mirror of
https://github.com/status-im/spiff-arena.git
synced 2025-01-10 02:05:40 +00:00
69e814758e
d27519a36 Merge pull request #259 from sartography/bugfix/spiff-postscript-execution 21aa8a12c update execution order for postscripts d83fd3d81 Merge pull request #256 from sartography/feature/xml-validation 8303aaab5 uping the sleep time in a test slightly to see if we can get this test to pass consistently in CI. 1d251d55d determine whether to validate by passing in a validator instead of a parameter 2d3daad2d add spiff schema f8c65dc60 Minor changes to BPMN diagrams to assure all tests are run against valid BPMN Diagrams. Changes required: 9e06b25bf add DMN validation 1b7cbeba0 set parser to validate by default 53fdbba52 add schemas & validation option a212d9c5d general cleanup git-subtree-dir: SpiffWorkflow git-subtree-split: d27519a3631b9772094e5f24dba2f478b0c47135
188 lines
7.0 KiB
Python
188 lines
7.0 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
import unittest
|
|
|
|
from SpiffWorkflow.task import TaskState
|
|
from SpiffWorkflow.bpmn.workflow import BpmnWorkflow
|
|
from SpiffWorkflow.bpmn.specs.events.event_definitions import MessageEventDefinition
|
|
from tests.SpiffWorkflow.bpmn.BpmnWorkflowTestCase import BpmnWorkflowTestCase
|
|
|
|
__author__ = 'matth'
|
|
|
|
|
|
class MessageNonInterruptTest(BpmnWorkflowTestCase):
|
|
|
|
def setUp(self):
|
|
self.spec, self.subprocesses = self.load_workflow_spec('Test-Workflows/*.bpmn20.xml', 'Test Workflows', False)
|
|
|
|
def testRunThroughHappySaveAndRestore(self):
|
|
|
|
self.workflow = BpmnWorkflow(self.spec, self.subprocesses)
|
|
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(TaskState.READY)))
|
|
self.assertEqual(2, len(self.workflow.get_tasks(TaskState.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(TaskState.WAITING)))
|
|
|
|
self.save_restore()
|
|
|
|
self.workflow.do_engine_steps()
|
|
self.assertEqual(
|
|
0, len(self.workflow.get_tasks(TaskState.READY | TaskState.WAITING)))
|
|
|
|
def testRunThroughMessageInterruptSaveAndRestore(self):
|
|
|
|
self.workflow = BpmnWorkflow(self.spec, self.subprocesses)
|
|
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(TaskState.READY)))
|
|
self.assertEqual(2, len(self.workflow.get_tasks(TaskState.WAITING)))
|
|
|
|
self.workflow.catch(MessageEventDefinition('Test Message'))
|
|
self.save_restore()
|
|
|
|
self.workflow.do_engine_steps()
|
|
self.assertEqual(1, len(self.workflow.get_tasks(TaskState.WAITING)))
|
|
self.assertEqual(2, len(self.workflow.get_tasks(TaskState.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(TaskState.READY)))
|
|
self.assertEqual(1, len(self.workflow.get_tasks(TaskState.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(TaskState.READY | TaskState.WAITING)))
|
|
|
|
def testRunThroughHappy(self):
|
|
|
|
self.workflow = BpmnWorkflow(self.spec, self.subprocesses)
|
|
self.do_next_exclusive_step(
|
|
'Select Test', choice='Message Non Interrupt')
|
|
self.workflow.do_engine_steps()
|
|
|
|
self.assertEqual(1, len(self.workflow.get_tasks(TaskState.READY)))
|
|
self.assertEqual(2, len(self.workflow.get_tasks(TaskState.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(TaskState.WAITING)))
|
|
|
|
self.workflow.do_engine_steps()
|
|
self.assertEqual(
|
|
0, len(self.workflow.get_tasks(TaskState.READY | TaskState.WAITING)))
|
|
|
|
def testRunThroughMessageInterrupt(self):
|
|
|
|
self.workflow = BpmnWorkflow(self.spec, self.subprocesses)
|
|
self.do_next_exclusive_step(
|
|
'Select Test', choice='Message Non Interrupt')
|
|
self.workflow.do_engine_steps()
|
|
|
|
self.assertEqual(1, len(self.workflow.get_tasks(TaskState.READY)))
|
|
self.assertEqual(2, len(self.workflow.get_tasks(TaskState.WAITING)))
|
|
|
|
self.workflow.catch(MessageEventDefinition('Test Message'))
|
|
|
|
self.workflow.do_engine_steps()
|
|
self.assertEqual(1, len(self.workflow.get_tasks(TaskState.WAITING)))
|
|
self.assertEqual(2, len(self.workflow.get_tasks(TaskState.READY)))
|
|
|
|
self.do_next_named_step('Acknowledge Non-Interrupt Message')
|
|
|
|
self.workflow.do_engine_steps()
|
|
self.assertEqual(1, len(self.workflow.get_tasks(TaskState.READY)))
|
|
self.assertEqual(2, len(self.workflow.get_tasks(TaskState.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(TaskState.READY | TaskState.WAITING)))
|
|
|
|
def testRunThroughMessageInterruptOtherOrder(self):
|
|
|
|
self.workflow = BpmnWorkflow(self.spec, self.subprocesses)
|
|
self.do_next_exclusive_step(
|
|
'Select Test', choice='Message Non Interrupt')
|
|
self.workflow.do_engine_steps()
|
|
|
|
self.assertEqual(1, len(self.workflow.get_tasks(TaskState.READY)))
|
|
self.assertEqual(2, len(self.workflow.get_tasks(TaskState.WAITING)))
|
|
|
|
self.workflow.catch(MessageEventDefinition('Test Message'))
|
|
|
|
self.workflow.do_engine_steps()
|
|
self.assertEqual(1, len(self.workflow.get_tasks(TaskState.WAITING)))
|
|
self.assertEqual(2, len(self.workflow.get_tasks(TaskState.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(TaskState.READY)))
|
|
|
|
self.do_next_named_step('Acknowledge Non-Interrupt Message')
|
|
|
|
self.workflow.do_engine_steps()
|
|
self.assertEqual(
|
|
0, len(self.workflow.get_tasks(TaskState.READY | TaskState.WAITING)))
|
|
|
|
def testRunThroughMessageInterruptOtherOrderSaveAndRestore(self):
|
|
|
|
self.workflow = BpmnWorkflow(self.spec, self.subprocesses)
|
|
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(TaskState.READY)))
|
|
self.assertEqual(2, len(self.workflow.get_tasks(TaskState.WAITING)))
|
|
|
|
self.workflow.catch(MessageEventDefinition('Test Message'))
|
|
self.save_restore()
|
|
|
|
self.workflow.do_engine_steps()
|
|
self.assertEqual(1, len(self.workflow.get_tasks(TaskState.WAITING)))
|
|
self.assertEqual(2, len(self.workflow.get_tasks(TaskState.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(TaskState.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(TaskState.READY | TaskState.WAITING)))
|
|
|
|
|
|
def suite():
|
|
return unittest.TestLoader().loadTestsFromTestCase(MessageNonInterruptTest)
|
|
if __name__ == '__main__':
|
|
unittest.TextTestRunner(verbosity=2).run(suite())
|