Squashed 'SpiffWorkflow/' changes from 161cb7a45..bee868d38

bee868d38 Merge pull request #163 from sartography/feature/process_name_for_log_list
c0da286d9 use workflow_spec to match task_spec naming w/ burnettk
ac9e11927 Merge commit '71f8c94096534112c8a08f202f8bb0e6f81ed92f' into main
5bf6f3814 prefer the bpmn process name over the identifier on the logs list page w/ burnettk
dc511b082 workflow.catch() was nice, in that it is where we could send events and messages.  With this change sending an event to catch will behave incorrectly for BPMN Messages. Only sending it to the right method will create the desired result.  It also adds a lot of additional code.   Would love a careful review of this, and any optimizations anyone can think of.

git-subtree-dir: SpiffWorkflow
git-subtree-split: bee868d38b2c3da680c7a96b6a634d16b90d5861
This commit is contained in:
burnettk 2023-03-01 17:24:53 -05:00
parent 89196daed5
commit ce6de53a76
1 changed files with 10 additions and 4 deletions

View File

@ -1,5 +1,5 @@
from SpiffWorkflow.bpmn.specs.SubWorkflowTask import CallActivity
from SpiffWorkflow.bpmn.workflow import BpmnWorkflow
from SpiffWorkflow.bpmn.workflow import BpmnWorkflow, BpmnMessage
from SpiffWorkflow.task import TaskState
from tests.SpiffWorkflow.bpmn.BpmnWorkflowTestCase import BpmnWorkflowTestCase
@ -60,12 +60,18 @@ class CollaborationTest(BpmnWorkflowTestCase):
self.assertEqual('from_name', events[0]['value'][0].retrieval_expression)
self.assertEqual('lover_name', events[0]['value'][0].name)
workflow.catch_bpmn_message('Love Letter Response', messages[0].payload,
messages[0].correlations)
# As shown above, the waiting event is looking for a payload with a
# 'from_name' that should be used to retrieve the lover's name.
new_message_payload = {'from_name': 'Peggy', 'other_nonsense': 1001}
workflow.catch_bpmn_message('Love Letter Response', new_message_payload)
workflow.do_engine_steps()
# The external message created above should be caught
self.assertEqual(receive.state, TaskState.COMPLETED)
self.assertEqual(receive.data, messages[0].payload)
# Spiff extensions allow us to specify the destination of a workflow
# but base BPMN does not, and all keys are added directly to the
# task data.
self.assertEqual(workflow.last_task.data, {'from_name': 'Peggy', 'lover_name': 'Peggy', 'other_nonsense': 1001})
self.assertEqual(workflow.correlations, {'lover':{'lover_name':'Peggy'}})
self.assertEqual(workflow.is_completed(), True)
def testCorrelation(self):