spiff-arena/tests/SpiffWorkflow/camunda/StartMessageEventTest.py
burnettk 1bed0fb3ee Squashed 'SpiffWorkflow/' changes from 580939cc..cd4da465
cd4da465 Merge pull request #264 from sartography/bugfix/dmn-equality-with-boolean
414a59eb disambiguate DMN expressions
eea53c91 Merge pull request #263 from sartography/feature/cleanup-task-completion
d248d5b1 execute postscript before other complete hook tasks
c09f1a90 streamline predict & remove some duplicated calls to it
64c21791 remove duplicate calls to update
4ca1076d move task update to _on_complete to ensure data is copied consistently after task related activities are done
d037a7eb small changes for readability
025bc30f Quick patch -- is_executable needs to be accurate immediately.
14d3d8c3 Merge pull request #262 from sartography/feature/parser_info_features
849c223e We are jumping through a lot of complex xml parsing in SpiffWorkflow-Backend because we need to know some basic information about a BPMN process at the moment it is saved.  Rather than do that work in the backend, it seems better to have SpiffWorkflow handle parsing the xml and providing a bit of metadata, including:

git-subtree-dir: SpiffWorkflow
git-subtree-split: cd4da465e125ca1ae1b57d227bfa324d9d4c507c
2022-11-18 10:03:32 -05:00

71 lines
2.7 KiB
Python

# -*- coding: utf-8 -*-
import unittest
from SpiffWorkflow.task import TaskState
from SpiffWorkflow.bpmn.workflow import BpmnWorkflow
from .BaseTestCase import BaseTestCase
__author__ = 'kellym'
class StartMessageTest(BaseTestCase):
def setUp(self):
self.spec, self.subprocesses = self.load_workflow_spec('message_test.bpmn', 'ThrowCatch')
self.workflow = BpmnWorkflow(self.spec, self.subprocesses)
def testParserCanReturnStartMessages(self):
parser = self.get_parser('message_test.bpmn')
self.assertEqual(
parser.process_parsers['ThrowCatch'].start_messages(), ['Message_1rkbi27'])
parser = self.get_parser('random_fact.bpmn')
self.assertEqual(
parser.process_parsers['random_fact'].start_messages(), [])
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() # get around start task
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(1, len(waiting_tasks), 'Expected to have one waiting task')
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',
'ApprovalResult': 'Yes',
'Done': 'OK!'
})
def suite():
return unittest.TestLoader().loadTestsFromTestCase(StartMessageTest)
if __name__ == '__main__':
unittest.TextTestRunner(verbosity=2).run(suite())