-class TestCreateTemplate(unittest.TestCase):
- existing_template_uuid = "zzzzz-d1hrv-validworkfloyml"
-
- def _adjust_script_params(self, expect_component):
- expect_component['script_parameters']['x'] = {
- 'dataclass': 'File',
- 'required': True,
- 'type': 'File',
- 'value': '169f39d466a5438ac4a90e779bf750c7+53/blorp.txt',
- }
- expect_component['script_parameters']['y'] = {
- 'dataclass': 'Collection',
- 'required': True,
- 'type': 'Directory',
- 'value': '99999999999999999999999999999998+99',
- }
- expect_component['script_parameters']['z'] = {
- 'dataclass': 'Collection',
- 'required': True,
- 'type': 'Directory',
- }
-
- @stubs
- def test_create(self, stubs):
- project_uuid = 'zzzzz-j7d0g-zzzzzzzzzzzzzzz'
-
- exited = arvados_cwl.main(
- ["--create-workflow", "--debug",
- "--api=jobs",
- "--project-uuid", project_uuid,
- "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"],
- stubs.capture_stdout, sys.stderr, api_client=stubs.api)
-
- stubs.api.pipeline_instances().create.refute_called()
- stubs.api.jobs().create.refute_called()
-
- expect_component = copy.deepcopy(stubs.expect_job_spec)
- self._adjust_script_params(expect_component)
- expect_template = {
- "components": {
- "submit_wf.cwl": expect_component,
- },
- "name": "submit_wf.cwl",
- "owner_uuid": project_uuid,
- }
- stubs.api.pipeline_templates().create.assert_called_with(
- body=JsonDiffMatcher(expect_template), ensure_unique_name=True)
-
- self.assertEqual(stubs.capture_stdout.getvalue(),
- stubs.expect_pipeline_template_uuid + '\n')
- self.assertEqual(exited, 0)
-
- @stubs
- def test_create_name(self, stubs):
- project_uuid = 'zzzzz-j7d0g-zzzzzzzzzzzzzzz'
-
- exited = arvados_cwl.main(
- ["--create-workflow", "--debug",
- "--project-uuid", project_uuid,
- "--api=jobs",
- "--name", "testing 123",
- "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"],
- stubs.capture_stdout, sys.stderr, api_client=stubs.api)
-
- stubs.api.pipeline_instances().create.refute_called()
- stubs.api.jobs().create.refute_called()
-
- expect_component = copy.deepcopy(stubs.expect_job_spec)
- self._adjust_script_params(expect_component)
- expect_template = {
- "components": {
- "testing 123": expect_component,
- },
- "name": "testing 123",
- "owner_uuid": project_uuid,
- }
- stubs.api.pipeline_templates().create.assert_called_with(
- body=JsonDiffMatcher(expect_template), ensure_unique_name=True)
-
- self.assertEqual(stubs.capture_stdout.getvalue(),
- stubs.expect_pipeline_template_uuid + '\n')
- self.assertEqual(exited, 0)
-
- @stubs
- def test_update_name(self, stubs):
- project_uuid = 'zzzzz-j7d0g-zzzzzzzzzzzzzzz'
-
- exited = arvados_cwl.main(
- ["--update-workflow", self.existing_template_uuid,
- "--debug",
- "--project-uuid", project_uuid,
- "--api=jobs",
- "--name", "testing 123",
- "tests/wf/submit_wf.cwl", "tests/submit_test_job.json"],
- stubs.capture_stdout, sys.stderr, api_client=stubs.api)
-
- stubs.api.pipeline_instances().create.refute_called()
- stubs.api.jobs().create.refute_called()
-
- expect_component = copy.deepcopy(stubs.expect_job_spec)
- self._adjust_script_params(expect_component)
- expect_template = {
- "components": {
- "testing 123": expect_component,
- },
- "name": "testing 123",
- "owner_uuid": project_uuid,
- }
- stubs.api.pipeline_templates().create.refute_called()
- stubs.api.pipeline_templates().update.assert_called_with(
- body=JsonDiffMatcher(expect_template), uuid=self.existing_template_uuid)
-
- self.assertEqual(stubs.capture_stdout.getvalue(),
- self.existing_template_uuid + '\n')
- self.assertEqual(exited, 0)
-
-