diff --git a/Pipfile.lock b/Pipfile.lock index d66dc2a1..a66b351b 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1266,7 +1266,7 @@ }, "spiffworkflow": { "git": "https://github.com/sartography/SpiffWorkflow", - "ref": "747b0a9cafeb2900264dbc5235c01c2386c55bd1" + "ref": "5c9301a3f47bd3dbeae72ffefd9d25cfee35fd0e" }, "sqlalchemy": { "hashes": [ diff --git a/crc/services/workflow_service.py b/crc/services/workflow_service.py index c5eaeaf8..965235cf 100755 --- a/crc/services/workflow_service.py +++ b/crc/services/workflow_service.py @@ -172,10 +172,9 @@ class WorkflowService(object): """Raise an exception of the workflow is not enabled and can not be executed.""" if study_id is not None: study_model = session.query(StudyModel).filter(StudyModel.id == study_id).first() - spec_model = session.query(WorkflowSpecModel).filter(WorkflowSpecModel.id == spec_id).first() status = StudyService._get_study_status(study_model) - if spec_model.id in status and status[spec_model.id]['status'] == 'disabled': - raise ApiError(code='disabled_workflow', message=f"This workflow is disabled. {status[spec_model.id]['message']}") + if spec_id in status and status[spec_id]['status'] == 'disabled': + raise ApiError(code='disabled_workflow', message=f"This workflow is disabled. {status[spec_id]['message']}") @staticmethod @timeit @@ -191,6 +190,7 @@ class WorkflowService(object): """ workflow_model = WorkflowService.make_test_workflow(spec_id, validate_study_id) + WorkflowService.raise_if_disabled(spec_id, validate_study_id) try: processor = WorkflowProcessor(workflow_model, validate_only=True) count = 0 diff --git a/tests/workflow/test_workflow_spec_validation_api.py b/tests/workflow/test_workflow_spec_validation_api.py index 36224d17..55b97758 100644 --- a/tests/workflow/test_workflow_spec_validation_api.py +++ b/tests/workflow/test_workflow_spec_validation_api.py @@ -96,6 +96,14 @@ class TestWorkflowSpecValidation(BaseTest): def test_invalid_script3(self): self.load_test_spec('empty_workflow', master_spec=True) self.create_reference_document() + + workflow = self.create_workflow('delete_variables') + workflow_api = self.get_workflow_api(workflow) + task = workflow_api.next_task + workflow_api = self.complete_form(workflow, task, {}) +# for item in ('a', 'b', 'c', 'd', 'e'): +# self.assertIn(item, task.data) + errors = self.validate_workflow("invalid_script3") self.assertEqual(1, len(errors)) self.assertEqual("Invalid_Script_Task", errors[0]['task_id'])