mirror of
https://github.com/status-im/spiff-arena.git
synced 2025-01-10 02:05:40 +00:00
12b7fa2b70
ffb168675 Option to run tests in parallel (#271) 062eaf15d another hot match -- assure hit policy is correctly passed through. c79ee8407 Quick patch the DMN hit policy to fix a dump mistake. 36dd1b23a Fix ResourceWarning: unclosed file BpmnParser.py:60 (#270) bba7ddf54 Merge pull request #268 from sartography/feature/multiple-event-definition 8cf770985 remove unused import 9d31e035e make multiple throw events work with start events 890c4b921 add throw support for multiple events c1fc55660 add support for catching parallel multiple event definitions 511830b67 add event based gateway 56bd858dc add event type for multiple events git-subtree-dir: SpiffWorkflow git-subtree-split: ffb1686757f944065580dd2db8def73d6c1f0134
81 lines
2.8 KiB
Python
81 lines
2.8 KiB
Python
from SpiffWorkflow.bpmn.workflow import BpmnWorkflow
|
|
from SpiffWorkflow.bpmn.specs.events.event_definitions import MessageEventDefinition
|
|
|
|
from ..BpmnWorkflowTestCase import BpmnWorkflowTestCase
|
|
|
|
|
|
class MultipleStartEventTest(BpmnWorkflowTestCase):
|
|
|
|
def setUp(self):
|
|
self.spec, self.subprocesses = self.load_workflow_spec('multiple-start.bpmn', 'main')
|
|
self.workflow = BpmnWorkflow(self.spec)
|
|
|
|
def testMultipleStartEvent(self):
|
|
self.actual_test()
|
|
|
|
def testMultipleStartEventSaveRestore(self):
|
|
self.actual_test(True)
|
|
|
|
def actual_test(self, save_restore=False):
|
|
|
|
self.workflow.do_engine_steps()
|
|
waiting_tasks = self.workflow.get_waiting_tasks()
|
|
|
|
if save_restore:
|
|
self.save_restore()
|
|
|
|
# The start event should be waiting
|
|
self.assertEqual(len(waiting_tasks), 1)
|
|
self.assertEqual(waiting_tasks[0].task_spec.name, 'StartEvent_1')
|
|
|
|
self.workflow.catch(MessageEventDefinition('message_1'))
|
|
self.workflow.refresh_waiting_tasks()
|
|
self.workflow.do_engine_steps()
|
|
|
|
# Now the first task should be ready
|
|
ready_tasks = self.workflow.get_ready_user_tasks()
|
|
self.assertEqual(len(ready_tasks), 1)
|
|
self.assertEqual(ready_tasks[0].task_spec.name, 'any_task')
|
|
|
|
|
|
class ParallelStartEventTest(BpmnWorkflowTestCase):
|
|
|
|
def setUp(self):
|
|
self.spec, self.subprocesses = self.load_workflow_spec('multiple-start-parallel.bpmn', 'main')
|
|
self.workflow = BpmnWorkflow(self.spec)
|
|
|
|
def testParallelStartEvent(self):
|
|
self.actual_test()
|
|
|
|
def testParallelStartEventSaveRestore(self):
|
|
self.actual_test(True)
|
|
|
|
def actual_test(self, save_restore=False):
|
|
|
|
self.workflow.do_engine_steps()
|
|
waiting_tasks = self.workflow.get_waiting_tasks()
|
|
|
|
if save_restore:
|
|
self.save_restore()
|
|
|
|
# The start event should be waiting
|
|
self.assertEqual(len(waiting_tasks), 1)
|
|
self.assertEqual(waiting_tasks[0].task_spec.name, 'StartEvent_1')
|
|
|
|
self.workflow.catch(MessageEventDefinition('message_1'))
|
|
self.workflow.refresh_waiting_tasks()
|
|
self.workflow.do_engine_steps()
|
|
|
|
# It should still be waiting because it has to receive both messages
|
|
waiting_tasks = self.workflow.get_waiting_tasks()
|
|
self.assertEqual(len(waiting_tasks), 1)
|
|
self.assertEqual(waiting_tasks[0].task_spec.name, 'StartEvent_1')
|
|
|
|
self.workflow.catch(MessageEventDefinition('message_2'))
|
|
self.workflow.refresh_waiting_tasks()
|
|
self.workflow.do_engine_steps()
|
|
|
|
# Now the first task should be ready
|
|
ready_tasks = self.workflow.get_ready_user_tasks()
|
|
self.assertEqual(len(ready_tasks), 1)
|
|
self.assertEqual(ready_tasks[0].task_spec.name, 'any_task') |