From 3ff98fb51ed986b34bf7fd5236efacb440b9f2ca Mon Sep 17 00:00:00 2001 From: jasquat Date: Thu, 5 Jan 2023 17:35:20 -0500 Subject: [PATCH] Squashed 'SpiffWorkflow/' changes from 5664815a2..4195453a4 4195453a4 Merge commit 'b55571406634555736fc471e7a53ca8b22288980' 0629dcb9a added fix to SpiffWorkflow to deepcopy operation params before evaluating them w/ burnettk git-subtree-dir: SpiffWorkflow git-subtree-split: 4195453a46638f23e87c3ffdb038717c2d8abd00 --- SpiffWorkflow/spiff/specs/service_task.py | 4 +++- tests/SpiffWorkflow/spiff/ServiceTaskTest.py | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/SpiffWorkflow/spiff/specs/service_task.py b/SpiffWorkflow/spiff/specs/service_task.py index b1c63a943..80e3f3453 100644 --- a/SpiffWorkflow/spiff/specs/service_task.py +++ b/SpiffWorkflow/spiff/specs/service_task.py @@ -1,3 +1,4 @@ +from copy import deepcopy import json from SpiffWorkflow.bpmn.specs.ServiceTask import ServiceTask from SpiffWorkflow.spiff.specs.spiff_task import SpiffBpmnTask @@ -27,7 +28,8 @@ class ServiceTask(SpiffBpmnTask, ServiceTask): param['value'] = task.workflow.script_engine.evaluate(task, param['value']) return param - evaluated_params = {k: evaluate(v) for k, v in self.operation_params.items()} + operation_params_copy = deepcopy(self.operation_params) + evaluated_params = {k: evaluate(v) for k, v in operation_params_copy.items()} result = task.workflow.script_engine.call_service(self.operation_name, evaluated_params, task.data) diff --git a/tests/SpiffWorkflow/spiff/ServiceTaskTest.py b/tests/SpiffWorkflow/spiff/ServiceTaskTest.py index 9417b42ed..1d3035b3f 100644 --- a/tests/SpiffWorkflow/spiff/ServiceTaskTest.py +++ b/tests/SpiffWorkflow/spiff/ServiceTaskTest.py @@ -60,6 +60,15 @@ class ServiceTaskTest(BaseTestCase): self.workflow.do_engine_steps() self._assert_service_tasks() + def testRunSameServiceTaskActivityMultipleTimes(self): + self.workflow.do_engine_steps() + service_task_activity = [t for t in self.workflow.get_tasks() if + t.task_spec.name == 'Activity-1inxqgx'][0] + + service_task_activity.task_spec._execute(service_task_activity) + service_task_activity.task_spec._execute(service_task_activity) + service_task_activity.task_spec._execute(service_task_activity) + def testRunThroughSaveRestore(self): self.save_restore() # Engine isn't preserved through save/restore, so we have to reset it.