From d9370f6608ac7bbb89809665132dfb28157091b3 Mon Sep 17 00:00:00 2001 From: burnettk Date: Mon, 27 Mar 2023 17:02:29 -0400 Subject: [PATCH 1/3] tests have been broken in ci, and this should fix it --- spiffworkflow-backend/poetry.lock | 2 +- .../src/spiffworkflow_backend/routes/tasks_controller.py | 2 +- .../services/process_instance_processor.py | 2 +- .../src/spiffworkflow_backend/services/task_service.py | 2 +- .../integration/test_logging_service.py | 2 +- .../unit/test_process_instance_processor.py | 6 +++--- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/spiffworkflow-backend/poetry.lock b/spiffworkflow-backend/poetry.lock index a8d70db3..b96b8d78 100644 --- a/spiffworkflow-backend/poetry.lock +++ b/spiffworkflow-backend/poetry.lock @@ -1895,7 +1895,7 @@ lxml = "*" type = "git" url = "https://github.com/sartography/SpiffWorkflow" reference = "main" -resolved_reference = "f162aac43af3af18d1a55186aeccea154fb8b05d" +resolved_reference = "3c3345c85dd7f3b7112ad04aaa6487abbd2e9414" [[package]] name = "SQLAlchemy" diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py index 50a4402a..baebd04c 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py @@ -636,7 +636,7 @@ def _get_spiff_task_from_process_instance( if processor is None: processor = ProcessInstanceProcessor(process_instance) task_uuid = uuid.UUID(task_guid) - spiff_task = processor.bpmn_process_instance.get_task(task_uuid) + spiff_task = processor.bpmn_process_instance.get_task_from_id(task_uuid) if spiff_task is None: raise ( diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py index 722baa0d..7e3028fd 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py @@ -1173,7 +1173,7 @@ class ProcessInstanceProcessor: """Mark the task complete optionally executing it.""" spiff_tasks_updated = {} start_in_seconds = time.time() - spiff_task = self.bpmn_process_instance.get_task(UUID(task_id)) + spiff_task = self.bpmn_process_instance.get_task_from_id(UUID(task_id)) event_type = ProcessInstanceEventType.task_skipped.value if execute: current_app.logger.info( diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/task_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/task_service.py index d3cf545c..90cd2919 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/task_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/task_service.py @@ -255,7 +255,7 @@ class TaskService: task_data_dict = task_properties.pop("data") state_int = task_properties["state"] - spiff_task = spiff_workflow.get_task(UUID(task_id)) + spiff_task = spiff_workflow.get_task_from_id(UUID(task_id)) task_model = TaskModel.query.filter_by(guid=task_id).first() if task_model is None: diff --git a/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_logging_service.py b/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_logging_service.py index 41f30563..7890e156 100644 --- a/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_logging_service.py +++ b/spiffworkflow-backend/tests/spiffworkflow_backend/integration/test_logging_service.py @@ -114,7 +114,7 @@ class TestLoggingService(BaseTest): process_instance = ProcessInstanceModel.query.filter_by(id=process_instance.id).first() processor = ProcessInstanceProcessor(process_instance) human_task_one = process_instance.active_human_tasks[0] - spiff_manual_task = processor.bpmn_process_instance.get_task(UUID(human_task_one.task_id)) + spiff_manual_task = processor.bpmn_process_instance.get_task_from_id(UUID(human_task_one.task_id)) ProcessInstanceService.complete_form_task(processor, spiff_manual_task, {}, initiator_user, human_task_one) headers = self.logged_in_headers(with_super_admin_user) diff --git a/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_instance_processor.py b/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_instance_processor.py index 37709197..4cacfe80 100644 --- a/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_instance_processor.py +++ b/spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_instance_processor.py @@ -305,10 +305,10 @@ class TestProcessInstanceProcessor(BaseTest): # process_instance = ProcessInstanceModel.query.filter_by(id=process_instance.id).first() # processor = ProcessInstanceProcessor(process_instance) # human_task_one = process_instance.active_human_tasks[0] - # spiff_manual_task = processor.bpmn_process_instance.get_task(UUID(human_task_one.task_id)) + # spiff_manual_task = processor.bpmn_process_instance.get_task_from_id(UUID(human_task_one.task_id)) # ProcessInstanceService.complete_form_task(processor, spiff_manual_task, {}, initiator_user, human_task_one) # human_task_one = process_instance.active_human_tasks[0] - # spiff_manual_task = processor.bpmn_process_instance.get_task(UUID(human_task_one.task_id)) + # spiff_manual_task = processor.bpmn_process_instance.get_task_from_id(UUID(human_task_one.task_id)) # ProcessInstanceService.complete_form_task(processor, spiff_manual_task, {}, initiator_user, human_task_one) def test_properly_saves_tasks_when_running( @@ -356,7 +356,7 @@ class TestProcessInstanceProcessor(BaseTest): process_instance = ProcessInstanceModel.query.filter_by(id=process_instance.id).first() processor = ProcessInstanceProcessor(process_instance) human_task_one = process_instance.active_human_tasks[0] - spiff_manual_task = processor.bpmn_process_instance.get_task(UUID(human_task_one.task_id)) + spiff_manual_task = processor.bpmn_process_instance.get_task_from_id(UUID(human_task_one.task_id)) ProcessInstanceService.complete_form_task(processor, spiff_manual_task, {}, initiator_user, human_task_one) # recreate variables to ensure all bpmn json was recreated from scratch from the db From 422aaf09daa76028f8cf10120bd8fa5c7fa3c819 Mon Sep 17 00:00:00 2001 From: burnettk Date: Mon, 27 Mar 2023 20:22:12 -0400 Subject: [PATCH 2/3] task_guid is a str, thanks, typeguard --- .../src/spiffworkflow_backend/routes/tasks_controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py index baebd04c..3d0eac40 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py @@ -175,7 +175,7 @@ def task_list_for_my_groups( def task_data_show( modified_process_model_identifier: str, process_instance_id: int, - task_guid: int = 0, + task_guid: str, ) -> flask.wrappers.Response: task_model = TaskModel.query.filter_by(guid=task_guid, process_instance_id=process_instance_id).first() if task_model is None: From 54b1a43494c1ebdcf9202a527034838cbebd4fc1 Mon Sep 17 00:00:00 2001 From: burnettk Date: Tue, 28 Mar 2023 08:04:42 -0400 Subject: [PATCH 3/3] lint --- .../services/process_instance_processor.py | 4 ++-- .../services/workflow_execution_service.py | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py index 54ee33b2..76b3d9ac 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py @@ -1,7 +1,5 @@ """Process_instance_processor.""" import _strptime # type: ignore -from sqlalchemy import or_ -from sqlalchemy import and_ import decimal import json import logging @@ -53,6 +51,8 @@ from SpiffWorkflow.spiff.serializer.config import SPIFF_SPEC_CONFIG # type: ign from SpiffWorkflow.task import Task as SpiffTask # type: ignore from SpiffWorkflow.task import TaskState from SpiffWorkflow.util.deep_merge import DeepMerge # type: ignore +from sqlalchemy import and_ +from sqlalchemy import or_ from spiffworkflow_backend.exceptions.api_error import ApiError from spiffworkflow_backend.models.bpmn_process import BpmnProcessModel diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/workflow_execution_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/workflow_execution_service.py index 99ef4ee6..ac0f1a41 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/workflow_execution_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/workflow_execution_service.py @@ -1,8 +1,8 @@ import logging import time -from uuid import UUID from typing import Callable from typing import Optional +from uuid import UUID from SpiffWorkflow.bpmn.serializer.workflow import BpmnWorkflowSerializer # type: ignore from SpiffWorkflow.bpmn.workflow import BpmnWorkflow # type: ignore @@ -83,7 +83,7 @@ class TaskModelSavingDelegate(EngineStepDelegate): raise Exception("Could not find cached current_task_start_in_seconds. This should never have happend") task_model.start_in_seconds = self.current_task_start_in_seconds task_model.end_in_seconds = time.time() - self.last_completed_spiff_task= spiff_task + self.last_completed_spiff_task = spiff_task if self.secondary_engine_step_delegate: self.secondary_engine_step_delegate.did_complete_task(spiff_task) @@ -123,7 +123,9 @@ class TaskModelSavingDelegate(EngineStepDelegate): def _process_spiff_task_parents(self, spiff_task: SpiffTask) -> None: (parent_subprocess_guid, _parent_subprocess) = TaskService.task_subprocess(spiff_task) if parent_subprocess_guid is not None: - spiff_task_of_parent_subprocess = spiff_task.workflow._get_outermost_workflow().get_task(UUID(parent_subprocess_guid)) + spiff_task_of_parent_subprocess = spiff_task.workflow._get_outermost_workflow().get_task( + UUID(parent_subprocess_guid) + ) if spiff_task_of_parent_subprocess is not None: self._update_task_model_with_spiff_task(spiff_task_of_parent_subprocess)