mirror of
https://github.com/status-im/spiff-arena.git
synced 2025-01-17 21:51:43 +00:00
0892db6fa7
git-subtree-dir: SpiffWorkflow git-subtree-split: 63db3e45947ec66b8d0efc2c74064004f8ff482c
58 lines
2.3 KiB
Python
58 lines
2.3 KiB
Python
import unittest
|
|
|
|
from SpiffWorkflow.task import TaskState
|
|
from SpiffWorkflow.bpmn.workflow import BpmnWorkflow
|
|
from .BaseTestCase import BaseTestCase
|
|
|
|
__author__ = 'essweine'
|
|
|
|
|
|
class CallActivityMessageTest(BaseTestCase):
|
|
|
|
def setUp(self):
|
|
self.spec, self.subprocesses = self.load_workflow_spec('call_activity_with_message*.bpmn', 'Process_0xeaemr')
|
|
self.workflow = BpmnWorkflow(self.spec, self.subprocesses)
|
|
|
|
def testRunThroughHappy(self):
|
|
self.actual_test(save_restore=False)
|
|
|
|
def testThroughSaveRestore(self):
|
|
self.actual_test(save_restore=True)
|
|
|
|
def actual_test(self, save_restore=False):
|
|
steps = [('Activity_EnterPlan',{'plan_details':'Bad'}),
|
|
('Activity_ApproveOrDeny', {'approved':'No'}),
|
|
('Activity_EnterPlan', {'plan_details':'Better'}),
|
|
('Activity_ApproveOrDeny', {'approved':'No'}),
|
|
('Activity_EnterPlan', {'plan_details':'Best'}),
|
|
('Activity_ApproveOrDeny', {'approved':'Yes'}),
|
|
('Activity_EnablePlan',{'Done':'OK!'})
|
|
]
|
|
|
|
self.workflow.do_engine_steps()
|
|
ready_tasks = self.workflow.get_tasks(TaskState.READY)
|
|
waiting_tasks = self.workflow.get_tasks(TaskState.WAITING)
|
|
self.assertEqual(1, len(ready_tasks),'Expected to have one ready task')
|
|
self.assertEqual(2, len(waiting_tasks), 'Expected to have two waiting tasks')
|
|
|
|
for step in steps:
|
|
current_task = ready_tasks[0]
|
|
self.assertEqual(current_task.task_spec.name,step[0])
|
|
current_task.update_data(step[1])
|
|
current_task.complete()
|
|
self.workflow.do_engine_steps()
|
|
self.workflow.refresh_waiting_tasks()
|
|
if save_restore: self.save_restore()
|
|
ready_tasks = self.workflow.get_tasks(TaskState.READY)
|
|
self.assertEqual(self.workflow.is_completed(),True,'Expected the workflow to be complete at this point')
|
|
self.assertEqual(self.workflow.last_task.data,{'plan_details': 'Best',
|
|
'Approved': 'Yes',
|
|
'Done': 'OK!'})
|
|
|
|
|
|
|
|
def suite():
|
|
return unittest.TestLoader().loadTestsFromTestCase(CallActivityMessageTest)
|
|
if __name__ == '__main__':
|
|
unittest.TextTestRunner(verbosity=2).run(suite())
|