Skip to content

Commit

Permalink
Fix test 1
Browse files Browse the repository at this point in the history
  • Loading branch information
YolanFery committed Dec 20, 2024
1 parent f767d31 commit 0d71fef
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion hexa/pipeline_templates/schema/mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def resolve_create_pipeline_from_template_version(_, info, **kwargs):
except PipelineTemplateVersion.DoesNotExist:
return {"success": False, "errors": ["PIPELINE_TEMPLATE_VERSION_NOT_FOUND"]}

pipeline_code = template_version.template.source_pipeline.code
pipeline_code = f"{template_version.template.source_pipeline.code} (from Template)"
if Pipeline.objects.filter(workspace=workspace, code=pipeline_code).exists():
return {"success": False, "errors": ["PIPELINE_ALREADY_EXISTS"]}
pipeline = template_version.create_pipeline(pipeline_code, workspace, request.user)
Expand Down
20 changes: 16 additions & 4 deletions hexa/pipeline_templates/tests/test_schema/test_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,16 @@ def setUpTestData(cls):
name="WS1",
description="Workspace 1",
)
cls.PIPELINE = Pipeline.objects.create(name="Test Pipeline", workspace=cls.WS1)
cls.PIPELINE = Pipeline.objects.create(
name="Test Pipeline", code="Test Pipeline", workspace=cls.WS1
)
cls.PIPELINE_VERSION1 = PipelineVersion.objects.create(
pipeline=cls.PIPELINE,
version_number=1,
description="Initial version",
parameters=[{"code": "param_1"}],
config=[{"param_1": 1}],
zipfile=str.encode("some_bytes"),
)
cls.PIPELINE_VERSION2 = PipelineVersion.objects.create(
pipeline=cls.PIPELINE,
Expand Down Expand Up @@ -87,6 +92,7 @@ def test_create_template_version(self):

def test_create_pipeline_from_template_version(self):
self.client.force_login(self.USER_ROOT)
self.create_template_version(self.PIPELINE_VERSION1.id, [{"versionNumber": 1}])
r = self.run_query(
"""
mutation createPipelineFromTemplateVersion($input: CreatePipelineFromTemplateVersionInput!) {
Expand All @@ -98,7 +104,9 @@ def test_create_pipeline_from_template_version(self):
{
"input": {
"workspaceSlug": self.WS1.slug,
"pipelineTemplateVersionId": str(self.PIPELINE_VERSION1.id),
"pipelineTemplateVersionId": str(
self.PIPELINE_VERSION1.template_version.id
),
}
},
)
Expand All @@ -108,8 +116,12 @@ def test_create_pipeline_from_template_version(self):
"errors": [],
"pipeline": {
"name": self.PIPELINE.name,
"code": self.PIPELINE.code,
"currentVersion": {"zipfile": "a", "parameters": "", "config": ""},
"code": "Test Pipeline (from Template)",
"currentVersion": {
"zipfile": "c29tZV9ieXRlcw==",
"parameters": [{"code": "param_1", "default": None}],
"config": [{"param_1": 1}],
},
},
},
r["data"]["createPipelineFromTemplateVersion"],
Expand Down

0 comments on commit 0d71fef

Please sign in to comment.