spiff-arena/tests/SpiffWorkflow/camunda/ResetTokenMIParallelTest.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

81 lines
3.0 KiB
Python

# -*- coding: utf-8 -*-
import unittest
from tests.SpiffWorkflow.camunda.BaseTestCase import BaseTestCase
from SpiffWorkflow.bpmn.workflow import BpmnWorkflow
__author__ = 'kellym'
class ResetTokenTestMIParallel(BaseTestCase):
"""The example bpmn diagram tests both a set cardinality from user input
as well as looping over an existing array."""
def setUp(self):
spec, subprocesses = self.load_workflow_spec('token_trial_MIParallel.bpmn', 'token')
self.workflow = BpmnWorkflow(spec, subprocesses)
def testRunThroughHappy(self):
self.actual_test(save_restore=False)
def testRunThroughSaveRestore(self):
self.actual_test(save_restore=True)
def actual_test(self, save_restore=False,reset_data=False):
self.workflow.do_engine_steps()
firsttaskid = None
steps = [{'taskname':'First',
'task_data': {'do_step':'Yes'}},
{'taskname': 'FormA',
'task_data': {'current': {'A' : 'x'}}},
{'taskname': 'FormA',
'task_data': {'current': {'A' : 'y'}}},
{'taskname': 'FormA',
'task_data': {'current': {'A' : 'z'}}}
]
for step in steps:
task = self.workflow.get_ready_user_tasks()[0]
if firsttaskid == None and step['taskname']=='FormA':
firsttaskid = task.id
self.assertEqual(step['taskname'], task.task_spec.name[:len(step['taskname'])])
task.update_data(step['task_data'])
self.workflow.complete_task_from_id(task.id)
self.workflow.do_engine_steps()
if save_restore: self.save_restore()
self.assertEqual({'do_step': 'Yes',
'output': {'1': {'A': 'x'}, '2': {'A': 'y'}, '3': {'A': 'z'}}},
self.workflow.last_task.data)
self.workflow.reset_task_from_id(firsttaskid)
#NB - this won't test random access
steps = [{'taskname': 'FormA',
'task_data': {'current': {'A' : 'a1'}}},
{'taskname': 'FormC',
'task_data': {'C' : 'c'}},
]
for step in steps:
task = self.workflow.get_ready_user_tasks()[0]
self.assertEqual(step['taskname'], task.task_spec.name)
task.update_data(step['task_data'])
self.workflow.complete_task_from_id(task.id)
self.workflow.do_engine_steps()
if save_restore: self.save_restore()
self.assertTrue(self.workflow.is_completed())
self.assertEqual({'do_step': 'Yes',
'C': 'c',
'output': {'1': {'A': 'a1'},
'2': {'A': 'y'},
'3': {'A': 'z'}}},
self.workflow.last_task.data)
def suite():
return unittest.TestLoader().loadTestsFromTestCase(ResetTokenTestMIParallel)
if __name__ == '__main__':
unittest.TextTestRunner(verbosity=2).run(suite())