class MessageInterruptsSpTest(BpmnWorkflowTestCase): def setUp(self): self.spec = self.load_spec() def load_spec(self): return self.load_workflow_spec('Test-Workflows/*.bpmn20.xml', 'Message Interrupts SP') def testRunThroughHappySaveAndRestore(self): self.workflow = BpmnWorkflow(self.spec) self.save_restore() self.workflow.do_engine_steps() self.save_restore() self.assertEqual(1, len(self.workflow.get_tasks(Task.READY))) self.assertEqual(1, len(self.workflow.get_tasks(Task.WAITING))) self.do_next_exclusive_step('Do Something In a Subprocess') self.workflow.do_engine_steps() self.save_restore() self.do_next_exclusive_step('Ack Subprocess Done') self.workflow.do_engine_steps() self.save_restore() self.workflow.do_engine_steps() self.assertEqual( 0, len(self.workflow.get_tasks(Task.READY | Task.WAITING))) def testRunThroughInterruptSaveAndRestore(self): self.workflow = BpmnWorkflow(self.spec) self.save_restore() self.workflow.do_engine_steps() self.save_restore() self.assertEqual(1, len(self.workflow.get_tasks(Task.READY))) self.assertEqual(1, len(self.workflow.get_tasks(Task.WAITING))) self.workflow.accept_message('Test Message') self.workflow.do_engine_steps() self.save_restore() self.do_next_exclusive_step('Acknowledge SP Interrupt Message') self.workflow.do_engine_steps() self.save_restore() self.workflow.do_engine_steps() self.assertEqual( 0, len(self.workflow.get_tasks(Task.READY | Task.WAITING)))
class MessageInterruptsSpTest(BpmnWorkflowTestCase): def setUp(self): self.spec = self.load_spec() def load_spec(self): return self.load_workflow_spec('Test-Workflows/*.bpmn20.xml', 'Message Interrupts SP') def testRunThroughHappySaveAndRestore(self): self.workflow = BpmnWorkflow(self.spec) self.save_restore() self.workflow.do_engine_steps() self.save_restore() self.assertEqual(1, len(self.workflow.get_tasks(Task.READY))) self.assertEqual(1, len(self.workflow.get_tasks(Task.WAITING))) self.do_next_exclusive_step('Do Something In a Subprocess') self.workflow.do_engine_steps() self.save_restore() self.do_next_exclusive_step('Ack Subprocess Done') self.workflow.do_engine_steps() self.save_restore() self.workflow.do_engine_steps() self.assertEqual( 0, len(self.workflow.get_tasks(Task.READY | Task.WAITING))) def testRunThroughInterruptSaveAndRestore(self): self.workflow = BpmnWorkflow(self.spec) self.save_restore() self.workflow.do_engine_steps() self.save_restore() self.assertEqual(1, len(self.workflow.get_tasks(Task.READY))) self.assertEqual(1, len(self.workflow.get_tasks(Task.WAITING))) self.workflow.accept_message('Test Message') self.workflow.do_engine_steps() self.save_restore() self.do_next_exclusive_step('Acknowledge SP Interrupt Message') self.workflow.do_engine_steps() self.save_restore() self.workflow.do_engine_steps() self.assertEqual( 0, len(self.workflow.get_tasks(Task.READY | Task.WAITING)))
class MessagesTest(BpmnWorkflowTestCase): def setUp(self): self.spec = self.load_spec() def load_spec(self): return self.load_workflow_spec('Test-Workflows/*.bpmn20.xml', 'Test Workflows') def testRunThroughHappy(self): self.workflow = BpmnWorkflow(self.spec) self.do_next_exclusive_step('Select Test', choice='Messages') self.workflow.do_engine_steps() self.assertEqual([], self.workflow.get_tasks(Task.READY)) self.assertEqual(1, len(self.workflow.get_tasks(Task.WAITING))) self.workflow.accept_message('Wrong Message') self.assertEqual([], self.workflow.get_tasks(Task.READY)) self.workflow.accept_message('Test Message') self.assertEqual(1, len(self.workflow.get_tasks(Task.READY))) self.assertEqual( 'Test Message', self.workflow.get_tasks(Task.READY)[0].task_spec.description) self.workflow.do_engine_steps() self.assertEqual( 0, len(self.workflow.get_tasks(Task.READY | Task.WAITING))) def testRunThroughSaveAndRestore(self): self.workflow = BpmnWorkflow(self.spec) self.do_next_exclusive_step('Select Test', choice='Messages') self.workflow.do_engine_steps() self.save_restore() self.assertEqual([], self.workflow.get_tasks(Task.READY)) self.assertEqual(1, len(self.workflow.get_tasks(Task.WAITING))) self.workflow.accept_message('Wrong Message') self.assertEqual([], self.workflow.get_tasks(Task.READY)) self.workflow.accept_message('Test Message') self.save_restore() self.workflow.do_engine_steps() self.assertEqual( 0, len(self.workflow.get_tasks(Task.READY | Task.WAITING)))
class MessageNonInterruptTest(BpmnWorkflowTestCase): def setUp(self): self.spec = self.load_spec() # self.spec.dump() def load_spec(self): return self.load_workflow_spec('Test-Workflows/*.bpmn20.xml', 'Test Workflows') def testRunThroughHappySaveAndRestore(self): self.workflow = BpmnWorkflow(self.spec) self.save_restore() self.do_next_exclusive_step('Select Test', choice='Message Non Interrupt') self.workflow.do_engine_steps() self.save_restore() self.assertEqual(1, len(self.workflow.get_tasks(Task.READY))) self.assertEqual(1, len(self.workflow.get_tasks(Task.WAITING))) self.do_next_exclusive_step('Do Something That Takes A Long Time') self.save_restore() self.workflow.do_engine_steps() self.assertEqual(0, len(self.workflow.get_tasks(Task.WAITING))) self.save_restore() self.workflow.do_engine_steps() self.assertEqual( 0, len(self.workflow.get_tasks(Task.READY | Task.WAITING))) def testRunThroughMessageInterruptSaveAndRestore(self): self.workflow = BpmnWorkflow(self.spec) self.save_restore() self.do_next_exclusive_step('Select Test', choice='Message Non Interrupt') self.workflow.do_engine_steps() self.save_restore() self.assertEqual(1, len(self.workflow.get_tasks(Task.READY))) self.assertEqual(1, len(self.workflow.get_tasks(Task.WAITING))) self.workflow.accept_message('Test Message') self.save_restore() self.workflow.do_engine_steps() self.assertEqual(0, len(self.workflow.get_tasks(Task.WAITING))) self.assertEqual(2, len(self.workflow.get_tasks(Task.READY))) self.do_next_named_step('Acknowledge Non-Interrupt Message') self.workflow.do_engine_steps() self.save_restore() self.workflow.do_engine_steps() self.assertEqual(1, len(self.workflow.get_tasks(Task.READY))) self.assertEqual(1, len(self.workflow.get_tasks(Task.READY))) self.do_next_named_step('Do Something That Takes A Long Time') self.workflow.do_engine_steps() self.save_restore() self.workflow.do_engine_steps() self.assertEqual( 0, len(self.workflow.get_tasks(Task.READY | Task.WAITING))) def testRunThroughHappy(self): self.workflow = BpmnWorkflow(self.spec) self.do_next_exclusive_step('Select Test', choice='Message Non Interrupt') self.workflow.do_engine_steps() self.assertEqual(1, len(self.workflow.get_tasks(Task.READY))) self.assertEqual(1, len(self.workflow.get_tasks(Task.WAITING))) self.do_next_exclusive_step('Do Something That Takes A Long Time') self.workflow.do_engine_steps() self.assertEqual(0, len(self.workflow.get_tasks(Task.WAITING))) self.workflow.do_engine_steps() self.assertEqual( 0, len(self.workflow.get_tasks(Task.READY | Task.WAITING))) def testRunThroughMessageInterrupt(self): self.workflow = BpmnWorkflow(self.spec) self.do_next_exclusive_step('Select Test', choice='Message Non Interrupt') self.workflow.do_engine_steps() self.assertEqual(1, len(self.workflow.get_tasks(Task.READY))) self.assertEqual(1, len(self.workflow.get_tasks(Task.WAITING))) self.workflow.accept_message('Test Message') self.workflow.do_engine_steps() self.assertEqual(0, len(self.workflow.get_tasks(Task.WAITING))) self.assertEqual(2, len(self.workflow.get_tasks(Task.READY))) self.do_next_named_step('Acknowledge Non-Interrupt Message') self.workflow.do_engine_steps() self.assertEqual(1, len(self.workflow.get_tasks(Task.READY))) self.assertEqual(1, len(self.workflow.get_tasks(Task.WAITING))) self.do_next_named_step('Do Something That Takes A Long Time') self.workflow.do_engine_steps() self.assertEqual( 0, len(self.workflow.get_tasks(Task.READY | Task.WAITING))) def testRunThroughMessageInterruptOtherOrder(self): self.workflow = BpmnWorkflow(self.spec) self.do_next_exclusive_step('Select Test', choice='Message Non Interrupt') self.workflow.do_engine_steps() self.assertEqual(1, len(self.workflow.get_tasks(Task.READY))) self.assertEqual(1, len(self.workflow.get_tasks(Task.WAITING))) self.workflow.accept_message('Test Message') self.workflow.do_engine_steps() self.assertEqual(0, len(self.workflow.get_tasks(Task.WAITING))) self.assertEqual(2, len(self.workflow.get_tasks(Task.READY))) self.do_next_named_step('Do Something That Takes A Long Time') self.workflow.do_engine_steps() self.assertEqual(1, len(self.workflow.get_tasks(Task.READY))) self.do_next_named_step('Acknowledge Non-Interrupt Message') self.workflow.do_engine_steps() self.assertEqual( 0, len(self.workflow.get_tasks(Task.READY | Task.WAITING))) def testRunThroughMessageInterruptOtherOrderSaveAndRestore(self): self.workflow = BpmnWorkflow(self.spec) self.save_restore() self.do_next_exclusive_step('Select Test', choice='Message Non Interrupt') self.workflow.do_engine_steps() self.save_restore() self.assertEqual(1, len(self.workflow.get_tasks(Task.READY))) self.assertEqual(1, len(self.workflow.get_tasks(Task.WAITING))) self.workflow.accept_message('Test Message') self.save_restore() self.workflow.do_engine_steps() self.assertEqual(0, len(self.workflow.get_tasks(Task.WAITING))) self.assertEqual(2, len(self.workflow.get_tasks(Task.READY))) self.do_next_named_step('Do Something That Takes A Long Time') self.save_restore() self.workflow.do_engine_steps() self.assertEqual(1, len(self.workflow.get_tasks(Task.READY))) self.assertEqual(1, len(self.workflow.get_tasks(Task.READY))) self.do_next_named_step('Acknowledge Non-Interrupt Message') self.save_restore() self.workflow.do_engine_steps() self.assertEqual( 0, len(self.workflow.get_tasks(Task.READY | Task.WAITING)))
class MessageInterruptsTest(BpmnWorkflowTestCase): def setUp(self): self.spec = self.load_spec() # self.spec.dump() def load_spec(self): return self.load_workflow_spec('Test-Workflows/*.bpmn20.xml', 'Test Workflows') def testRunThroughHappySaveAndRestore(self): self.workflow = BpmnWorkflow(self.spec) self.save_restore() self.do_next_exclusive_step('Select Test', choice='Message Interrupts') self.workflow.do_engine_steps() self.save_restore() self.assertEqual(1, len(self.workflow.get_tasks(Task.READY))) self.assertEqual(1, len(self.workflow.get_tasks(Task.WAITING))) self.do_next_exclusive_step('Do Something That Takes A Long Time') self.save_restore() self.workflow.do_engine_steps() self.assertEqual(0, len(self.workflow.get_tasks(Task.WAITING))) self.save_restore() self.workflow.do_engine_steps() self.assertEqual( 0, len(self.workflow.get_tasks(Task.READY | Task.WAITING))) def testRunThroughMessageInterruptSaveAndRestore(self): self.workflow = BpmnWorkflow(self.spec) self.save_restore() self.do_next_exclusive_step('Select Test', choice='Message Interrupts') self.workflow.do_engine_steps() self.save_restore() self.assertEqual(1, len(self.workflow.get_tasks(Task.READY))) self.assertEqual(1, len(self.workflow.get_tasks(Task.WAITING))) self.workflow.accept_message('Test Message') self.save_restore() self.workflow.do_engine_steps() self.save_restore() self.assertEqual(0, len(self.workflow.get_tasks(Task.WAITING))) self.assertEqual(1, len(self.workflow.get_tasks(Task.READY))) self.do_next_exclusive_step('Acknowledge Interrupt Message') self.save_restore() self.workflow.do_engine_steps() self.save_restore() self.assertEqual( 0, len(self.workflow.get_tasks(Task.READY | Task.WAITING))) def testRunThroughHappy(self): self.workflow = BpmnWorkflow(self.spec) self.do_next_exclusive_step('Select Test', choice='Message Interrupts') self.workflow.do_engine_steps() self.assertEqual(1, len(self.workflow.get_tasks(Task.READY))) self.assertEqual(1, len(self.workflow.get_tasks(Task.WAITING))) self.do_next_exclusive_step('Do Something That Takes A Long Time') self.workflow.do_engine_steps() self.assertEqual(0, len(self.workflow.get_tasks(Task.WAITING))) self.workflow.do_engine_steps() self.assertEqual( 0, len(self.workflow.get_tasks(Task.READY | Task.WAITING))) def testRunThroughMessageInterrupt(self): self.workflow = BpmnWorkflow(self.spec) self.do_next_exclusive_step('Select Test', choice='Message Interrupts') self.workflow.do_engine_steps() self.assertEqual(1, len(self.workflow.get_tasks(Task.READY))) self.assertEqual(1, len(self.workflow.get_tasks(Task.WAITING))) self.workflow.accept_message('Test Message') self.workflow.do_engine_steps() self.assertEqual(0, len(self.workflow.get_tasks(Task.WAITING))) self.assertEqual(1, len(self.workflow.get_tasks(Task.READY))) self.do_next_exclusive_step('Acknowledge Interrupt Message') self.workflow.do_engine_steps() self.assertEqual( 0, len(self.workflow.get_tasks(Task.READY | Task.WAITING)))
if __name__ == '__main__': spec=load_workflow_spec('Test-Workflows/*.bpmn20.xml', 'Test Workflows') workflow=BpmnWorkflow(spec) task_spec0=workflow.get_task_spec_from_name('sid-6A83C24E-9609-47CD-B595-BCFC30BBF790') task_spec0.ready_event.connect(usertask1) task_spec1=workflow.get_task_spec_from_name('sid-5A3ED200-8278-4D1F-9F84-B5E53B268133') task_spec2=workflow.get_task_spec_from_name('sid-464B8E64-10B4-4158-BDEE-11144CE20306') task_spec2.ready_event.connect(end) workflow.do_engine_steps() workflow.get_tasks(Task.READY)[0].complete() workflow.do_engine_steps() workflow.accept_message('Test Message') workflow.get_tasks(Task.READY)[0].complete() workflow.do_engine_steps()