spiff-arena/tests/SpiffWorkflow/bpmn/events/NITimerDurationBoundaryTest.py

70 lines
2.7 KiB
Python
Raw Normal View History

import datetime
import time
Squashed 'SpiffWorkflow/' changes from 01a25fc3..0adfc8cb 0adfc8cb update spiff signal event 52d65dfc Merge pull request #346 from sartography/bugfix/update-split-task-inputs 23ca808c make sure tasks with boundary events are connected properly de427431 remove pointless parser attribute and variable 3236b5b9 change subprocess start event validation error message text a5ad0672 Merge pull request #344 from sartography/bugfix/gateway-in-loop 6b22a195 allow event definitions without refs bb843873 clean up inclusive gateway a little a7d81c02 prevent parallel gateways from waiting on descendants 802352a2 move test to proper location ebcdde95 Merge pull request #343 from sartography/feature/event-payloads 87636472 add an additional test for boundary event parent removal 41423168 add escalation event test 26c5a9bb fix message event catch check 9bd018e5 Add test case for call activities in sub processes, fixed bug (#342) 546923b4 add serialization migration for boundary events 46d41e20 add spiff payload extensions + base spec improvements a0f5fc2a remove boundary event parent 56277ff1 add event class 6de6fb2b reorganize event definitions 7db65566 fix subprocess cancel 442535ae do not allow the task trace to infinitely loop to get the trace w/ burnettk dbe41c8e Merge pull request #339 from sartography/improvement/better-subworkflow-management 6c61f20a update parent attribute name ea0a7bf4 update correlations when catching external messages f511e2dd remove unneeded method from tests 953fa63c clean up workflow methods efcdcf54 Merge pull request #338 from sartography/bugfix/triggered-multiinstance-tasks 11b78ce7 prevent errors synching children of MI tasks bbb79e05 miscellaneous improvements 3f8e8d84 split bpmn workflow into two classes 61e01201 clean up workflow attributes & methods git-subtree-dir: SpiffWorkflow git-subtree-split: 0adfc8cbaec80d36f98a4136434e960f666fcfe2
2023-08-09 20:14:27 +00:00
from SpiffWorkflow.task import TaskState
from SpiffWorkflow.bpmn.workflow import BpmnWorkflow
from tests.SpiffWorkflow.bpmn.BpmnWorkflowTestCase import BpmnWorkflowTestCase
__author__ = 'kellym'
class NITimerDurationTest(BpmnWorkflowTestCase):
"""
Non-Interrupting Timer boundary test
"""
def setUp(self):
spec, subprocesses = self.load_workflow_spec('timer-non-interrupt-boundary.bpmn', 'NonInterruptTimer')
self.workflow = BpmnWorkflow(spec, subprocesses)
def load_spec(self):
return
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):
self.workflow.do_engine_steps()
ready_tasks = self.workflow.get_tasks(TaskState.READY)
event = self.workflow.get_tasks_from_spec_name('Event_0jyy8ao')[0]
self.assertEqual(event.state, TaskState.WAITING)
loopcount = 0
starttime = datetime.datetime.now()
# test bpmn has a timeout of .2s; we should terminate loop before that.
# The subprocess will also wait
Squashed 'SpiffWorkflow/' changes from 01a25fc3..0adfc8cb 0adfc8cb update spiff signal event 52d65dfc Merge pull request #346 from sartography/bugfix/update-split-task-inputs 23ca808c make sure tasks with boundary events are connected properly de427431 remove pointless parser attribute and variable 3236b5b9 change subprocess start event validation error message text a5ad0672 Merge pull request #344 from sartography/bugfix/gateway-in-loop 6b22a195 allow event definitions without refs bb843873 clean up inclusive gateway a little a7d81c02 prevent parallel gateways from waiting on descendants 802352a2 move test to proper location ebcdde95 Merge pull request #343 from sartography/feature/event-payloads 87636472 add an additional test for boundary event parent removal 41423168 add escalation event test 26c5a9bb fix message event catch check 9bd018e5 Add test case for call activities in sub processes, fixed bug (#342) 546923b4 add serialization migration for boundary events 46d41e20 add spiff payload extensions + base spec improvements a0f5fc2a remove boundary event parent 56277ff1 add event class 6de6fb2b reorganize event definitions 7db65566 fix subprocess cancel 442535ae do not allow the task trace to infinitely loop to get the trace w/ burnettk dbe41c8e Merge pull request #339 from sartography/improvement/better-subworkflow-management 6c61f20a update parent attribute name ea0a7bf4 update correlations when catching external messages f511e2dd remove unneeded method from tests 953fa63c clean up workflow methods efcdcf54 Merge pull request #338 from sartography/bugfix/triggered-multiinstance-tasks 11b78ce7 prevent errors synching children of MI tasks bbb79e05 miscellaneous improvements 3f8e8d84 split bpmn workflow into two classes 61e01201 clean up workflow attributes & methods git-subtree-dir: SpiffWorkflow git-subtree-split: 0adfc8cbaec80d36f98a4136434e960f666fcfe2
2023-08-09 20:14:27 +00:00
while event.state == TaskState.WAITING and loopcount < 10:
if save_restore:
self.save_restore()
Squashed 'SpiffWorkflow/' changes from 01a25fc3..0adfc8cb 0adfc8cb update spiff signal event 52d65dfc Merge pull request #346 from sartography/bugfix/update-split-task-inputs 23ca808c make sure tasks with boundary events are connected properly de427431 remove pointless parser attribute and variable 3236b5b9 change subprocess start event validation error message text a5ad0672 Merge pull request #344 from sartography/bugfix/gateway-in-loop 6b22a195 allow event definitions without refs bb843873 clean up inclusive gateway a little a7d81c02 prevent parallel gateways from waiting on descendants 802352a2 move test to proper location ebcdde95 Merge pull request #343 from sartography/feature/event-payloads 87636472 add an additional test for boundary event parent removal 41423168 add escalation event test 26c5a9bb fix message event catch check 9bd018e5 Add test case for call activities in sub processes, fixed bug (#342) 546923b4 add serialization migration for boundary events 46d41e20 add spiff payload extensions + base spec improvements a0f5fc2a remove boundary event parent 56277ff1 add event class 6de6fb2b reorganize event definitions 7db65566 fix subprocess cancel 442535ae do not allow the task trace to infinitely loop to get the trace w/ burnettk dbe41c8e Merge pull request #339 from sartography/improvement/better-subworkflow-management 6c61f20a update parent attribute name ea0a7bf4 update correlations when catching external messages f511e2dd remove unneeded method from tests 953fa63c clean up workflow methods efcdcf54 Merge pull request #338 from sartography/bugfix/triggered-multiinstance-tasks 11b78ce7 prevent errors synching children of MI tasks bbb79e05 miscellaneous improvements 3f8e8d84 split bpmn workflow into two classes 61e01201 clean up workflow attributes & methods git-subtree-dir: SpiffWorkflow git-subtree-split: 0adfc8cbaec80d36f98a4136434e960f666fcfe2
2023-08-09 20:14:27 +00:00
event = self.workflow.get_tasks_from_spec_name('Event_0jyy8ao')[0]
time.sleep(0.1)
ready_tasks = self.workflow.get_tasks(TaskState.READY)
# There should be one ready task until the boundary event fires
self.assertEqual(len(self.workflow.get_ready_user_tasks()), 1)
self.workflow.refresh_waiting_tasks()
self.workflow.do_engine_steps()
loopcount += 1
endtime = datetime.datetime.now()
duration = endtime - starttime
# appropriate time here is .5 seconds due to the .3 seconds that we loop and then
self.assertEqual(duration < datetime.timedelta(seconds=.5), True)
self.assertEqual(duration > datetime.timedelta(seconds=.2), True)
ready_tasks = self.workflow.get_ready_user_tasks()
# Now there should be two.
self.assertEqual(len(ready_tasks), 2)
for task in ready_tasks:
if task.task_spec.name == 'GetReason':
task.data['delay_reason'] = 'Just Because'
elif task.task_spec.name == 'Activity_Work':
task.data['work_done'] = 'Yes'
Squashed 'SpiffWorkflow/' changes from bee868d38..96ad2a2b0 96ad2a2b0 Merge pull request #311 from sartography/feature/error-message-on-bad-child-task 3fb69038d Merge remote-tracking branch 'origin/main' into feature/error-message-on-bad-child-task df703ebb8 Merge remote-tracking branch 'origin/feature/add_task_not_found_error' d6e244bcf also raise TaskNotFoundException from bpmn workflow w/ burnettk 37d7ae679 Merge pull request #310 from sartography/feature/add_task_not_found_error 7f4d38ce2 give us a better error if for some reason a task does not exist b98efbd20 added an exception for task not found w/ burnettk e1add839d Merge pull request #308 from sartography/bugfix/execute-event-gateways-on-ready 964c0231a do not predict tasks when deserializing, add method to predict all unfinished tasks 114f87aa9 update event gateway 62454c99c Merge pull request #307 from sartography/feature/standardize-task-execution a087d29ea update task_spec._run to return a boolean & misc cleanup 9864d753d reenable recursion test 1bb1246a0 rename methods & move ready_before tasks from run to ready 12ce08519 move event task execution to run d51bb68eb cleanup predictions 5e05458a3 make all tasks execute when run rather than completed (except bpmn events) 273d7b325 create a run method for tasks 3c3345c85 Merge pull request #306 from sartography/feature/create-core-test-package ed85547d7 hopefully fix CI job, also update some deprecated assertions 80d68c231 cleanup around finding tasks ea5ffff41 create tests based on individual patterns afe41fba1 move core tests into one package c075d52bc remove locks from task spec -- they don't do anything d78c7cc04 reorganize so that related methods are near each other f162aac43 Merge pull request #305 from sartography/feature/remove-loop-reset 6cad29817 'fix' old serializer to remove loop resets -- or at least get the tests to pass a95d2fc12 add serialization migration that removes loop resets c076175c8 account for DST in timers 42b483054 Merge pull request #303 from sartography/bugfix/execute-tasks-on-ready 2bb08aae1 update script/service tasks to execute on ready 0bd23a0ab fix scripts in business rule tasks 13034aaf1 prevent loop reset tasks from being inserted 3fb80518d update join execution model git-subtree-dir: SpiffWorkflow git-subtree-split: 96ad2a2b060deb445c39374f065690023351de19
2023-04-07 15:46:14 +00:00
task.run()
self.workflow.refresh_waiting_tasks()
self.workflow.do_engine_steps()
self.workflow.do_engine_steps()
self.assertEqual(self.workflow.is_completed(), True)
self.assertEqual(self.workflow.last_task.data, {'work_done': 'Yes', 'delay_reason': 'Just Because'})