From 369b518384970fc148b8ebf030acbd850494c89a Mon Sep 17 00:00:00 2001 From: NWalker4483 Date: Tue, 22 Jun 2021 11:29:00 -0400 Subject: [PATCH] Removed WorkflowService.delete_test_data() --- .vscode/settings.json | 3 ++ crc/services/workflow_service.py | 78 +++++++++++++++----------------- 2 files changed, 39 insertions(+), 42 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..18eec337 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.pythonPath": "/Users/nilewalker/.local/share/virtualenvs/cr-connect-workflow-pBIHH0UI/bin/python" +} \ No newline at end of file diff --git a/crc/services/workflow_service.py b/crc/services/workflow_service.py index 647f50a8..77a00cb4 100644 --- a/crc/services/workflow_service.py +++ b/crc/services/workflow_service.py @@ -110,49 +110,43 @@ class WorkflowService(object): count = 0 while not processor.bpmn_workflow.is_completed(): - if count < 100: # check for infinite loop - try: - processor.bpmn_workflow.get_deep_nav_list() # Assure no errors with navigation. - exit_task = processor.bpmn_workflow.do_engine_steps(exit_at=test_until) - if (exit_task != None): - WorkflowService.delete_test_data() - raise ApiError.from_task("validation_break", - f"The validation has been exited early on task '{exit_task.task_spec.name}' and was parented by ", - exit_task.parent) - tasks = processor.bpmn_workflow.get_tasks(SpiffTask.READY) - for task in tasks: - if task.task_spec.lane is not None and task.task_spec.lane not in task.data: - raise ApiError.from_task("invalid_role", - f"This task is in a lane called '{task.task_spec.lane}', The " - f" current task data must have information mapping this role to " - f" a unique user id.", task) - task_api = WorkflowService.spiff_task_to_api_task( - task, - add_docs_and_forms=True) # Assure we try to process the documentation, and raise those errors. - # make sure forms have a form key - if hasattr(task_api, 'form') and task_api.form is not None and task_api.form.key == '': - raise ApiError(code='missing_form_key', - message='Forms must include a Form Key.', - task_id=task.id, - task_name=task.get_name()) - WorkflowService.populate_form_with_random_data(task, task_api, required_only) - processor.complete_task(task) - if test_until == task.task_spec.name: - WorkflowService.delete_test_data() - raise ApiError.from_task("validation_break", - f"The validation has been exited early on task '{task.task_spec.name}' and was parented by ", - task.parent) - count += 1 - except WorkflowException as we: - WorkflowService.delete_test_data() - raise ApiError.from_workflow_exception("workflow_validation_exception", str(we), we) - else: - raise ApiError.from_task(code='validation_loop', - message=f'There appears to be an infinite loop in the validation. Task is {task.task_spec.description}', - task=task) - - WorkflowService.delete_test_data() + processor.bpmn_workflow.get_deep_nav_list() # Assure no errors with navigation. + exit_task = processor.bpmn_workflow.do_engine_steps(exit_at=test_until) + if (exit_task != None): + raise ApiError.from_task("validation_break", + f"The validation has been exited early on task '{exit_task.task_spec.name}' and was parented by ", + exit_task.parent) + tasks = processor.bpmn_workflow.get_tasks(SpiffTask.READY) + for task in tasks: + if task.task_spec.lane is not None and task.task_spec.lane not in task.data: + raise ApiError.from_task("invalid_role", + f"This task is in a lane called '{task.task_spec.lane}', The " + f" current task data must have information mapping this role to " + f" a unique user id.", task) + task_api = WorkflowService.spiff_task_to_api_task( + task, + add_docs_and_forms=True) # Assure we try to process the documentation, and raise those errors. + # make sure forms have a form key + if hasattr(task_api, 'form') and task_api.form is not None and task_api.form.key == '': + raise ApiError(code='missing_form_key', + message='Forms must include a Form Key.', + task_id=task.id, + task_name=task.get_name()) + WorkflowService.populate_form_with_random_data(task, task_api, required_only) + processor.complete_task(task) + if test_until == task.task_spec.name: + raise ApiError.from_task("validation_break", + f"The validation has been exited early on task '{task.task_spec.name}' and was parented by ", + task.parent) + count += 1 + if count >= 100: + raise ApiError.from_task(code='validation_loop', + message=f'There appears to be an infinite loop in the validation. Task is {task.task_spec.description}', + task=task) WorkflowService._process_documentation(processor.bpmn_workflow.last_task.parent.parent) + + except WorkflowException as we: + raise ApiError.from_workflow_exception("workflow_validation_exception", str(we), we) finally: WorkflowService.delete_test_data(workflow_model) return processor.bpmn_workflow.last_task.data