From f1b8cfcc07ed69ffbe02abb07b84bb1997625814 Mon Sep 17 00:00:00 2001 From: burnettk Date: Fri, 7 Apr 2023 11:46:14 -0400 Subject: [PATCH] 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 --- doc/non-bpmn/tutorial/start.py | 2 +- setup.py | 5 +- tests/SpiffWorkflow/PatternTest.py | 103 --- tests/SpiffWorkflow/bpmn/ApprovalsTest.py | 2 +- .../bpmn/BaseParallelTestCase.py | 9 +- .../SpiffWorkflow/bpmn/BpmnLoaderForTests.py | 2 +- .../bpmn/BpmnWorkflowTestCase.py | 4 +- .../bpmn/CallActivityEndEventTest.py | 2 +- tests/SpiffWorkflow/bpmn/CollaborationTest.py | 12 +- .../bpmn/DataObjectReferenceTest.py | 14 +- tests/SpiffWorkflow/bpmn/IOSpecTest.py | 8 +- .../bpmn/InclusiveGatewayTest.py | 2 +- .../bpmn/ParallelMultiInstanceTest.py | 4 +- tests/SpiffWorkflow/bpmn/ParallelOrderTest.py | 2 +- .../bpmn/ParallelThroughSameTaskTest.py | 4 +- .../SpiffWorkflow/bpmn/ResetSubProcessTest.py | 14 +- tests/SpiffWorkflow/bpmn/ResetTimerTest.py | 28 - .../bpmn/SequentialMultiInstanceTest.py | 4 +- tests/SpiffWorkflow/bpmn/StandardLoopTest.py | 4 +- tests/SpiffWorkflow/bpmn/SwimLaneTest.py | 8 +- tests/SpiffWorkflow/bpmn/TooManyLoopsTest.py | 86 --- .../Parallel-Looping-After-Join.bpmn20.xml | 590 ++++++++--------- .../SpiffWorkflow/bpmn/data/reset_timer.bpmn | 104 --- .../data/serialization/v1.1-loop-reset.json | 600 ++++++++++++++++++ .../SpiffWorkflow/bpmn/data/sub_in_loop.bpmn | 88 --- .../bpmn/data/sub_in_loop_call_activity.bpmn | 38 -- .../bpmn/data/too_many_loops.bpmn | 125 ---- .../data/too_many_loops_call_activity.bpmn | 48 -- .../bpmn/data/too_many_loops_sub_process.bpmn | 157 ----- .../bpmn/events/CallActivityEscalationTest.py | 6 +- .../bpmn/events/EventBasedGatewayTest.py | 4 +- .../bpmn/events/MultipleEventsTest.py | 6 +- .../bpmn/events/MultipleThrowEventTest.py | 2 +- .../NITimerDurationBoundaryTest.py | 2 +- .../bpmn/events/TimerCycleTest.py | 6 +- .../events/TimerDurationBoundaryOnTaskTest.py | 2 +- .../bpmn/events/TimerDurationBoundaryTest.py | 4 +- .../bpmn/events/TransactionSubprocssTest.py | 14 +- .../serializer/BpmnWorkflowSerializerTest.py | 4 +- .../bpmn/serializer/VersionMigrationTest.py | 20 +- .../camunda/CallActivityMessageTest.py | 2 +- .../SpiffWorkflow/camunda/ClashingNameTest.py | 4 +- .../camunda/DMNCustomScriptTest.py | 2 +- tests/SpiffWorkflow/camunda/DMNDictTest.py | 4 +- .../ExternalMessageBoundaryEventTest.py | 4 +- .../InvalidBusinessRuleTaskParserTest.py | 2 +- .../camunda/MessageBoundaryEventTest.py | 2 +- .../camunda/MultiInstanceDMNTest.py | 4 +- .../camunda/NIMessageBoundaryTest.py | 10 +- .../camunda/ParseMultiInstanceTest.py | 6 +- .../camunda/ResetTokenNestedParallelTest.py | 8 +- .../camunda/ResetTokenParallelMatrixTest.py | 8 +- .../ResetTokenParallelTaskCountTest.py | 7 +- .../camunda/ResetTokenSubWorkflowTest.py | 8 +- tests/SpiffWorkflow/camunda/ResetTokenTest.py | 4 +- .../camunda/StartMessageEventTest.py | 2 +- .../SpiffWorkflow/camunda/SubWorkflowTest.py | 2 +- .../camunda/UserTaskParserTest.py | 20 +- .../camunda/specs/UserTaskSpecTest.py | 3 +- .../core/ControlFlowPatternTest.py | 185 ++++++ tests/SpiffWorkflow/core/DataPatternTest.py | 24 + .../{ => core}/ExecuteProcessMock.py | 0 .../{ => core}/PersistSmallWorkflowTest.py | 14 +- tests/SpiffWorkflow/{ => core}/TaskTest.py | 2 +- .../SpiffWorkflow/{ => core}/WorkflowTest.py | 16 +- .../SpiffWorkflow/{data => core}/__init__.py | 0 .../{data/spiff => core/data}/__init__.py | 0 .../acyclic_synchronizing_merge.path | 0 .../acyclic_synchronizing_merge.xml | 0 .../data/control-flow/arbitrary_cycles.path | 9 + .../data}/control-flow/arbitrary_cycles.xml | 0 .../control-flow/blocking_discriminator.path | 15 + .../control-flow/blocking_discriminator.xml | 0 .../control-flow/blocking_partial_join.path | 15 + .../control-flow/blocking_partial_join.xml | 0 .../data}/control-flow/cancel_case.path | 0 .../data}/control-flow/cancel_case.xml | 0 .../cancel_multi_instance_task.path | 0 .../cancel_multi_instance_task.xml | 0 .../data}/control-flow/cancel_region.path | 0 .../data}/control-flow/cancel_region.xml | 0 .../data}/control-flow/cancel_task.path | 0 .../data}/control-flow/cancel_task.xml | 0 .../cancelling_discriminator.path | 11 + .../control-flow/cancelling_discriminator.xml | 0 .../control-flow/cancelling_partial_join.path | 13 + .../control-flow/cancelling_partial_join.xml | 0 ...lling_partial_join_for_multi_instance.path | 0 ...elling_partial_join_for_multi_instance.xml | 0 .../complete_multiple_instance_activity.path | 0 .../complete_multiple_instance_activity.xml | 0 .../data}/control-flow/critical_section.path | 0 .../data}/control-flow/critical_section.xml | 4 - .../data}/control-flow/deferred_choice.path | 0 .../data}/control-flow/deferred_choice.xml | 0 ...namic_partial_join_for_multi_instance.path | 0 ...ynamic_partial_join_for_multi_instance.xml | 0 .../data}/control-flow/exclusive_choice.path | 0 .../data}/control-flow/exclusive_choice.xml | 0 .../control-flow/explicit_termination.path | 0 .../control-flow/explicit_termination.xml | 0 .../general_synchronizing_merge.path | 19 + .../general_synchronizing_merge.xml | 0 .../control-flow/generalized_and_join.path | 21 + .../control-flow/generalized_and_join.xml | 0 .../control-flow/implicit_termination.path | 0 .../control-flow/implicit_termination.xml | 0 .../interleaved_parallel_routing.path | 0 .../interleaved_parallel_routing.xml | 3 - .../control-flow/interleaved_routing.path | 0 .../control-flow/interleaved_routing.xml | 6 - .../data}/control-flow/milestone.path | 0 .../data}/control-flow/milestone.xml | 0 .../data}/control-flow/multi_choice.path | 0 .../data}/control-flow/multi_choice.xml | 0 ...e_with_a_priori_design_time_knowledge.path | 0 ...ce_with_a_priori_design_time_knowledge.xml | 0 ...ance_with_a_priori_run_time_knowledge.path | 0 ...tance_with_a_priori_run_time_knowledge.xml | 0 .../multi_instance_without_a_priori.path | 0 .../multi_instance_without_a_priori.xml | 0 .../multi_instance_without_synch.path | 0 .../multi_instance_without_synch.xml | 0 .../data}/control-flow/multi_merge.path | 0 .../data}/control-flow/multi_merge.xml | 0 .../data}/control-flow/parallel_split.path | 0 .../data}/control-flow/parallel_split.xml | 0 .../control-flow/persistent_trigger.path | 0 .../data}/control-flow/persistent_trigger.xml | 0 .../data}/control-flow/recursion.path | 0 .../data}/control-flow/recursion.xml | 0 .../data}/control-flow/sequence.path | 0 .../data}/control-flow/sequence.xml | 0 .../data}/control-flow/simple_merge.path | 0 .../data}/control-flow/simple_merge.xml | 0 ...tatic_partial_join_for_multi_instance.path | 0 ...static_partial_join_for_multi_instance.xml | 0 .../structured_discriminator.path | 0 .../control-flow/structured_discriminator.xml | 0 .../control-flow/structured_partial_join.path | 0 .../control-flow/structured_partial_join.xml | 0 .../structured_synchronizing_merge.path | 0 .../structured_synchronizing_merge.xml | 0 .../control-flow/subworkflow_to_join.path | 0 .../control-flow/subworkflow_to_join.xml | 0 .../subworkflow_to_join_inner.xml | 0 .../data}/control-flow/synchronization.path | 0 .../data}/control-flow/synchronization.xml | 0 .../data}/control-flow/thread_merge.path | 0 .../data}/control-flow/thread_merge.xml | 0 .../data}/control-flow/thread_split.path | 0 .../data}/control-flow/thread_split.xml | 0 .../data}/control-flow/transient_trigger.path | 0 .../data}/control-flow/transient_trigger.xml | 0 .../spiff => core/data}/data/block_data.xml | 0 .../data}/data/block_data.xml.data | 0 .../data}/data/block_data_inner.xml | 0 .../data}/data/block_to_subworkflow.xml | 0 .../data}/data/block_to_subworkflow.xml.data | 0 .../data}/data/block_to_subworkflow_inner.xml | 0 .../data}/data/subworkflow_to_block.xml | 0 .../data}/data/subworkflow_to_block.xml.data | 0 .../data}/data/subworkflow_to_block_inner.xml | 0 .../spiff => core/data}/data/task_data.xml | 0 .../data}/data/task_data.xml.data | 0 .../spiff => core/data}/data/task_to_task.xml | 0 .../data}/data/task_to_task.xml.data | 0 .../spiff => core/data}/resource/.gitignore | 0 tests/SpiffWorkflow/core/data/workflow1.path | 42 ++ .../{data/spiff => core/data}/workflow1.py | 0 .../{data/spiff => core/data}/workflow1.xml | 0 tests/SpiffWorkflow/{ => core}/docTest.py | 4 +- tests/SpiffWorkflow/core/pattern_base.py | 123 ++++ .../{ => core}/specs/CeleryTest.py | 17 +- .../{ => core}/specs/DeepMergeTest.py | 0 .../{ => core}/specs/ExecuteTest.py | 7 +- .../{ => core}/specs/JoinTest.py | 7 +- .../{ => core}/specs/MergeTest.py | 7 +- .../{ => core}/specs/SubWorkflowTest.py | 13 +- .../{ => core}/specs/TaskSpecTest.py | 5 - .../{ => core}/specs/TransformTest.py | 8 +- .../{ => core}/specs/WorkflowSpecTest.py | 31 +- .../{serializer => core/specs}/__init__.py | 0 tests/SpiffWorkflow/{ => core}/util.py | 34 +- tests/SpiffWorkflow/data/empty1.xml | 0 tests/SpiffWorkflow/data/empty2.xml | 1 - .../spiff/control-flow/arbitrary_cycles.path | 10 - .../control-flow/blocking_discriminator.path | 14 - .../control-flow/blocking_partial_join.path | 15 - .../cancelling_discriminator.path | 12 - .../control-flow/cancelling_partial_join.path | 13 - .../general_synchronizing_merge.path | 21 - .../control-flow/generalized_and_join.path | 22 - tests/SpiffWorkflow/data/spiff/workflow1.path | 41 -- .../InvalidBusinessRuleNameErrorTest.py | 2 +- tests/SpiffWorkflow/serializer/baseTest.py | 88 --- tests/SpiffWorkflow/serializer/dictTest.py | 73 --- tests/SpiffWorkflow/serializer/jsonTest.py | 38 -- .../SpiffWorkflow/serializer/prettyxmlTest.py | 30 - tests/SpiffWorkflow/serializer/xmlTest.py | 29 - tests/SpiffWorkflow/specs/__init__.py | 0 tests/SpiffWorkflow/spiff/BaseTestCase.py | 3 - .../spiff/BusinessRuleTaskTest.py | 2 +- tests/SpiffWorkflow/spiff/CorrelationTest.py | 4 +- .../spiff/MultiInstanceTaskTest.py | 2 +- .../spiff/PrescriptPostscriptTest.py | 4 +- 206 files changed, 1585 insertions(+), 1735 deletions(-) delete mode 100644 tests/SpiffWorkflow/PatternTest.py delete mode 100644 tests/SpiffWorkflow/bpmn/ResetTimerTest.py delete mode 100644 tests/SpiffWorkflow/bpmn/TooManyLoopsTest.py delete mode 100644 tests/SpiffWorkflow/bpmn/data/reset_timer.bpmn create mode 100644 tests/SpiffWorkflow/bpmn/data/serialization/v1.1-loop-reset.json delete mode 100644 tests/SpiffWorkflow/bpmn/data/sub_in_loop.bpmn delete mode 100644 tests/SpiffWorkflow/bpmn/data/sub_in_loop_call_activity.bpmn delete mode 100644 tests/SpiffWorkflow/bpmn/data/too_many_loops.bpmn delete mode 100644 tests/SpiffWorkflow/bpmn/data/too_many_loops_call_activity.bpmn delete mode 100644 tests/SpiffWorkflow/bpmn/data/too_many_loops_sub_process.bpmn rename tests/SpiffWorkflow/bpmn/{ => events}/NITimerDurationBoundaryTest.py (99%) create mode 100644 tests/SpiffWorkflow/core/ControlFlowPatternTest.py create mode 100644 tests/SpiffWorkflow/core/DataPatternTest.py rename tests/SpiffWorkflow/{ => core}/ExecuteProcessMock.py (100%) rename tests/SpiffWorkflow/{ => core}/PersistSmallWorkflowTest.py (92%) rename tests/SpiffWorkflow/{ => core}/TaskTest.py (97%) rename tests/SpiffWorkflow/{ => core}/WorkflowTest.py (86%) rename tests/SpiffWorkflow/{data => core}/__init__.py (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/__init__.py (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/acyclic_synchronizing_merge.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/acyclic_synchronizing_merge.xml (100%) create mode 100644 tests/SpiffWorkflow/core/data/control-flow/arbitrary_cycles.path rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/arbitrary_cycles.xml (100%) create mode 100644 tests/SpiffWorkflow/core/data/control-flow/blocking_discriminator.path rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/blocking_discriminator.xml (100%) create mode 100644 tests/SpiffWorkflow/core/data/control-flow/blocking_partial_join.path rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/blocking_partial_join.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/cancel_case.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/cancel_case.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/cancel_multi_instance_task.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/cancel_multi_instance_task.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/cancel_region.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/cancel_region.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/cancel_task.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/cancel_task.xml (100%) create mode 100644 tests/SpiffWorkflow/core/data/control-flow/cancelling_discriminator.path rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/cancelling_discriminator.xml (100%) create mode 100644 tests/SpiffWorkflow/core/data/control-flow/cancelling_partial_join.path rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/cancelling_partial_join.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/cancelling_partial_join_for_multi_instance.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/cancelling_partial_join_for_multi_instance.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/complete_multiple_instance_activity.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/complete_multiple_instance_activity.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/critical_section.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/critical_section.xml (91%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/deferred_choice.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/deferred_choice.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/dynamic_partial_join_for_multi_instance.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/dynamic_partial_join_for_multi_instance.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/exclusive_choice.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/exclusive_choice.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/explicit_termination.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/explicit_termination.xml (100%) create mode 100644 tests/SpiffWorkflow/core/data/control-flow/general_synchronizing_merge.path rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/general_synchronizing_merge.xml (100%) create mode 100644 tests/SpiffWorkflow/core/data/control-flow/generalized_and_join.path rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/generalized_and_join.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/implicit_termination.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/implicit_termination.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/interleaved_parallel_routing.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/interleaved_parallel_routing.xml (87%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/interleaved_routing.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/interleaved_routing.xml (81%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/milestone.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/milestone.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/multi_choice.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/multi_choice.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/multi_instance_with_a_priori_design_time_knowledge.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/multi_instance_with_a_priori_design_time_knowledge.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/multi_instance_with_a_priori_run_time_knowledge.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/multi_instance_with_a_priori_run_time_knowledge.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/multi_instance_without_a_priori.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/multi_instance_without_a_priori.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/multi_instance_without_synch.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/multi_instance_without_synch.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/multi_merge.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/multi_merge.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/parallel_split.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/parallel_split.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/persistent_trigger.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/persistent_trigger.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/recursion.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/recursion.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/sequence.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/sequence.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/simple_merge.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/simple_merge.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/static_partial_join_for_multi_instance.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/static_partial_join_for_multi_instance.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/structured_discriminator.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/structured_discriminator.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/structured_partial_join.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/structured_partial_join.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/structured_synchronizing_merge.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/structured_synchronizing_merge.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/subworkflow_to_join.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/subworkflow_to_join.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/subworkflow_to_join_inner.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/synchronization.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/synchronization.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/thread_merge.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/thread_merge.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/thread_split.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/thread_split.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/transient_trigger.path (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/control-flow/transient_trigger.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/data/block_data.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/data/block_data.xml.data (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/data/block_data_inner.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/data/block_to_subworkflow.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/data/block_to_subworkflow.xml.data (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/data/block_to_subworkflow_inner.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/data/subworkflow_to_block.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/data/subworkflow_to_block.xml.data (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/data/subworkflow_to_block_inner.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/data/task_data.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/data/task_data.xml.data (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/data/task_to_task.xml (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/data/task_to_task.xml.data (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/resource/.gitignore (100%) create mode 100644 tests/SpiffWorkflow/core/data/workflow1.path rename tests/SpiffWorkflow/{data/spiff => core/data}/workflow1.py (100%) rename tests/SpiffWorkflow/{data/spiff => core/data}/workflow1.xml (100%) rename tests/SpiffWorkflow/{ => core}/docTest.py (90%) create mode 100644 tests/SpiffWorkflow/core/pattern_base.py rename tests/SpiffWorkflow/{ => core}/specs/CeleryTest.py (90%) rename tests/SpiffWorkflow/{ => core}/specs/DeepMergeTest.py (100%) rename tests/SpiffWorkflow/{ => core}/specs/ExecuteTest.py (96%) rename tests/SpiffWorkflow/{ => core}/specs/JoinTest.py (85%) rename tests/SpiffWorkflow/{ => core}/specs/MergeTest.py (96%) rename tests/SpiffWorkflow/{ => core}/specs/SubWorkflowTest.py (93%) rename tests/SpiffWorkflow/{ => core}/specs/TaskSpecTest.py (96%) rename tests/SpiffWorkflow/{ => core}/specs/TransformTest.py (91%) rename tests/SpiffWorkflow/{ => core}/specs/WorkflowSpecTest.py (83%) rename tests/SpiffWorkflow/{serializer => core/specs}/__init__.py (100%) rename tests/SpiffWorkflow/{ => core}/util.py (83%) delete mode 100644 tests/SpiffWorkflow/data/empty1.xml delete mode 100644 tests/SpiffWorkflow/data/empty2.xml delete mode 100644 tests/SpiffWorkflow/data/spiff/control-flow/arbitrary_cycles.path delete mode 100644 tests/SpiffWorkflow/data/spiff/control-flow/blocking_discriminator.path delete mode 100644 tests/SpiffWorkflow/data/spiff/control-flow/blocking_partial_join.path delete mode 100644 tests/SpiffWorkflow/data/spiff/control-flow/cancelling_discriminator.path delete mode 100644 tests/SpiffWorkflow/data/spiff/control-flow/cancelling_partial_join.path delete mode 100644 tests/SpiffWorkflow/data/spiff/control-flow/general_synchronizing_merge.path delete mode 100644 tests/SpiffWorkflow/data/spiff/control-flow/generalized_and_join.path delete mode 100644 tests/SpiffWorkflow/data/spiff/workflow1.path delete mode 100644 tests/SpiffWorkflow/serializer/baseTest.py delete mode 100644 tests/SpiffWorkflow/serializer/dictTest.py delete mode 100644 tests/SpiffWorkflow/serializer/jsonTest.py delete mode 100644 tests/SpiffWorkflow/serializer/prettyxmlTest.py delete mode 100644 tests/SpiffWorkflow/serializer/xmlTest.py delete mode 100644 tests/SpiffWorkflow/specs/__init__.py diff --git a/doc/non-bpmn/tutorial/start.py b/doc/non-bpmn/tutorial/start.py index 4090384cc..93d6aec55 100644 --- a/doc/non-bpmn/tutorial/start.py +++ b/doc/non-bpmn/tutorial/start.py @@ -19,7 +19,7 @@ workflow = Workflow(spec) # Execute until all tasks are done or require manual intervention. # For the sake of this tutorial, we ignore the "manual" flag on the # tasks. In practice, you probably don't want to do that. -workflow.complete_all(halt_on_manual=False) +workflow.run_all(halt_on_manual=False) # Alternatively, this is what a UI would do for a manual task. #workflow.complete_task_from_id(...) diff --git a/setup.py b/setup.py index ad4c2163a..3429710d2 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,10 @@ setup(name='SpiffWorkflow', author_email='dan@sartography.com', license='lGPLv2', packages=find_packages(exclude=['tests', 'tests.*']), - package_data={'SpiffWorkflow.bpmn.parser.schema': ['*.xsd']}, + package_data={ + 'SpiffWorkflow.bpmn.parser': ['schema/*.xsd'], + 'SpiffWorkflow.dmn.parser': ['schema/*.xsd'], + }, install_requires=['configparser', 'lxml', 'celery', # required for python 3.7 - https://stackoverflow.com/a/73932581 'importlib-metadata<5.0; python_version <= "3.7"'], diff --git a/tests/SpiffWorkflow/PatternTest.py b/tests/SpiffWorkflow/PatternTest.py deleted file mode 100644 index 85a90d271..000000000 --- a/tests/SpiffWorkflow/PatternTest.py +++ /dev/null @@ -1,103 +0,0 @@ -# -*- coding: utf-8 -*- - -from builtins import object -import sys -import unittest -import os -sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..')) - -from lxml import etree - -from SpiffWorkflow.specs.WorkflowSpec import WorkflowSpec -from SpiffWorkflow.task import Task -from SpiffWorkflow.serializer.prettyxml import XmlSerializer -from tests.SpiffWorkflow.util import run_workflow - - -class WorkflowTestData(object): - - def __init__(self, filename, spec, path, data): - self.filename = filename - self.spec = spec - self.path = path - self.data = data - - -class PatternTest(unittest.TestCase): - maxDiff = None - - def setUp(self): - Task.id_pool = 0 - Task.thread_id_pool = 0 - self.xml_path = ['data/spiff/control-flow', - 'data/spiff/data', - 'data/spiff/resource', - 'data/spiff'] - self.workflows = [] - - for basedir in self.xml_path: - dirname = os.path.join(os.path.dirname(__file__), basedir) - - for filename in os.listdir(dirname): - if not filename.endswith(('.xml', '.py')): - continue - if filename.endswith('__.py'): - continue - filename = os.path.join(dirname, filename) - self.load_workflow_spec(filename) - - def load_workflow_spec(self, filename): - # Load the .path file. - path_file = os.path.splitext(filename)[0] + '.path' - if os.path.exists(path_file): - with open(path_file) as fp: - expected_path = fp.read() - else: - expected_path = None - - # Load the .data file. - data_file = os.path.splitext(filename)[0] + '.data' - if os.path.exists(data_file): - with open(data_file) as fp: - expected_data = fp.read() - else: - expected_data = None - - # Test patterns that are defined in XML format. - if filename.endswith('.xml'): - with open(filename) as fp: - xml = etree.parse(fp).getroot() - serializer = XmlSerializer() - wf_spec = WorkflowSpec.deserialize( - serializer, xml, filename=filename) - - # Test patterns that are defined in Python. - elif filename.endswith('.py'): - with open(filename) as fp: - code = compile(fp.read(), filename, 'exec') - thedict = {} - result = eval(code, thedict) - wf_spec = thedict['TestWorkflowSpec']() - - else: - raise Exception('unsuported specification format', filename) - - test_data = WorkflowTestData( - filename, wf_spec, expected_path, expected_data) - self.workflows.append(test_data) - - def testWorkflowSpec(self): - for test in self.workflows: - print(test.filename) - run_workflow(self, test.spec, test.path, test.data) - - -def suite(): - return unittest.TestLoader().loadTestsFromTestCase(PatternTest) -if __name__ == '__main__': - if len(sys.argv) == 2: - test = PatternTest('run_pattern') - test.setUp() - test.run_pattern(sys.argv[1]) - sys.exit(0) - unittest.TextTestRunner(verbosity=2).run(suite()) diff --git a/tests/SpiffWorkflow/bpmn/ApprovalsTest.py b/tests/SpiffWorkflow/bpmn/ApprovalsTest.py index 857c81f07..9247dec99 100644 --- a/tests/SpiffWorkflow/bpmn/ApprovalsTest.py +++ b/tests/SpiffWorkflow/bpmn/ApprovalsTest.py @@ -2,7 +2,7 @@ import unittest from SpiffWorkflow.bpmn.workflow import BpmnWorkflow -from tests.SpiffWorkflow.bpmn.BpmnWorkflowTestCase import BpmnWorkflowTestCase +from .BpmnWorkflowTestCase import BpmnWorkflowTestCase __author__ = 'matth' diff --git a/tests/SpiffWorkflow/bpmn/BaseParallelTestCase.py b/tests/SpiffWorkflow/bpmn/BaseParallelTestCase.py index 80fc5ff7b..a936e602f 100644 --- a/tests/SpiffWorkflow/bpmn/BaseParallelTestCase.py +++ b/tests/SpiffWorkflow/bpmn/BaseParallelTestCase.py @@ -1,10 +1,7 @@ # -*- coding: utf-8 -*- -from builtins import range -import unittest import logging from SpiffWorkflow.task import TaskState -from SpiffWorkflow.bpmn.workflow import BpmnWorkflow from tests.SpiffWorkflow.bpmn.BpmnWorkflowTestCase import BpmnWorkflowTestCase __author__ = 'matth' @@ -28,13 +25,9 @@ class BaseParallelTestCase(BpmnWorkflowTestCase): "Doing step '%s' (with choice='%s')", s, choice) else: logging.info("Doing step '%s'", s) - # logging.debug(self.workflow.get_dump()) - self.do_next_named_step( - s, choice=choice, only_one_instance=only_one_instance) + self.do_next_named_step(s, choice=choice, only_one_instance=only_one_instance) self.workflow.do_engine_steps() if save_restore: - # logging.debug("Before SaveRestore: \n%s" % - # self.workflow.get_dump()) self.save_restore() self.workflow.do_engine_steps() diff --git a/tests/SpiffWorkflow/bpmn/BpmnLoaderForTests.py b/tests/SpiffWorkflow/bpmn/BpmnLoaderForTests.py index d8420daa8..376975ba9 100644 --- a/tests/SpiffWorkflow/bpmn/BpmnLoaderForTests.py +++ b/tests/SpiffWorkflow/bpmn/BpmnLoaderForTests.py @@ -34,7 +34,7 @@ class TestUserTask(UserTask): def do_choice(self, task, choice): task.set_data(choice=choice) - task.complete() + task.run() class TestExclusiveGatewayParser(ConditionalGatewayParser): diff --git a/tests/SpiffWorkflow/bpmn/BpmnWorkflowTestCase.py b/tests/SpiffWorkflow/bpmn/BpmnWorkflowTestCase.py index d16a87920..5f9b797c6 100644 --- a/tests/SpiffWorkflow/bpmn/BpmnWorkflowTestCase.py +++ b/tests/SpiffWorkflow/bpmn/BpmnWorkflowTestCase.py @@ -64,7 +64,7 @@ class BpmnWorkflowTestCase(unittest.TestCase): def switch_workflow(p): for task_id, sp in p.workflow._get_outermost_workflow().subprocesses.items(): if p in sp.get_tasks(workflow=sp): - return p.workflow.get_task(task_id) + return p.workflow.get_task_from_id(task_id) def is_match(t): if not (t.task_spec.name == step_name_path[-1] or t.task_spec.description == step_name_path[-1]): @@ -116,7 +116,7 @@ class BpmnWorkflowTestCase(unittest.TestCase): if set_attribs: tasks[0].set_data(**set_attribs) - tasks[0].complete() + tasks[0].run() def save_restore(self): diff --git a/tests/SpiffWorkflow/bpmn/CallActivityEndEventTest.py b/tests/SpiffWorkflow/bpmn/CallActivityEndEventTest.py index 1e3d158e7..2fa5adfc5 100644 --- a/tests/SpiffWorkflow/bpmn/CallActivityEndEventTest.py +++ b/tests/SpiffWorkflow/bpmn/CallActivityEndEventTest.py @@ -6,7 +6,7 @@ from SpiffWorkflow.bpmn.PythonScriptEngine import PythonScriptEngine from SpiffWorkflow.bpmn.workflow import BpmnWorkflow from SpiffWorkflow.exceptions import WorkflowTaskException -from tests.SpiffWorkflow.bpmn.BpmnWorkflowTestCase import BpmnWorkflowTestCase +from .BpmnWorkflowTestCase import BpmnWorkflowTestCase __author__ = 'kellym' diff --git a/tests/SpiffWorkflow/bpmn/CollaborationTest.py b/tests/SpiffWorkflow/bpmn/CollaborationTest.py index 9f28bdbb7..b3c03f223 100644 --- a/tests/SpiffWorkflow/bpmn/CollaborationTest.py +++ b/tests/SpiffWorkflow/bpmn/CollaborationTest.py @@ -82,7 +82,7 @@ class CollaborationTest(BpmnWorkflowTestCase): workflow.do_engine_steps() for idx, task in enumerate(workflow.get_ready_user_tasks()): task.data['task_num'] = idx - task.complete() + task.run() workflow.do_engine_steps() ready_tasks = workflow.get_ready_user_tasks() waiting = workflow.get_tasks_from_spec_name('get_response') @@ -94,7 +94,7 @@ class CollaborationTest(BpmnWorkflowTestCase): # Now copy the task_num that was sent into a new variable for task in ready_tasks: task.data.update(init_id=task.data['task_num']) - task.complete() + task.run() workflow.do_engine_steps() # If the messages were routed properly, the id should match for task in workflow.get_tasks_from_spec_name('subprocess_end'): @@ -108,7 +108,7 @@ class CollaborationTest(BpmnWorkflowTestCase): workflow.do_engine_steps() for idx, task in enumerate(workflow.get_ready_user_tasks()): task.data['task_num'] = idx - task.complete() + task.run() workflow.do_engine_steps() # Two processes should have been started and two corresponding catch events should be waiting @@ -121,12 +121,12 @@ class CollaborationTest(BpmnWorkflowTestCase): # Now copy the task_num that was sent into a new variable for task in ready_tasks: task.data.update(init_id=task.data['task_num']) - task.complete() + task.run() workflow.do_engine_steps() # Complete dummy tasks for task in workflow.get_ready_user_tasks(): - task.complete() + task.run() workflow.do_engine_steps() # Repeat for the other process, using a different mapped name @@ -136,7 +136,7 @@ class CollaborationTest(BpmnWorkflowTestCase): self.assertEqual(len(waiting), 2) for task in ready_tasks: task.data.update(subprocess=task.data['task_num']) - task.complete() + task.run() workflow.do_engine_steps() # If the messages were routed properly, the id should match diff --git a/tests/SpiffWorkflow/bpmn/DataObjectReferenceTest.py b/tests/SpiffWorkflow/bpmn/DataObjectReferenceTest.py index fab8db77b..584202900 100644 --- a/tests/SpiffWorkflow/bpmn/DataObjectReferenceTest.py +++ b/tests/SpiffWorkflow/bpmn/DataObjectReferenceTest.py @@ -22,13 +22,13 @@ class DataObjectReferenceTest(BpmnWorkflowTestCase): # Add the data so that we can advance the workflow ready_tasks = self.workflow.get_ready_user_tasks() ready_tasks[0].data = { 'obj_1': 'hello' } - ready_tasks[0].complete() + ready_tasks[0].run() # Remove the data before advancing ready_tasks = self.workflow.get_ready_user_tasks() self.workflow.data.pop('obj_1') with self.assertRaises(WorkflowDataException) as exc: - ready_tasks[0].complete() + ready_tasks[0].run() self.assertEqual(exc.data_output.name, 'obj_1') def testMissingDataOutput(self): @@ -37,7 +37,7 @@ class DataObjectReferenceTest(BpmnWorkflowTestCase): self.workflow.do_engine_steps() ready_tasks = self.workflow.get_ready_user_tasks() with self.assertRaises(WorkflowDataException) as exc: - ready_tasks[0].complete() + ready_tasks[0].run() self.assertEqual(exc.data_output.name, 'obj_1') def actual_test(self, save_restore): @@ -48,7 +48,7 @@ class DataObjectReferenceTest(BpmnWorkflowTestCase): # Set up the data ready_tasks = self.workflow.get_ready_user_tasks() ready_tasks[0].data = { 'obj_1': 'hello' } - ready_tasks[0].complete() + ready_tasks[0].run() # After task completion, obj_1 should be copied out of the task into the workflow self.assertNotIn('obj_1', ready_tasks[0].data) self.assertIn('obj_1', self.workflow.data) @@ -59,14 +59,14 @@ class DataObjectReferenceTest(BpmnWorkflowTestCase): # Set a value for obj_1 in the task data again ready_tasks = self.workflow.get_ready_user_tasks() ready_tasks[0].data = { 'obj_1': 'hello again' } - ready_tasks[0].complete() + ready_tasks[0].run() # Check to make sure we use the workflow value instead of the value we set ready_tasks = self.workflow.get_ready_user_tasks() self.assertEqual(ready_tasks[0].data['obj_1'], 'hello') # Modify the value in the task ready_tasks[0].data = { 'obj_1': 'hello again' } - ready_tasks[0].complete() + ready_tasks[0].run() # We did not set an output data reference so obj_1 should remain unchanged in the workflow data # and be removed from the task data self.assertNotIn('obj_1', ready_tasks[0].data) @@ -77,7 +77,7 @@ class DataObjectReferenceTest(BpmnWorkflowTestCase): ready_tasks = self.workflow.get_ready_user_tasks() self.assertEqual(ready_tasks[0].data['obj_1'], 'hello') ready_tasks[0].data['obj_1'] = 'hello again' - ready_tasks[0].complete() + ready_tasks[0].run() self.workflow.do_engine_steps() sp = self.workflow.get_tasks_from_spec_name('subprocess')[0] # It was copied out diff --git a/tests/SpiffWorkflow/bpmn/IOSpecTest.py b/tests/SpiffWorkflow/bpmn/IOSpecTest.py index b3f70fe67..fe8dc7dd4 100644 --- a/tests/SpiffWorkflow/bpmn/IOSpecTest.py +++ b/tests/SpiffWorkflow/bpmn/IOSpecTest.py @@ -76,7 +76,7 @@ class CallActivityDataTest(BpmnWorkflowTestCase): waiting = self.workflow.get_tasks(TaskState.WAITING) while len(waiting) == 0: next_task = self.workflow.get_tasks(TaskState.READY)[0] - next_task.complete() + next_task.run() waiting = self.workflow.get_tasks(TaskState.WAITING) def complete_subprocess(self): @@ -84,7 +84,7 @@ class CallActivityDataTest(BpmnWorkflowTestCase): waiting = self.workflow.get_tasks(TaskState.WAITING) while len(waiting) > 0: next_task = self.workflow.get_tasks(TaskState.READY)[0] - next_task.complete() + next_task.run() waiting = self.workflow.get_tasks(TaskState.WAITING) @@ -113,7 +113,7 @@ class IOSpecOnTaskTest(BpmnWorkflowTestCase): task = self.workflow.get_tasks_from_spec_name('any_task')[0] task.data.update({'out_1': 1}) with self.assertRaises(WorkflowDataException) as exc: - task.complete() + task.run() self.assertEqual(exc.exception.data_output.name, 'out_2') def actual_test(self, save_restore=False): @@ -124,6 +124,6 @@ class IOSpecOnTaskTest(BpmnWorkflowTestCase): task = self.workflow.get_tasks_from_spec_name('any_task')[0] self.assertDictEqual(task.data, {'in_1': 1, 'in_2': 'hello world'}) task.data.update({'out_1': 1, 'out_2': 'bye', 'extra': True}) - task.complete() + task.run() self.workflow.do_engine_steps() self.assertDictEqual(self.workflow.last_task.data, {'out_1': 1, 'out_2': 'bye'}) diff --git a/tests/SpiffWorkflow/bpmn/InclusiveGatewayTest.py b/tests/SpiffWorkflow/bpmn/InclusiveGatewayTest.py index f4a0e5db6..1b46e29d4 100644 --- a/tests/SpiffWorkflow/bpmn/InclusiveGatewayTest.py +++ b/tests/SpiffWorkflow/bpmn/InclusiveGatewayTest.py @@ -36,4 +36,4 @@ class InclusiveGatewayTest(BpmnWorkflowTestCase): def set_data(self, value): task = self.workflow.get_ready_user_tasks()[0] task.data = value - task.complete() + task.run() diff --git a/tests/SpiffWorkflow/bpmn/ParallelMultiInstanceTest.py b/tests/SpiffWorkflow/bpmn/ParallelMultiInstanceTest.py index c72948b42..314d73931 100644 --- a/tests/SpiffWorkflow/bpmn/ParallelMultiInstanceTest.py +++ b/tests/SpiffWorkflow/bpmn/ParallelMultiInstanceTest.py @@ -26,7 +26,7 @@ class BaseTestCase(BpmnWorkflowTestCase): self.assertEqual(task.task_spec.name, 'any_task [child]') self.assertIn('input_item', task.data) task.data['output_item'] = task.data['input_item'] * 2 - task.complete() + task.run() if save_restore: self.save_restore() ready_tasks = self.workflow.get_ready_user_tasks() @@ -47,7 +47,7 @@ class BaseTestCase(BpmnWorkflowTestCase): self.assertEqual(len(ready_tasks), 3) task = [t for t in ready_tasks if t.data['input_item'] == 2][0] task.data['output_item'] = task.data['input_item'] * 2 - task.complete() + task.run() self.workflow.do_engine_steps() self.workflow.refresh_waiting_tasks() diff --git a/tests/SpiffWorkflow/bpmn/ParallelOrderTest.py b/tests/SpiffWorkflow/bpmn/ParallelOrderTest.py index 39797448b..3232ac6b0 100644 --- a/tests/SpiffWorkflow/bpmn/ParallelOrderTest.py +++ b/tests/SpiffWorkflow/bpmn/ParallelOrderTest.py @@ -20,7 +20,7 @@ class ParallelOrderTest(BpmnWorkflowTestCase): self.workflow.do_engine_steps() self.assertFalse(self.workflow.is_completed()) - self.assertEquals(4, len(self.workflow.get_ready_user_tasks())) + self.assertEqual(4, len(self.workflow.get_ready_user_tasks())) tasks = self.workflow.get_ready_user_tasks() self.assertEquals("Task 1", tasks[0].get_description()) self.assertEquals("Task 2", tasks[1].get_description()) diff --git a/tests/SpiffWorkflow/bpmn/ParallelThroughSameTaskTest.py b/tests/SpiffWorkflow/bpmn/ParallelThroughSameTaskTest.py index 4768ddbae..07c790dc8 100644 --- a/tests/SpiffWorkflow/bpmn/ParallelThroughSameTaskTest.py +++ b/tests/SpiffWorkflow/bpmn/ParallelThroughSameTaskTest.py @@ -51,7 +51,7 @@ class ParallelThroughSameTaskTest(BpmnWorkflowTestCase): self.assertEqual(2, len(ready_tasks)) self.assertEqual( 'Repeated Task', ready_tasks[0].task_spec.description) - ready_tasks[0].complete() + ready_tasks[0].run() self.workflow.do_engine_steps() # The inclusive gateway allows us through here, because there is no route for the other thread # that doesn't use the same sequence flow @@ -82,7 +82,7 @@ class ParallelThroughSameTaskTest(BpmnWorkflowTestCase): self.assertEqual(2, len(ready_tasks)) self.assertEqual( 'Repeated Task', ready_tasks[0].task_spec.description) - ready_tasks[0].complete() + ready_tasks[0].run() self.workflow.do_engine_steps() self.save_restore() # The inclusive gateway allows us through here, because there is no route for the other thread diff --git a/tests/SpiffWorkflow/bpmn/ResetSubProcessTest.py b/tests/SpiffWorkflow/bpmn/ResetSubProcessTest.py index 81e5f330e..b9cd99be7 100644 --- a/tests/SpiffWorkflow/bpmn/ResetSubProcessTest.py +++ b/tests/SpiffWorkflow/bpmn/ResetSubProcessTest.py @@ -35,7 +35,7 @@ class ResetSubProcessTest(BpmnWorkflowTestCase): self.workflow.do_engine_steps() top_level_task = self.workflow.get_ready_user_tasks()[0] - self.workflow.complete_task_from_id(top_level_task.id) + self.workflow.run_task_from_id(top_level_task.id) self.workflow.do_engine_steps() task = self.workflow.get_ready_user_tasks()[0] self.save_restore() @@ -50,11 +50,11 @@ class ResetSubProcessTest(BpmnWorkflowTestCase): self.workflow.do_engine_steps() self.assertEqual(1, len(self.workflow.get_ready_user_tasks())) task = self.workflow.get_ready_user_tasks()[0] - self.workflow.complete_task_from_id(task.id) + self.workflow.run_task_from_id(task.id) self.workflow.do_engine_steps() task = self.workflow.get_ready_user_tasks()[0] self.assertEqual(task.get_name(),'SubTask2') - self.workflow.complete_task_from_id(task.id) + self.workflow.run_task_from_id(task.id) self.workflow.do_engine_steps() task = self.workflow.get_tasks_from_spec_name('Task1')[0] task.reset_token(self.workflow.last_task.data) @@ -62,19 +62,19 @@ class ResetSubProcessTest(BpmnWorkflowTestCase): self.reload_save_restore() task = self.workflow.get_ready_user_tasks()[0] self.assertEqual(task.get_name(),'Task1') - self.workflow.complete_task_from_id(task.id) + self.workflow.run_task_from_id(task.id) self.workflow.do_engine_steps() task = self.workflow.get_ready_user_tasks()[0] self.assertEqual(task.get_name(),'Subtask2') - self.workflow.complete_task_from_id(task.id) + self.workflow.run_task_from_id(task.id) self.workflow.do_engine_steps() task = self.workflow.get_ready_user_tasks()[0] self.assertEqual(task.get_name(),'Subtask2A') - self.workflow.complete_task_from_id(task.id) + self.workflow.run_task_from_id(task.id) self.workflow.do_engine_steps() task = self.workflow.get_ready_user_tasks()[0] self.assertEqual(task.get_name(),'Task2') - self.workflow.complete_task_from_id(task.id) + self.workflow.run_task_from_id(task.id) self.workflow.do_engine_steps() self.assertTrue(self.workflow.is_completed()) diff --git a/tests/SpiffWorkflow/bpmn/ResetTimerTest.py b/tests/SpiffWorkflow/bpmn/ResetTimerTest.py deleted file mode 100644 index 8a94dabab..000000000 --- a/tests/SpiffWorkflow/bpmn/ResetTimerTest.py +++ /dev/null @@ -1,28 +0,0 @@ - -from SpiffWorkflow.bpmn.workflow import BpmnWorkflow -from SpiffWorkflow.task import TaskState - -from tests.SpiffWorkflow.bpmn.BpmnWorkflowTestCase import BpmnWorkflowTestCase - -class ResetTimerTest(BpmnWorkflowTestCase): - - def test_timer(self): - spec, subprocess = self.load_workflow_spec('reset_timer.bpmn', 'main') - self.workflow = BpmnWorkflow(spec, subprocess) - self.workflow.do_engine_steps() - task_1 = self.workflow.get_tasks_from_spec_name('task_1')[0] - timer = self.workflow.get_tasks_from_spec_name('timer')[0] - original_timer = timer.internal_data.get('event_value') - # This returns us to the task - task_1.data['modify'] = True - task_1.complete() - self.workflow.do_engine_steps() - # The timer should be waiting and the time should have been updated - self.assertEqual(task_1.state, TaskState.READY) - self.assertEqual(timer.state, TaskState.WAITING) - self.assertGreater(timer.internal_data.get('event_value'), original_timer) - task_1.data['modify'] = False - task_1.complete() - self.workflow.do_engine_steps() - self.assertEqual(timer.state, TaskState.CANCELLED) - self.assertTrue(self.workflow.is_completed()) \ No newline at end of file diff --git a/tests/SpiffWorkflow/bpmn/SequentialMultiInstanceTest.py b/tests/SpiffWorkflow/bpmn/SequentialMultiInstanceTest.py index ba93fdbe1..c70b8e473 100644 --- a/tests/SpiffWorkflow/bpmn/SequentialMultiInstanceTest.py +++ b/tests/SpiffWorkflow/bpmn/SequentialMultiInstanceTest.py @@ -27,7 +27,7 @@ class BaseTestCase(BpmnWorkflowTestCase): self.assertEqual(task.task_spec.name, 'any_task [child]') self.assertIn('input_item', task.data) task.data['output_item'] = task.data['input_item'] * 2 - task.complete() + task.run() if save_restore: self.save_restore() ready_tasks = self.workflow.get_ready_user_tasks() @@ -54,7 +54,7 @@ class BaseTestCase(BpmnWorkflowTestCase): self.assertEqual(ready.task_spec.name, 'any_task [child]') self.assertIn('input_item', ready.data) ready.data['output_item'] = ready.data['input_item'] * 2 - ready.complete() + ready.run() self.workflow.do_engine_steps() self.workflow.refresh_waiting_tasks() ready_tasks = self.workflow.get_ready_user_tasks() diff --git a/tests/SpiffWorkflow/bpmn/StandardLoopTest.py b/tests/SpiffWorkflow/bpmn/StandardLoopTest.py index e9d6534c4..18a819764 100644 --- a/tests/SpiffWorkflow/bpmn/StandardLoopTest.py +++ b/tests/SpiffWorkflow/bpmn/StandardLoopTest.py @@ -21,7 +21,7 @@ class StandardLoopTest(BpmnWorkflowTestCase): ready_tasks = self.workflow.get_ready_user_tasks() self.assertEqual(len(ready_tasks), 1) ready_tasks[0].data[str(idx)] = True - ready_tasks[0].complete() + ready_tasks[0].run() self.workflow.do_engine_steps() self.assertTrue(self.workflow.is_completed()) @@ -36,7 +36,7 @@ class StandardLoopTest(BpmnWorkflowTestCase): ready_tasks = self.workflow.get_ready_user_tasks() self.assertEqual(len(ready_tasks), 1) ready_tasks[0].data['done'] = True - ready_tasks[0].complete() + ready_tasks[0].run() self.workflow.do_engine_steps() self.assertTrue(self.workflow.is_completed()) diff --git a/tests/SpiffWorkflow/bpmn/SwimLaneTest.py b/tests/SpiffWorkflow/bpmn/SwimLaneTest.py index 12bbedddc..a7000d526 100644 --- a/tests/SpiffWorkflow/bpmn/SwimLaneTest.py +++ b/tests/SpiffWorkflow/bpmn/SwimLaneTest.py @@ -35,7 +35,7 @@ class SwimLaneTest(BpmnWorkflowTestCase): self.assertEqual(0, len(btasks)) task = atasks[0] self.assertEqual('Activity_A1', task.task_spec.name) - self.workflow.complete_task_from_id(task.id) + self.workflow.run_task_from_id(task.id) self.workflow.do_engine_steps() atasks = self.workflow.get_ready_user_tasks(lane="A") btasks = self.workflow.get_ready_user_tasks(lane="B") @@ -44,10 +44,10 @@ class SwimLaneTest(BpmnWorkflowTestCase): # Complete the gateway and the two tasks in B Lane btasks[0].data = {'NeedClarification': False} - self.workflow.complete_task_from_id(btasks[0].id) + self.workflow.run_task_from_id(btasks[0].id) self.workflow.do_engine_steps() btasks = self.workflow.get_ready_user_tasks(lane="B") - self.workflow.complete_task_from_id(btasks[0].id) + self.workflow.run_task_from_id(btasks[0].id) self.workflow.do_engine_steps() # Assert we are in lane C @@ -56,7 +56,7 @@ class SwimLaneTest(BpmnWorkflowTestCase): self.assertEqual(tasks[0].task_spec.lane, "C") # Step into the sub-process, assure that is also in lane C - self.workflow.complete_task_from_id(tasks[0].id) + self.workflow.run_task_from_id(tasks[0].id) self.workflow.do_engine_steps() tasks = self.workflow.get_ready_user_tasks() self.assertEqual("SubProcessTask", tasks[0].task_spec.description) diff --git a/tests/SpiffWorkflow/bpmn/TooManyLoopsTest.py b/tests/SpiffWorkflow/bpmn/TooManyLoopsTest.py deleted file mode 100644 index 0b3d56033..000000000 --- a/tests/SpiffWorkflow/bpmn/TooManyLoopsTest.py +++ /dev/null @@ -1,86 +0,0 @@ -# -*- coding: utf-8 -*- - -import datetime -import unittest - -from SpiffWorkflow.bpmn.PythonScriptEngine import PythonScriptEngine -from SpiffWorkflow.bpmn.PythonScriptEngineEnvironment import TaskDataEnvironment -from SpiffWorkflow.bpmn.workflow import BpmnWorkflow -from tests.SpiffWorkflow.bpmn.BpmnWorkflowTestCase import BpmnWorkflowTestCase - -__author__ = 'sartography' - -class CustomScriptEngine(PythonScriptEngine): - """This is a custom script processor that can be easily injected into Spiff Workflow. - It will execute python code read in from the bpmn. It will also make any scripts in the - scripts directory available for execution. """ - def __init__(self): - environment = TaskDataEnvironment({ - 'timedelta': datetime.timedelta, - }) - super().__init__(environment=environment) - -class TooManyLoopsTest(BpmnWorkflowTestCase): - - """Looping back around many times would cause the tree of tasks to grow - for each loop, doing this a 100 or 1000 times would cause the system to - run fail in various ways. This assures that is no longer the case.""" - - 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): - spec, subprocesses = self.load_workflow_spec('too_many_loops*.bpmn', 'loops') - self.workflow = BpmnWorkflow(spec, subprocesses, script_engine=CustomScriptEngine()) - counter = 0 - data = {} - while not self.workflow.is_completed(): - self.workflow.do_engine_steps() - self.workflow.refresh_waiting_tasks() - if (self.workflow.last_task.data != data): - data = self.workflow.last_task.data - counter += 1 # There is a 10 millisecond wait task. - if save_restore: - self.save_restore() - self.workflow.script_engine = CustomScriptEngine() - self.assertEqual(20, self.workflow.last_task.data['counter']) - - def test_with_sub_process(self): - # Found an issue where looping back would fail when it happens - # right after a sub-process. So assuring this is fixed. - counter = 0 - spec, subprocesses = self.load_workflow_spec('too_many_loops_sub_process.bpmn', 'loops_sub') - self.workflow = BpmnWorkflow(spec, subprocesses, script_engine=CustomScriptEngine()) - data = {} - while not self.workflow.is_completed(): - self.workflow.do_engine_steps() - self.workflow.refresh_waiting_tasks() - if (self.workflow.last_task.data != data): - data = self.workflow.last_task.data - counter += 1 # There is a 10 millisecond wait task. -# self.save_restore() - self.assertEqual(20, self.workflow.last_task.data['counter']) - # One less, because we don't go back through once the first counter - # hits 20. - self.assertEqual(19, self.workflow.last_task.data['counter2']) - - def test_with_two_call_activities(self): - spec, subprocess = self.load_workflow_spec('sub_in_loop*.bpmn', 'main') - self.workflow = BpmnWorkflow(spec, subprocess, script_engine=CustomScriptEngine()) - self.workflow.do_engine_steps() - for loop in range(3): - ready = self.workflow.get_ready_user_tasks() - ready[0].data = { 'done': True if loop == 3 else False } - ready[0].complete() - self.workflow.refresh_waiting_tasks() - self.workflow.do_engine_steps() - self.save_restore() - self.workflow.script_engine = CustomScriptEngine() - -def suite(): - return unittest.TestLoader().loadTestsFromTestCase(TooManyLoopsTest) -if __name__ == '__main__': - unittest.TextTestRunner(verbosity=2).run(suite()) diff --git a/tests/SpiffWorkflow/bpmn/data/Test-Workflows/Parallel-Looping-After-Join.bpmn20.xml b/tests/SpiffWorkflow/bpmn/data/Test-Workflows/Parallel-Looping-After-Join.bpmn20.xml index 150b28d10..c37bc64dd 100644 --- a/tests/SpiffWorkflow/bpmn/data/Test-Workflows/Parallel-Looping-After-Join.bpmn20.xml +++ b/tests/SpiffWorkflow/bpmn/data/Test-Workflows/Parallel-Looping-After-Join.bpmn20.xml @@ -1,291 +1,303 @@ - - - - - - - - - - - - - - - sid-B33EE043-AB93-4343-A1D4-7B267E2DAFBE - sid-349F8C0C-45EA-489C-84DD-1D944F48D778 - sid-57463471-693A-42A2-9EC6-6460BEDECA86 - sid-CA089240-802A-4C32-9130-FB1A33DDCCC3 - sid-E976FBC2-266E-420F-8D4D-C8FBC6199090 - sid-F3A979E3-F586-4807-8223-1FAB5A5647B0 - sid-51816945-79BF-47F9-BA3C-E95ABAE3D1DB - sid-4F7F3AA6-4E8E-458D-BBEF-E03FC0646897 - sid-ABD788A3-CD57-4280-A22A-260B3AEEE138 - sid-E7B8898A-0D14-4E98-B3D7-736B94EE3FA7 - sid-A1609BD5-1E4A-47AE-8648-1DD41D1B1D58 - sid-1946C635-7886-4687-844F-C644FA6222B8 - sid-4C3B3C16-91DB-43E3-A816-FFEE572E61E1 - sid-55C018B8-C073-4292-9ED0-79BDE50E7498 - sid-E7904BFA-1F17-478E-91C9-C8A5B64190C9 - - - - - - - sid-F3994F51-FE54-4910-A1F4-E5895AA1A612 - - - - - - sid-3E0EBE59-75C8-465C-90CC-197CE808A96E - sid-7E15C71B-DE9E-4788-B140-A647C99FDC94 - sid-B6E22A74-A691-453A-A789-B9F8AF787D7C - - - - - - sid-7E15C71B-DE9E-4788-B140-A647C99FDC94 - sid-607CB05E-8762-41B6-AD43-C3970661A99D - - - - - - sid-B6E22A74-A691-453A-A789-B9F8AF787D7C - sid-CAEAD081-6E73-4C98-8656-C67DA18F5140 - - - - - - sid-231F8A51-752F-4CB3-8FD1-23D153238344 - sid-607CB05E-8762-41B6-AD43-C3970661A99D - sid-0895E09C-077C-4D12-8C11-31F28CBC7740 - - - - - - sid-0895E09C-077C-4D12-8C11-31F28CBC7740 - sid-2668AC98-39E4-4B12-9052-930528086CAC - - - - - - sid-F6160C0E-216C-4D72-98D1-CC5549327D55 - - - - - - sid-CAEAD081-6E73-4C98-8656-C67DA18F5140 - sid-918C653D-0960-4223-9C28-78114F238BCC - sid-FD82C2A6-7C54-4890-901E-A7E864F7605C - - - - - - sid-918C653D-0960-4223-9C28-78114F238BCC - sid-961AF51C-9935-410E-AAA4-105B19186F5E - - - - - - sid-FD82C2A6-7C54-4890-901E-A7E864F7605C - sid-47947925-21CD-46FF-8D3F-294B235AA4CF - - - - - - sid-961AF51C-9935-410E-AAA4-105B19186F5E - sid-47947925-21CD-46FF-8D3F-294B235AA4CF - sid-AFA38469-CD5C-42A2-9473-2EAEBA61F0C0 - - - - - - sid-AFA38469-CD5C-42A2-9473-2EAEBA61F0C0 - sid-231F8A51-752F-4CB3-8FD1-23D153238344 - - - - - - sid-2668AC98-39E4-4B12-9052-930528086CAC - sid-08D6385B-C6BB-45FC-A6BD-2369F392868D - sid-41205B5D-4DBA-4155-A0EE-7D71CE9AA459 - - - - - - sid-08D6385B-C6BB-45FC-A6BD-2369F392868D - sid-F6160C0E-216C-4D72-98D1-CC5549327D55 - - - - - - sid-41205B5D-4DBA-4155-A0EE-7D71CE9AA459 - sid-F3994F51-FE54-4910-A1F4-E5895AA1A612 - sid-3E0EBE59-75C8-465C-90CC-197CE808A96E - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + start + first_split + one + two + join_of_first + retry + end + second_split + two_a + two_b + join_of_second_split + two_done + exclusive + done + go + + + + + + + sid-F3994F51-FE54-4910-A1F4-E5895AA1A612 + + + + + + sid-3E0EBE59-75C8-465C-90CC-197CE808A96E + sid-7E15C71B-DE9E-4788-B140-A647C99FDC94 + sid-B6E22A74-A691-453A-A789-B9F8AF787D7C + + + + + + sid-7E15C71B-DE9E-4788-B140-A647C99FDC94 + join_of_first_split + + + + + + sid-B6E22A74-A691-453A-A789-B9F8AF787D7C + sid-CAEAD081-6E73-4C98-8656-C67DA18F5140 + + + + + + sid-231F8A51-752F-4CB3-8FD1-23D153238344 + join_of_first_split + sid-0895E09C-077C-4D12-8C11-31F28CBC7740 + + + + + + sid-0895E09C-077C-4D12-8C11-31F28CBC7740 + sid-2668AC98-39E4-4B12-9052-930528086CAC + + + + + + sid-F6160C0E-216C-4D72-98D1-CC5549327D55 + + + + + + sid-CAEAD081-6E73-4C98-8656-C67DA18F5140 + sid-918C653D-0960-4223-9C28-78114F238BCC + sid-FD82C2A6-7C54-4890-901E-A7E864F7605C + + + + + + sid-918C653D-0960-4223-9C28-78114F238BCC + sid-961AF51C-9935-410E-AAA4-105B19186F5E + + + + + + sid-FD82C2A6-7C54-4890-901E-A7E864F7605C + sid-47947925-21CD-46FF-8D3F-294B235AA4CF + + + + + + sid-961AF51C-9935-410E-AAA4-105B19186F5E + sid-47947925-21CD-46FF-8D3F-294B235AA4CF + sid-AFA38469-CD5C-42A2-9473-2EAEBA61F0C0 + + + + + + sid-AFA38469-CD5C-42A2-9473-2EAEBA61F0C0 + sid-231F8A51-752F-4CB3-8FD1-23D153238344 + + + + + + sid-2668AC98-39E4-4B12-9052-930528086CAC + sid-08D6385B-C6BB-45FC-A6BD-2369F392868D + sid-41205B5D-4DBA-4155-A0EE-7D71CE9AA459 + + + + + + sid-08D6385B-C6BB-45FC-A6BD-2369F392868D + sid-F6160C0E-216C-4D72-98D1-CC5549327D55 + + + + + + sid-41205B5D-4DBA-4155-A0EE-7D71CE9AA459 + sid-F3994F51-FE54-4910-A1F4-E5895AA1A612 + sid-3E0EBE59-75C8-465C-90CC-197CE808A96E + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/SpiffWorkflow/bpmn/data/reset_timer.bpmn b/tests/SpiffWorkflow/bpmn/data/reset_timer.bpmn deleted file mode 100644 index 7750e4bb2..000000000 --- a/tests/SpiffWorkflow/bpmn/data/reset_timer.bpmn +++ /dev/null @@ -1,104 +0,0 @@ - - - - - Flow_0j648np - - - Flow_0j648np - modify - Flow_13cp5nc - - - - Flow_13cp5nc - Flow_1r81vou - - - - Flow_0m5s7t9 - Flow_0p7c88x - - - Flow_1gm7381 - Flow_0p7c88x - - - Flow_0m5s7t9 - - "PT60S" - - - - - Flow_1r81vou - modify - Flow_1gm7381 - - - - modify - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/SpiffWorkflow/bpmn/data/serialization/v1.1-loop-reset.json b/tests/SpiffWorkflow/bpmn/data/serialization/v1.1-loop-reset.json new file mode 100644 index 000000000..4068fdca0 --- /dev/null +++ b/tests/SpiffWorkflow/bpmn/data/serialization/v1.1-loop-reset.json @@ -0,0 +1,600 @@ +{ + "serializer_version": "1.1", + "data": {}, + "last_task": "65ef57f0-3fbf-4851-b7c8-a03de9a9062d", + "success": true, + "tasks": { + "fcccd5d5-8e9c-4dba-91c3-5b2ed44bb332": { + "id": "fcccd5d5-8e9c-4dba-91c3-5b2ed44bb332", + "parent": null, + "children": [ + "e9523ea2-0474-4c36-a7c2-24ff56633ed7" + ], + "last_state_change": 1678818080.7799659, + "state": 32, + "task_spec": "Root", + "triggered": false, + "workflow_name": "loops", + "internal_data": {}, + "data": {} + }, + "e9523ea2-0474-4c36-a7c2-24ff56633ed7": { + "id": "e9523ea2-0474-4c36-a7c2-24ff56633ed7", + "parent": "fcccd5d5-8e9c-4dba-91c3-5b2ed44bb332", + "children": [ + "af4a1c32-12a7-46a7-b985-284fef1cb993" + ], + "last_state_change": 1678818080.7888825, + "state": 32, + "task_spec": "Start", + "triggered": false, + "workflow_name": "loops", + "internal_data": {}, + "data": {} + }, + "af4a1c32-12a7-46a7-b985-284fef1cb993": { + "id": "af4a1c32-12a7-46a7-b985-284fef1cb993", + "parent": "e9523ea2-0474-4c36-a7c2-24ff56633ed7", + "children": [ + "65ef57f0-3fbf-4851-b7c8-a03de9a9062d" + ], + "last_state_change": 1678818080.7926495, + "state": 32, + "task_spec": "StartEvent_1", + "triggered": false, + "workflow_name": "loops", + "internal_data": { + "event_fired": true + }, + "data": {} + }, + "65ef57f0-3fbf-4851-b7c8-a03de9a9062d": { + "id": "65ef57f0-3fbf-4851-b7c8-a03de9a9062d", + "parent": "af4a1c32-12a7-46a7-b985-284fef1cb993", + "children": [ + "b5200074-8196-40d3-8f83-204cf132856c" + ], + "last_state_change": 1678818080.7970355, + "state": 32, + "task_spec": "initialize", + "triggered": false, + "workflow_name": "loops", + "internal_data": {}, + "data": { + "counter": 0 + } + }, + "b5200074-8196-40d3-8f83-204cf132856c": { + "id": "b5200074-8196-40d3-8f83-204cf132856c", + "parent": "65ef57f0-3fbf-4851-b7c8-a03de9a9062d", + "children": [ + "2ab8ec7f-a9ee-4891-a7a9-20250e2ab816" + ], + "last_state_change": 1678818091.420421, + "state": 16, + "task_spec": "TIMER_EVENT", + "triggered": false, + "workflow_name": "loops", + "internal_data": { + "event_value": "2023-03-14T18:21:20.809141+00:00", + "event_fired": true + }, + "data": { + "counter": 0 + } + }, + "2ab8ec7f-a9ee-4891-a7a9-20250e2ab816": { + "id": "2ab8ec7f-a9ee-4891-a7a9-20250e2ab816", + "parent": "b5200074-8196-40d3-8f83-204cf132856c", + "children": [ + "259de884-e162-4e0b-8c86-d4827870e2ca" + ], + "last_state_change": 1678818080.7815213, + "state": 4, + "task_spec": "increment_counter", + "triggered": false, + "workflow_name": "loops", + "internal_data": {}, + "data": {} + }, + "259de884-e162-4e0b-8c86-d4827870e2ca": { + "id": "259de884-e162-4e0b-8c86-d4827870e2ca", + "parent": "2ab8ec7f-a9ee-4891-a7a9-20250e2ab816", + "children": [ + "bd7c4868-142b-487f-9ed3-6a384762dd55" + ], + "last_state_change": 1678818080.7818034, + "state": 4, + "task_spec": "Activity_0w5u4k4", + "triggered": false, + "workflow_name": "loops", + "internal_data": {}, + "data": {} + }, + "bd7c4868-142b-487f-9ed3-6a384762dd55": { + "id": "bd7c4868-142b-487f-9ed3-6a384762dd55", + "parent": "259de884-e162-4e0b-8c86-d4827870e2ca", + "children": [ + "2fc6691e-f99b-46f2-bebc-7ba729880d13", + "3a14ea66-76b3-4442-8cb3-71a89b9b92fd" + ], + "last_state_change": 1678818080.782314, + "state": 4, + "task_spec": "Gateway_over_20", + "triggered": false, + "workflow_name": "loops", + "internal_data": {}, + "data": {} + }, + "2fc6691e-f99b-46f2-bebc-7ba729880d13": { + "id": "2fc6691e-f99b-46f2-bebc-7ba729880d13", + "parent": "bd7c4868-142b-487f-9ed3-6a384762dd55", + "children": [ + "655b5f82-14dd-4edd-b88d-94e8cce02e78" + ], + "last_state_change": 1678818080.783402, + "state": 1, + "task_spec": "end_event5", + "triggered": false, + "workflow_name": "loops", + "internal_data": {}, + "data": {} + }, + "655b5f82-14dd-4edd-b88d-94e8cce02e78": { + "id": "655b5f82-14dd-4edd-b88d-94e8cce02e78", + "parent": "2fc6691e-f99b-46f2-bebc-7ba729880d13", + "children": [], + "last_state_change": 1678818080.7840528, + "state": 1, + "task_spec": "loops.EndJoin", + "triggered": false, + "workflow_name": "loops", + "internal_data": {}, + "data": {} + }, + "3a14ea66-76b3-4442-8cb3-71a89b9b92fd": { + "id": "3a14ea66-76b3-4442-8cb3-71a89b9b92fd", + "parent": "bd7c4868-142b-487f-9ed3-6a384762dd55", + "children": [], + "last_state_change": 1678818080.7835343, + "state": 1, + "task_spec": "return_to_TIMER_EVENT", + "triggered": false, + "workflow_name": "loops", + "internal_data": {}, + "data": {} + } + }, + "root": "fcccd5d5-8e9c-4dba-91c3-5b2ed44bb332", + "spec": { + "name": "loops", + "description": "loops", + "file": "/home/essweine/work/sartography/code/SpiffWorkflow/tests/SpiffWorkflow/bpmn/data/too_many_loops.bpmn", + "task_specs": { + "Start": { + "id": "loops_1", + "name": "Start", + "description": "", + "manual": false, + "internal": false, + "lookahead": 2, + "inputs": [], + "outputs": [ + "StartEvent_1" + ], + "typename": "StartTask" + }, + "loops.EndJoin": { + "id": "loops_2", + "name": "loops.EndJoin", + "description": "", + "manual": false, + "internal": false, + "lookahead": 2, + "inputs": [ + "end_event5" + ], + "outputs": [ + "End" + ], + "typename": "_EndJoin" + }, + "End": { + "id": "loops_3", + "name": "End", + "description": "", + "manual": false, + "internal": false, + "lookahead": 2, + "inputs": [ + "loops.EndJoin" + ], + "outputs": [], + "typename": "Simple" + }, + "StartEvent_1": { + "id": "loops_4", + "name": "StartEvent_1", + "description": null, + "manual": false, + "internal": false, + "lookahead": 2, + "inputs": [ + "Start" + ], + "outputs": [ + "initialize" + ], + "lane": null, + "documentation": null, + "position": { + "x": 152.0, + "y": 159.0 + }, + "data_input_associations": [], + "data_output_associations": [], + "io_specification": null, + "event_definition": { + "internal": false, + "external": false, + "typename": "NoneEventDefinition" + }, + "typename": "StartEvent", + "extensions": {} + }, + "initialize": { + "id": "loops_5", + "name": "initialize", + "description": "initialize", + "manual": false, + "internal": false, + "lookahead": 2, + "inputs": [ + "StartEvent_1" + ], + "outputs": [ + "TIMER_EVENT" + ], + "lane": null, + "documentation": null, + "position": { + "x": 250.0, + "y": 137.0 + }, + "data_input_associations": [], + "data_output_associations": [], + "io_specification": null, + "script": "counter = 0", + "typename": "ScriptTask", + "extensions": {} + }, + "TIMER_EVENT": { + "id": "loops_6", + "name": "TIMER_EVENT", + "description": "Wait", + "manual": false, + "internal": false, + "lookahead": 2, + "inputs": [ + "Gateway_over_20", + "initialize" + ], + "outputs": [ + "increment_counter" + ], + "lane": null, + "documentation": null, + "position": { + "x": 412.0, + "y": 159.0 + }, + "data_input_associations": [], + "data_output_associations": [], + "io_specification": null, + "event_definition": { + "internal": true, + "external": true, + "name": "Wait", + "expression": "\"PT.01S\"", + "typename": "DurationTimerEventDefinition" + }, + "typename": "IntermediateCatchEvent", + "extensions": {} + }, + "increment_counter": { + "id": "loops_7", + "name": "increment_counter", + "description": "increment counter", + "manual": false, + "internal": false, + "lookahead": 2, + "inputs": [ + "TIMER_EVENT" + ], + "outputs": [ + "Activity_0w5u4k4" + ], + "lane": null, + "documentation": null, + "position": { + "x": 480.0, + "y": 137.0 + }, + "data_input_associations": [], + "data_output_associations": [], + "io_specification": null, + "script": "counter = counter + 1", + "typename": "ScriptTask", + "extensions": {} + }, + "Activity_0w5u4k4": { + "id": "loops_8", + "name": "Activity_0w5u4k4", + "description": "call something", + "manual": false, + "internal": false, + "lookahead": 2, + "inputs": [ + "increment_counter" + ], + "outputs": [ + "Gateway_over_20" + ], + "lane": null, + "documentation": null, + "position": { + "x": 620.0, + "y": 137.0 + }, + "data_input_associations": [], + "data_output_associations": [], + "io_specification": null, + "spec": "loops_ca", + "typename": "CallActivity", + "extensions": {} + }, + "Gateway_over_20": { + "id": "loops_9", + "name": "Gateway_over_20", + "description": "is > 20", + "manual": false, + "internal": false, + "lookahead": 2, + "inputs": [ + "Activity_0w5u4k4" + ], + "outputs": [ + "end_event5", + "TIMER_EVENT" + ], + "lane": null, + "documentation": null, + "position": { + "x": 755.0, + "y": 152.0 + }, + "data_input_associations": [], + "data_output_associations": [], + "io_specification": null, + "cond_task_specs": [ + { + "condition": "counter >= 20", + "task_spec": "end_event5" + }, + { + "condition": "counter < 20", + "task_spec": "TIMER_EVENT" + } + ], + "choice": null, + "default_task_spec": null, + "typename": "ExclusiveGateway", + "extensions": {} + }, + "end_event5": { + "id": "loops_10", + "name": "end_event5", + "description": null, + "manual": false, + "internal": false, + "lookahead": 2, + "inputs": [ + "Gateway_over_20" + ], + "outputs": [ + "loops.EndJoin" + ], + "lane": null, + "documentation": "### Results\nSubmission for Pre-Review was sent to the HSR-IRB on {{ sent_local_date_str }} at {{ sent_local_time_str }}.\n\nThe HSR-IRB started the Pre-Review process on {{ end_local_date_str }} at {{ end_local_time_str }} and assigned {{ irb_info.IRB_ADMINISTRATIVE_REVIEWER }} as the reviewer.\n\n### Metrics\n\n\nDays elapsed: {{days_delta }}", + "position": { + "x": 932.0, + "y": 159.0 + }, + "data_input_associations": [], + "data_output_associations": [], + "io_specification": null, + "event_definition": { + "internal": false, + "external": false, + "typename": "NoneEventDefinition" + }, + "typename": "EndEvent", + "extensions": {} + }, + "Root": { + "id": "loops_11", + "name": "Root", + "description": "", + "manual": false, + "internal": false, + "lookahead": 2, + "inputs": [], + "outputs": [], + "typename": "Simple" + }, + "return_to_TIMER_EVENT": { + "id": "loops_12", + "name": "return_to_TIMER_EVENT", + "description": "", + "manual": false, + "internal": false, + "lookahead": 2, + "inputs": [ + "Gateway_over_20", + "initialize" + ], + "outputs": [], + "destination_id": "b5200074-8196-40d3-8f83-204cf132856c", + "destination_spec_name": "TIMER_EVENT", + "typename": "LoopResetTask" + } + }, + "io_specification": null, + "data_objects": {}, + "correlation_keys": {}, + "typename": "BpmnProcessSpec" + }, + "subprocess_specs": { + "loops_ca": { + "name": "loops_ca", + "description": "loops_ca", + "file": "/home/essweine/work/sartography/code/SpiffWorkflow/tests/SpiffWorkflow/bpmn/data/too_many_loops_call_activity.bpmn", + "task_specs": { + "Start": { + "id": "loops_ca_1", + "name": "Start", + "description": "", + "manual": false, + "internal": false, + "lookahead": 2, + "inputs": [], + "outputs": [ + "StartEvent_1" + ], + "typename": "StartTask" + }, + "loops_ca.EndJoin": { + "id": "loops_ca_2", + "name": "loops_ca.EndJoin", + "description": "", + "manual": false, + "internal": false, + "lookahead": 2, + "inputs": [ + "end_event5" + ], + "outputs": [ + "End" + ], + "typename": "_EndJoin" + }, + "End": { + "id": "loops_ca_3", + "name": "End", + "description": "", + "manual": false, + "internal": false, + "lookahead": 2, + "inputs": [ + "loops_ca.EndJoin" + ], + "outputs": [], + "typename": "Simple" + }, + "StartEvent_1": { + "id": "loops_ca_4", + "name": "StartEvent_1", + "description": null, + "manual": false, + "internal": false, + "lookahead": 2, + "inputs": [ + "Start" + ], + "outputs": [ + "increment_counter" + ], + "lane": null, + "documentation": null, + "position": { + "x": 152.0, + "y": 109.0 + }, + "data_input_associations": [], + "data_output_associations": [], + "io_specification": null, + "event_definition": { + "internal": false, + "external": false, + "typename": "NoneEventDefinition" + }, + "typename": "StartEvent", + "extensions": {} + }, + "increment_counter": { + "id": "loops_ca_5", + "name": "increment_counter", + "description": "increment counter", + "manual": false, + "internal": false, + "lookahead": 2, + "inputs": [ + "StartEvent_1" + ], + "outputs": [ + "end_event5" + ], + "lane": null, + "documentation": null, + "position": { + "x": 220.0, + "y": 87.0 + }, + "data_input_associations": [], + "data_output_associations": [], + "io_specification": null, + "script": "counter2 = 1000", + "typename": "ScriptTask", + "extensions": {} + }, + "end_event5": { + "id": "loops_ca_6", + "name": "end_event5", + "description": null, + "manual": false, + "internal": false, + "lookahead": 2, + "inputs": [ + "increment_counter" + ], + "outputs": [ + "loops_ca.EndJoin" + ], + "lane": null, + "documentation": "### Results\nSubmission for Pre-Review was sent to the HSR-IRB on {{ sent_local_date_str }} at {{ sent_local_time_str }}.\n\nThe HSR-IRB started the Pre-Review process on {{ end_local_date_str }} at {{ end_local_time_str }} and assigned {{ irb_info.IRB_ADMINISTRATIVE_REVIEWER }} as the reviewer.\n\n### Metrics\n\n\nDays elapsed: {{days_delta }}", + "position": { + "x": 362.0, + "y": 109.0 + }, + "data_input_associations": [], + "data_output_associations": [], + "io_specification": null, + "event_definition": { + "internal": false, + "external": false, + "typename": "NoneEventDefinition" + }, + "typename": "EndEvent", + "extensions": {} + } + }, + "io_specification": null, + "data_objects": {}, + "correlation_keys": {}, + "typename": "BpmnProcessSpec" + } + }, + "subprocesses": {}, + "bpmn_messages": [], + "correlations": {} +} diff --git a/tests/SpiffWorkflow/bpmn/data/sub_in_loop.bpmn b/tests/SpiffWorkflow/bpmn/data/sub_in_loop.bpmn deleted file mode 100644 index ec8720e0a..000000000 --- a/tests/SpiffWorkflow/bpmn/data/sub_in_loop.bpmn +++ /dev/null @@ -1,88 +0,0 @@ - - - - - Flow_0nlj5lh - - - Flow_0nlj5lh - Flow_16vai1a - Flow_1lkecht - - - - Flow_1lkecht - Flow_1vci114 - - - - Flow_0iui938 - Flow_0ew7zdi - Flow_16vai1a - - - Flow_0ew7zdi - - - done - - - - Flow_1vci114 - Flow_0iui938 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/SpiffWorkflow/bpmn/data/sub_in_loop_call_activity.bpmn b/tests/SpiffWorkflow/bpmn/data/sub_in_loop_call_activity.bpmn deleted file mode 100644 index 2af69b3be..000000000 --- a/tests/SpiffWorkflow/bpmn/data/sub_in_loop_call_activity.bpmn +++ /dev/null @@ -1,38 +0,0 @@ - - - - - Flow_1dbtwxp - - - - Flow_1t99mly - - - - Flow_1dbtwxp - Flow_1t99mly - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/SpiffWorkflow/bpmn/data/too_many_loops.bpmn b/tests/SpiffWorkflow/bpmn/data/too_many_loops.bpmn deleted file mode 100644 index 97f663c69..000000000 --- a/tests/SpiffWorkflow/bpmn/data/too_many_loops.bpmn +++ /dev/null @@ -1,125 +0,0 @@ - - - - - Flow_1gb8wca - Flow_1d2usdq - counter = counter + 1 - - - - ### Results -Submission for Pre-Review was sent to the HSR-IRB on {{ sent_local_date_str }} at {{ sent_local_time_str }}. - -The HSR-IRB started the Pre-Review process on {{ end_local_date_str }} at {{ end_local_time_str }} and assigned {{ irb_info.IRB_ADMINISTRATIVE_REVIEWER }} as the reviewer. - -### Metrics - - -Days elapsed: {{days_delta }} - Flow_1tj9oz1 - - - - Flow_15jw6a4 - Flow_0op1a19 - Flow_1gb8wca - - "PT.01S" - - - - Flow_0mxlkif - Flow_1tj9oz1 - Flow_0op1a19 - - - counter >= 20 - - - counter < 20 - - - - Flow_0q7fkb7 - Flow_15jw6a4 - counter = 0 - - - - Flow_1d2usdq - Flow_0mxlkif - - - Flow_0q7fkb7 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/SpiffWorkflow/bpmn/data/too_many_loops_call_activity.bpmn b/tests/SpiffWorkflow/bpmn/data/too_many_loops_call_activity.bpmn deleted file mode 100644 index ee7f0479d..000000000 --- a/tests/SpiffWorkflow/bpmn/data/too_many_loops_call_activity.bpmn +++ /dev/null @@ -1,48 +0,0 @@ - - - - - Flow_175n91v - - - Flow_175n91v - Flow_1d2usdq - counter2 = 1000 - - - - ### Results -Submission for Pre-Review was sent to the HSR-IRB on {{ sent_local_date_str }} at {{ sent_local_time_str }}. - -The HSR-IRB started the Pre-Review process on {{ end_local_date_str }} at {{ end_local_time_str }} and assigned {{ irb_info.IRB_ADMINISTRATIVE_REVIEWER }} as the reviewer. - -### Metrics - - -Days elapsed: {{days_delta }} - Flow_1d2usdq - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/SpiffWorkflow/bpmn/data/too_many_loops_sub_process.bpmn b/tests/SpiffWorkflow/bpmn/data/too_many_loops_sub_process.bpmn deleted file mode 100644 index ed1461dbb..000000000 --- a/tests/SpiffWorkflow/bpmn/data/too_many_loops_sub_process.bpmn +++ /dev/null @@ -1,157 +0,0 @@ - - - - - Flow_0q7fkb7 - - - - Flow_1gb8wca - Flow_1d2usdq - counter = counter + 1 - - - - ### Results -Submission for Pre-Review was sent to the HSR-IRB on {{ sent_local_date_str }} at {{ sent_local_time_str }}. - -The HSR-IRB started the Pre-Review process on {{ end_local_date_str }} at {{ end_local_time_str }} and assigned {{ irb_info.IRB_ADMINISTRATIVE_REVIEWER }} as the reviewer. - -### Metrics - - -Days elapsed: {{days_delta }} - Flow_1tj9oz1 - - - - Flow_15jw6a4 - Flow_1ivr6d7 - Flow_1gb8wca - - "PT0.01S" - - - - Flow_1d2usdq - Flow_1tj9oz1 - Flow_0op1a19 - - - counter >= 20 - - - counter < 20 - - - - Flow_0q7fkb7 - Flow_15jw6a4 - counter = 0 -counter2 = 0 -counter3 = 0 - - - - Flow_0op1a19 - Flow_1ivr6d7 - - Flow_1fcanuu - - - - Flow_1fcanuu - Flow_04le6u5 - counter2 += 1 - - - Flow_04le6u5 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/tests/SpiffWorkflow/bpmn/events/CallActivityEscalationTest.py b/tests/SpiffWorkflow/bpmn/events/CallActivityEscalationTest.py index 6c7ea6e28..e8bae0e57 100644 --- a/tests/SpiffWorkflow/bpmn/events/CallActivityEscalationTest.py +++ b/tests/SpiffWorkflow/bpmn/events/CallActivityEscalationTest.py @@ -51,7 +51,7 @@ class CallActivityEscalationTest(BpmnWorkflowTestCase): task.set_data(should_escalate=True) self.workflow.do_engine_steps() self.save_restore() - self.workflow.complete_all() + self.workflow.run_all() self.assertEqual(True, self.workflow.is_completed()) self.assertEqual(True, 'EndEvent_specific1_noninterrupting_normal' in completed_set) @@ -81,7 +81,7 @@ class CallActivityEscalationTest(BpmnWorkflowTestCase): task.set_data(should_escalate=False) self.workflow.do_engine_steps() self.save_restore() - self.workflow.complete_all() + self.workflow.run_all() self.assertEqual(True, self.workflow.is_completed()) self.assertEqual(True, 'EndEvent_specific1_noninterrupting_normal' in completed_set) @@ -109,7 +109,7 @@ class CallActivityEscalationTest(BpmnWorkflowTestCase): track_workflow(self.spec, completed_set) self.workflow.do_engine_steps() self.save_restore() - self.workflow.complete_all() + self.workflow.run_all() self.assertEqual(True, self.workflow.is_completed()) self.assertEqual(True, 'EndEvent_specific1_noninterrupting_normal' in completed_set) diff --git a/tests/SpiffWorkflow/bpmn/events/EventBasedGatewayTest.py b/tests/SpiffWorkflow/bpmn/events/EventBasedGatewayTest.py index 529852ee2..e1565d4fd 100644 --- a/tests/SpiffWorkflow/bpmn/events/EventBasedGatewayTest.py +++ b/tests/SpiffWorkflow/bpmn/events/EventBasedGatewayTest.py @@ -28,7 +28,7 @@ class EventBasedGatewayTest(BpmnWorkflowTestCase): if save_restore: self.save_restore() self.workflow.script_engine = self.script_engine - self.assertEqual(len(waiting_tasks), 1) + self.assertEqual(len(waiting_tasks), 2) self.workflow.catch(MessageEventDefinition('message_1')) self.workflow.do_engine_steps() self.workflow.refresh_waiting_tasks() @@ -41,7 +41,7 @@ class EventBasedGatewayTest(BpmnWorkflowTestCase): self.workflow.do_engine_steps() waiting_tasks = self.workflow.get_waiting_tasks() - self.assertEqual(len(waiting_tasks), 1) + self.assertEqual(len(waiting_tasks), 2) timer_event = waiting_tasks[0].task_spec.event_definition.event_definitions[-1] self.workflow.catch(timer_event) self.workflow.refresh_waiting_tasks() diff --git a/tests/SpiffWorkflow/bpmn/events/MultipleEventsTest.py b/tests/SpiffWorkflow/bpmn/events/MultipleEventsTest.py index 86c552358..2b6cf5df0 100644 --- a/tests/SpiffWorkflow/bpmn/events/MultipleEventsTest.py +++ b/tests/SpiffWorkflow/bpmn/events/MultipleEventsTest.py @@ -33,7 +33,7 @@ class MultipleEventsTest(BpmnWorkflowTestCase): task = self.workflow.get_tasks(TaskState.READY)[0] # Move to User Task 1 - self.workflow.complete_task_from_id(task.id) + self.workflow.run_task_from_id(task.id) self.workflow.do_engine_steps() task = self.workflow.get_tasks(TaskState.READY)[0] self.assertEqual('UserTaskOne', task.get_name()) @@ -52,10 +52,10 @@ class MultipleEventsTest(BpmnWorkflowTestCase): task = self.workflow.get_tasks(TaskState.READY)[0] # Move to User Task 2 - self.workflow.complete_task_from_id(task.id) + self.workflow.run_task_from_id(task.id) self.workflow.do_engine_steps() task = self.workflow.get_tasks(TaskState.READY)[0] - self.workflow.complete_task_from_id(task.id) + self.workflow.run_task_from_id(task.id) self.workflow.do_engine_steps() task = self.workflow.get_tasks(TaskState.READY)[0] self.assertEqual('UserTaskTwo', task.get_name()) diff --git a/tests/SpiffWorkflow/bpmn/events/MultipleThrowEventTest.py b/tests/SpiffWorkflow/bpmn/events/MultipleThrowEventTest.py index 087951eb3..031a1643b 100644 --- a/tests/SpiffWorkflow/bpmn/events/MultipleThrowEventTest.py +++ b/tests/SpiffWorkflow/bpmn/events/MultipleThrowEventTest.py @@ -42,6 +42,6 @@ class MultipleThrowEventStartsEventTest(BpmnWorkflowTestCase): self.workflow.do_engine_steps() ready_tasks = self.workflow.get_ready_user_tasks() self.assertEqual(len(ready_tasks), 1) - ready_tasks[0].complete() + ready_tasks[0].run() self.workflow.do_engine_steps() self.assertEqual(self.workflow.is_completed(), True) \ No newline at end of file diff --git a/tests/SpiffWorkflow/bpmn/NITimerDurationBoundaryTest.py b/tests/SpiffWorkflow/bpmn/events/NITimerDurationBoundaryTest.py similarity index 99% rename from tests/SpiffWorkflow/bpmn/NITimerDurationBoundaryTest.py rename to tests/SpiffWorkflow/bpmn/events/NITimerDurationBoundaryTest.py index 29e0f62ad..136b3ef39 100644 --- a/tests/SpiffWorkflow/bpmn/NITimerDurationBoundaryTest.py +++ b/tests/SpiffWorkflow/bpmn/events/NITimerDurationBoundaryTest.py @@ -62,7 +62,7 @@ class NITimerDurationTest(BpmnWorkflowTestCase): task.data['delay_reason'] = 'Just Because' elif task.task_spec.name == 'Activity_Work': task.data['work_done'] = 'Yes' - task.complete() + task.run() self.workflow.refresh_waiting_tasks() self.workflow.do_engine_steps() self.assertEqual(self.workflow.is_completed(),True) diff --git a/tests/SpiffWorkflow/bpmn/events/TimerCycleTest.py b/tests/SpiffWorkflow/bpmn/events/TimerCycleTest.py index 452e71ed8..3e16830e4 100644 --- a/tests/SpiffWorkflow/bpmn/events/TimerCycleTest.py +++ b/tests/SpiffWorkflow/bpmn/events/TimerCycleTest.py @@ -55,11 +55,11 @@ class TimerCycleTest(BpmnWorkflowTestCase): time.sleep(0.05) self.workflow.refresh_waiting_tasks() events = self.workflow.waiting_events() - if loopcount == 0: - # Wait time is 0.1s, so the first time through, there should still be a waiting event + if loopcount < 2: + # Wait time is 0.1s, two child tasks are created self.assertEqual(len(events), 1) else: - # By the second iteration, both should be complete + # By the third iteration, the event should no longer be waiting self.assertEqual(len(events), 0) # Get coffee still ready diff --git a/tests/SpiffWorkflow/bpmn/events/TimerDurationBoundaryOnTaskTest.py b/tests/SpiffWorkflow/bpmn/events/TimerDurationBoundaryOnTaskTest.py index 1cd2c17b8..d7571b1e4 100644 --- a/tests/SpiffWorkflow/bpmn/events/TimerDurationBoundaryOnTaskTest.py +++ b/tests/SpiffWorkflow/bpmn/events/TimerDurationBoundaryOnTaskTest.py @@ -39,7 +39,7 @@ class TimerDurationTest(BpmnWorkflowTestCase): # Make sure the task can still be called. task = self.workflow.get_ready_user_tasks()[0] - task.complete() + task.run() self.workflow.do_engine_steps() self.assertTrue(self.workflow.is_completed()) diff --git a/tests/SpiffWorkflow/bpmn/events/TimerDurationBoundaryTest.py b/tests/SpiffWorkflow/bpmn/events/TimerDurationBoundaryTest.py index ce248dae0..f784ec4fc 100644 --- a/tests/SpiffWorkflow/bpmn/events/TimerDurationBoundaryTest.py +++ b/tests/SpiffWorkflow/bpmn/events/TimerDurationBoundaryTest.py @@ -24,7 +24,7 @@ class TimerDurationTest(BpmnWorkflowTestCase): def actual_test(self,save_restore = False): self.workflow.do_engine_steps() ready_tasks = self.workflow.get_tasks(TaskState.READY) - ready_tasks[0].complete() + ready_tasks[0].run() self.workflow.do_engine_steps() loopcount = 0 @@ -43,7 +43,7 @@ class TimerDurationTest(BpmnWorkflowTestCase): self.assertEqual(subworkflow.state, TaskState.CANCELLED) ready_tasks = self.workflow.get_ready_user_tasks() while len(ready_tasks) > 0: - ready_tasks[0].complete() + ready_tasks[0].run() ready_tasks = self.workflow.get_ready_user_tasks() self.workflow.do_engine_steps() self.assertTrue(self.workflow.is_completed()) diff --git a/tests/SpiffWorkflow/bpmn/events/TransactionSubprocssTest.py b/tests/SpiffWorkflow/bpmn/events/TransactionSubprocssTest.py index 02a8389fb..de7def175 100644 --- a/tests/SpiffWorkflow/bpmn/events/TransactionSubprocssTest.py +++ b/tests/SpiffWorkflow/bpmn/events/TransactionSubprocssTest.py @@ -19,11 +19,11 @@ class TransactionSubprocessTest(BpmnWorkflowTestCase): ready_tasks = self.workflow.get_tasks(TaskState.READY) ready_tasks[0].update_data({'value': 'asdf'}) - ready_tasks[0].complete() + ready_tasks[0].run() self.workflow.do_engine_steps() ready_tasks = self.workflow.get_tasks(TaskState.READY) ready_tasks[0].update_data({'quantity': 2}) - ready_tasks[0].complete() + ready_tasks[0].run() self.workflow.do_engine_steps() self.assertIn('value', self.workflow.last_task.data) @@ -48,7 +48,7 @@ class TransactionSubprocessTest(BpmnWorkflowTestCase): # If value == '', we cancel ready_tasks[0].update_data({'value': ''}) - ready_tasks[0].complete() + ready_tasks[0].run() self.workflow.do_engine_steps() # If the subprocess gets cancelled, verify that data set there does not persist @@ -72,13 +72,13 @@ class TransactionSubprocessTest(BpmnWorkflowTestCase): ready_tasks = self.workflow.get_tasks(TaskState.READY) ready_tasks[0].update_data({'value': 'asdf'}) - ready_tasks[0].complete() + ready_tasks[0].run() self.workflow.do_engine_steps() ready_tasks = self.workflow.get_tasks(TaskState.READY) # If quantity == 0, we throw an error with no error code ready_tasks[0].update_data({'quantity': 0}) - ready_tasks[0].complete() + ready_tasks[0].run() self.workflow.do_engine_steps() # We formerly checked that subprocess data does not persist, but I think it should persist @@ -103,13 +103,13 @@ class TransactionSubprocessTest(BpmnWorkflowTestCase): ready_tasks = self.workflow.get_tasks(TaskState.READY) ready_tasks[0].update_data({'value': 'asdf'}) - ready_tasks[0].complete() + ready_tasks[0].run() self.workflow.do_engine_steps() ready_tasks = self.workflow.get_tasks(TaskState.READY) # If quantity < 0, we throw 'Error 1' ready_tasks[0].update_data({'quantity': -1}) - ready_tasks[0].complete() + ready_tasks[0].run() self.workflow.do_engine_steps() # The cancel boundary event should be cancelled diff --git a/tests/SpiffWorkflow/bpmn/serializer/BpmnWorkflowSerializerTest.py b/tests/SpiffWorkflow/bpmn/serializer/BpmnWorkflowSerializerTest.py index 88612867f..e2b92ab02 100644 --- a/tests/SpiffWorkflow/bpmn/serializer/BpmnWorkflowSerializerTest.py +++ b/tests/SpiffWorkflow/bpmn/serializer/BpmnWorkflowSerializerTest.py @@ -142,7 +142,7 @@ class BpmnWorkflowSerializerTest(BaseTestCase): def test_serialize_workflow_where_script_task_includes_function(self): self.workflow.do_engine_steps() ready_tasks = self.workflow.get_ready_user_tasks() - ready_tasks[0].complete() + ready_tasks[0].run() self.workflow.do_engine_steps() results = self.serializer.serialize_json(self.workflow) assert self.workflow.is_completed() @@ -161,7 +161,7 @@ class BpmnWorkflowSerializerTest(BaseTestCase): self.assertEqual(w1.data, w2.data) self.assertEqual(w1.name, w2.name) for task in w1.get_ready_user_tasks(): - w2_task = w2.get_task(task.id) + w2_task = w2.get_task_from_id(task.id) self.assertIsNotNone(w2_task) self.assertEqual(task.data, w2_task.data) diff --git a/tests/SpiffWorkflow/bpmn/serializer/VersionMigrationTest.py b/tests/SpiffWorkflow/bpmn/serializer/VersionMigrationTest.py index 2b169f149..393b2d76d 100644 --- a/tests/SpiffWorkflow/bpmn/serializer/VersionMigrationTest.py +++ b/tests/SpiffWorkflow/bpmn/serializer/VersionMigrationTest.py @@ -16,11 +16,12 @@ class Version_1_0_Test(BaseTestCase): def test_convert_subprocess(self): # The serialization used here comes from NestedSubprocessTest saved at line 25 with version 1.0 fn = os.path.join(self.DATA_DIR, 'serialization', 'v1.0.json') - wf = self.serializer.deserialize_json(open(fn).read()) + with open(fn) as fh: + wf = self.serializer.deserialize_json(fh.read()) # We should be able to finish the workflow from this point ready_tasks = wf.get_tasks(TaskState.READY) self.assertEqual('Action3', ready_tasks[0].task_spec.description) - ready_tasks[0].complete() + ready_tasks[0].run() wf.do_engine_steps() self.assertEqual(True, wf.is_completed()) @@ -49,7 +50,7 @@ class Version_1_1_Test(BaseTestCase): self.assertEqual(len(task.task_spec.cond_task_specs), 2) ready_task = wf.get_ready_user_tasks()[0] ready_task.data['NeedClarification'] = 'Yes' - ready_task.complete() + ready_task.run() wf.do_engine_steps() ready_task = wf.get_ready_user_tasks()[0] self.assertEqual(ready_task.task_spec.name, 'Activity_A2') @@ -58,4 +59,15 @@ class Version_1_1_Test(BaseTestCase): fn = os.path.join(self.DATA_DIR, 'serialization', 'v1.1-multi.json') with self.assertRaises(VersionMigrationError) as ctx: wf = self.serializer.deserialize_json(open(fn).read()) - self.assertEqual(ctx.exception.message, "This workflow cannot be migrated because it contains MultiInstance Tasks") \ No newline at end of file + self.assertEqual(ctx.exception.message, "This workflow cannot be migrated because it contains MultiInstance Tasks") + + def test_remove_loop_reset(self): + fn = os.path.join(self.DATA_DIR, 'serialization', 'v1.1-loop-reset.json') + wf = self.serializer.deserialize_json(open(fn).read()) + # Allow 3 seconds max to allow this test to complete (there are 20 loops with a 0.1s timer) + end = time.time() + 3 + while not wf.is_completed() and time.time() < end: + wf.do_engine_steps() + wf.refresh_waiting_tasks() + self.assertTrue(wf.is_completed()) + self.assertEqual(wf.last_task.data['counter'], 20) diff --git a/tests/SpiffWorkflow/camunda/CallActivityMessageTest.py b/tests/SpiffWorkflow/camunda/CallActivityMessageTest.py index a7d9d6c54..b5177c78a 100644 --- a/tests/SpiffWorkflow/camunda/CallActivityMessageTest.py +++ b/tests/SpiffWorkflow/camunda/CallActivityMessageTest.py @@ -39,7 +39,7 @@ class CallActivityMessageTest(BaseTestCase): current_task = ready_tasks[0] self.assertEqual(current_task.task_spec.name,step[0]) current_task.update_data(step[1]) - current_task.complete() + current_task.run() self.workflow.do_engine_steps() self.workflow.refresh_waiting_tasks() if save_restore: self.save_restore() diff --git a/tests/SpiffWorkflow/camunda/ClashingNameTest.py b/tests/SpiffWorkflow/camunda/ClashingNameTest.py index b078ddf3e..a8d68cdcc 100644 --- a/tests/SpiffWorkflow/camunda/ClashingNameTest.py +++ b/tests/SpiffWorkflow/camunda/ClashingNameTest.py @@ -52,7 +52,7 @@ class ClashingNameTest(BaseTestCase): firsttaskid = task.id self.assertEqual(step['taskname'], task.task_spec.name) task.update_data({step['formvar']: step['answer']}) - self.workflow.complete_task_from_id(task.id) + self.workflow.run_task_from_id(task.id) self.workflow.do_engine_steps() if save_restore: self.save_restore() @@ -68,7 +68,7 @@ class ClashingNameTest(BaseTestCase): task = self.workflow.get_ready_user_tasks()[0] self.assertEqual(step['taskname'], task.task_spec.name) task.update_data({step['formvar']: step['answer']}) - self.workflow.complete_task_from_id(task.id) + self.workflow.run_task_from_id(task.id) self.workflow.do_engine_steps() if save_restore: self.save_restore() diff --git a/tests/SpiffWorkflow/camunda/DMNCustomScriptTest.py b/tests/SpiffWorkflow/camunda/DMNCustomScriptTest.py index 23d256346..21f03f756 100644 --- a/tests/SpiffWorkflow/camunda/DMNCustomScriptTest.py +++ b/tests/SpiffWorkflow/camunda/DMNCustomScriptTest.py @@ -29,7 +29,7 @@ class DMNCustomScriptTest(BaseTestCase): def complete_manual_task(self): manual_task = self.workflow.get_tasks_from_spec_name('manual_task')[0] - self.workflow.complete_task_from_id(manual_task.id) + self.workflow.run_task_from_id(manual_task.id) self.workflow.do_engine_steps() def testDmnHappy(self): diff --git a/tests/SpiffWorkflow/camunda/DMNDictTest.py b/tests/SpiffWorkflow/camunda/DMNDictTest.py index 053614b49..38cf09bac 100644 --- a/tests/SpiffWorkflow/camunda/DMNDictTest.py +++ b/tests/SpiffWorkflow/camunda/DMNDictTest.py @@ -16,7 +16,7 @@ class DMNDictTest(BaseTestCase): self.workflow = BpmnWorkflow(self.spec) self.workflow.do_engine_steps() x = self.workflow.get_ready_user_tasks() - self.workflow.complete_task_from_id(x[0].id) + self.workflow.run_task_from_id(x[0].id) self.workflow.do_engine_steps() self.assertDictEqual(self.workflow.last_task.data, self.expectedResult) @@ -25,7 +25,7 @@ class DMNDictTest(BaseTestCase): self.workflow.do_engine_steps() self.save_restore() x = self.workflow.get_ready_user_tasks() - self.workflow.complete_task_from_id(x[0].id) + self.workflow.run_task_from_id(x[0].id) self.workflow.do_engine_steps() self.save_restore() self.assertDictEqual(self.workflow.last_task.data, self.expectedResult) diff --git a/tests/SpiffWorkflow/camunda/ExternalMessageBoundaryEventTest.py b/tests/SpiffWorkflow/camunda/ExternalMessageBoundaryEventTest.py index e7d5d13c5..74b5dd99d 100644 --- a/tests/SpiffWorkflow/camunda/ExternalMessageBoundaryEventTest.py +++ b/tests/SpiffWorkflow/camunda/ExternalMessageBoundaryEventTest.py @@ -41,7 +41,7 @@ class ExternalMessageBoundaryTest(BaseTestCase): self.assertEqual(True, ready_tasks[1].data['caughtinterrupt']) self.assertEqual('Meaningless User Task',ready_tasks[0].task_spec.description) self.assertEqual(False, ready_tasks[0].data['caughtinterrupt']) - ready_tasks[1].complete() + ready_tasks[1].run() self.workflow.do_engine_steps() # what I think is going on here is that when we hit the reset, it is updating the # last_task and appending the data to whatever happened there, so it would make sense that @@ -52,7 +52,7 @@ class ExternalMessageBoundaryTest(BaseTestCase): # The user activity was cancelled and we should continue from the boundary event self.assertEqual(1, len(ready_tasks),'Expected to have two ready tasks') event = self.workflow.get_tasks_from_spec_name('Event_19detfv')[0] - event.complete() + event.run() self.assertEqual('SomethingDrastic', event.data['reset_var']) self.assertEqual(False, event.data['caughtinterrupt']) diff --git a/tests/SpiffWorkflow/camunda/InvalidBusinessRuleTaskParserTest.py b/tests/SpiffWorkflow/camunda/InvalidBusinessRuleTaskParserTest.py index 757767d68..a00ed8599 100644 --- a/tests/SpiffWorkflow/camunda/InvalidBusinessRuleTaskParserTest.py +++ b/tests/SpiffWorkflow/camunda/InvalidBusinessRuleTaskParserTest.py @@ -31,7 +31,7 @@ class BusinessRuleTaskParserTest(BaseTestCase): self.assertTrue(True, "An error was raised..") self.assertEqual("InvalidDecisionTaskId", we.task_spec.name) self.maxDiff = 1000 - self.assertEquals("Error evaluating expression 'spam= 1'. Rule failed on row 1. Business Rule Task 'Invalid Decision'.", str(we)) + self.assertEqual("Error evaluating expression 'spam= 1'. Rule failed on row 1. Business Rule Task 'Invalid Decision'.", str(we)) def suite(): return unittest.TestLoader().loadTestsFromTestCase(BusinessRuleTaskParserTest) diff --git a/tests/SpiffWorkflow/camunda/MessageBoundaryEventTest.py b/tests/SpiffWorkflow/camunda/MessageBoundaryEventTest.py index 8c0bf3c9c..2b67be61c 100644 --- a/tests/SpiffWorkflow/camunda/MessageBoundaryEventTest.py +++ b/tests/SpiffWorkflow/camunda/MessageBoundaryEventTest.py @@ -41,7 +41,7 @@ class MessageBoundaryTest(BaseTestCase): if task.task_spec.name == step[0]: task.update_data(step[1]) - self.workflow.complete_task_from_id(task.id) + self.workflow.run_task_from_id(task.id) self.workflow.do_engine_steps() time.sleep(.01) self.workflow.refresh_waiting_tasks() diff --git a/tests/SpiffWorkflow/camunda/MultiInstanceDMNTest.py b/tests/SpiffWorkflow/camunda/MultiInstanceDMNTest.py index d0893c0e5..c7de85276 100644 --- a/tests/SpiffWorkflow/camunda/MultiInstanceDMNTest.py +++ b/tests/SpiffWorkflow/camunda/MultiInstanceDMNTest.py @@ -23,10 +23,10 @@ class MultiInstanceDMNTest(BaseTestCase): self.save_restore() self.workflow.do_engine_steps() - self.workflow.complete_next() + self.workflow.run_next() self.save_restore() self.workflow.do_engine_steps() - self.workflow.complete_next() + self.workflow.run_next() self.save_restore() self.workflow.do_engine_steps() self.save_restore() diff --git a/tests/SpiffWorkflow/camunda/NIMessageBoundaryTest.py b/tests/SpiffWorkflow/camunda/NIMessageBoundaryTest.py index a3c79fbba..cd5120da0 100644 --- a/tests/SpiffWorkflow/camunda/NIMessageBoundaryTest.py +++ b/tests/SpiffWorkflow/camunda/NIMessageBoundaryTest.py @@ -29,7 +29,7 @@ class NIMessageBoundaryTest(BaseTestCase): ready_tasks = self.workflow.get_tasks(TaskState.READY) self.assertEqual(1, len(ready_tasks)) - self.workflow.complete_task_from_id(ready_tasks[0].id) + self.workflow.run_task_from_id(ready_tasks[0].id) self.workflow.do_engine_steps() # first we run through a couple of steps where we answer No to each @@ -45,7 +45,7 @@ class NIMessageBoundaryTest(BaseTestCase): 'We got a ready task that we did not expect - %s'%( task.task_spec.name)) task.data[response[0]] = response[1] - self.workflow.complete_task_from_id(task.id) + self.workflow.run_task_from_id(task.id) self.workflow.do_engine_steps() # if we have a list of tasks - that list becomes invalid # after we do a save restore, so I'm completing the list @@ -66,7 +66,7 @@ class NIMessageBoundaryTest(BaseTestCase): 'We got a ready task that we did not expect - %s'%( task.task_spec.name)) task.data[response[0]] = response[1] - self.workflow.complete_task_from_id(task.id) + self.workflow.run_task_from_id(task.id) self.workflow.do_engine_steps() if save_restore: self.save_restore() @@ -75,14 +75,14 @@ class NIMessageBoundaryTest(BaseTestCase): task = ready_tasks[0] self.assertEqual(task.task_spec.name,'Activity_DoWork') task.data['work_done'] = 'Yes' - self.workflow.complete_task_from_id(task.id) + self.workflow.run_task_from_id(task.id) self.workflow.do_engine_steps() ready_tasks = self.workflow.get_tasks(TaskState.READY) self.assertEqual(len(ready_tasks), 1) task = ready_tasks[0] self.assertEqual(task.task_spec.name, 'Activity_WorkCompleted') task.data['work_completed'] = 'Lots of Stuff' - self.workflow.complete_task_from_id(task.id) + self.workflow.run_task_from_id(task.id) self.workflow.do_engine_steps() self.assertEqual(self.workflow.is_completed(),True) self.assertEqual(self.workflow.last_task.data,{'Event_InterruptBoundary_Response': 'Youre late!', diff --git a/tests/SpiffWorkflow/camunda/ParseMultiInstanceTest.py b/tests/SpiffWorkflow/camunda/ParseMultiInstanceTest.py index 9f612a6d8..37f170ebf 100644 --- a/tests/SpiffWorkflow/camunda/ParseMultiInstanceTest.py +++ b/tests/SpiffWorkflow/camunda/ParseMultiInstanceTest.py @@ -32,7 +32,7 @@ class ParseMultiInstanceTest(BaseTestCase): self.assertEqual(len(ready_tasks), 3) for task in ready_tasks: task.data['output_item'] = task.data['output_item'] * 2 - task.complete() + task.run() self.workflow.do_engine_steps() self.assertTrue(self.workflow.is_completed()) @@ -58,7 +58,7 @@ class ParseMultiInstanceTest(BaseTestCase): self.assertEqual(len(ready_tasks), 3) for task in ready_tasks: task.data['output_item'] = task.data['output_item'] * 2 - task.complete() + task.run() self.workflow.do_engine_steps() self.assertTrue(self.workflow.is_completed()) @@ -84,7 +84,7 @@ class ParseMultiInstanceTest(BaseTestCase): self.assertEqual(len(ready_tasks), 3) for task in ready_tasks: task.data['input_item'] = task.data['input_item'] * 2 - task.complete() + task.run() self.workflow.do_engine_steps() self.assertTrue(self.workflow.is_completed()) diff --git a/tests/SpiffWorkflow/camunda/ResetTokenNestedParallelTest.py b/tests/SpiffWorkflow/camunda/ResetTokenNestedParallelTest.py index 698eac7eb..d8c535cab 100644 --- a/tests/SpiffWorkflow/camunda/ResetTokenNestedParallelTest.py +++ b/tests/SpiffWorkflow/camunda/ResetTokenNestedParallelTest.py @@ -73,7 +73,7 @@ class ResetTokenTestNestedParallel(BaseTestCase): firsttaskid = task.id self.assertEqual(step['taskname'], task.task_spec.name) task.update_data({step['formvar']: step['answer']}) - self.workflow.complete_task_from_id(task.id) + self.workflow.run_task_from_id(task.id) self.workflow.do_engine_steps() if save_restore: self.save_restore() self.workflow.reset_task_from_id(firsttaskid) @@ -91,7 +91,7 @@ class ResetTokenTestNestedParallel(BaseTestCase): task = self.workflow.get_ready_user_tasks()[0] self.assertEqual(step['taskname'], task.task_spec.name) task.update_data({step['formvar']: step['answer']}) - self.workflow.complete_task_from_id(task.id) + self.workflow.run_task_from_id(task.id) self.workflow.do_engine_steps() if save_restore: self.save_restore() notworking = self.workflow.get_ready_user_tasks() @@ -148,7 +148,7 @@ class ResetTokenTestNestedParallel(BaseTestCase): firsttaskid = task.id self.assertEqual(step['taskname'], task.task_spec.name) task.update_data({step['formvar']: step['answer']}) - self.workflow.complete_task_from_id(task.id) + self.workflow.run_task_from_id(task.id) self.workflow.do_engine_steps() if save_restore: self.save_restore() @@ -182,7 +182,7 @@ class ResetTokenTestNestedParallel(BaseTestCase): task = self.workflow.get_ready_user_tasks()[0] self.assertEqual(step['taskname'], task.task_spec.name) task.update_data({step['formvar']: step['answer']}) - self.workflow.complete_task_from_id(task.id) + self.workflow.run_task_from_id(task.id) self.workflow.do_engine_steps() if save_restore: self.save_restore() diff --git a/tests/SpiffWorkflow/camunda/ResetTokenParallelMatrixTest.py b/tests/SpiffWorkflow/camunda/ResetTokenParallelMatrixTest.py index a5cb0af0b..7b90e7f86 100644 --- a/tests/SpiffWorkflow/camunda/ResetTokenParallelMatrixTest.py +++ b/tests/SpiffWorkflow/camunda/ResetTokenParallelMatrixTest.py @@ -76,7 +76,7 @@ class ResetTokenTestParallelMatrix(BaseTestCase): firsttaskid = task.id self.assertEqual(step['taskname'], task.task_spec.name) task.update_data({step['formvar']: step['answer']}) - self.workflow.complete_task_from_id(task.id) + self.workflow.run_task_from_id(task.id) self.workflow.do_engine_steps() if save_restore: self.save_restore() @@ -96,7 +96,7 @@ class ResetTokenTestParallelMatrix(BaseTestCase): task = self.workflow.get_ready_user_tasks()[0] self.assertEqual(step['taskname'], task.task_spec.name) task.update_data({step['formvar']: step['answer']}) - self.workflow.complete_task_from_id(task.id) + self.workflow.run_task_from_id(task.id) self.workflow.do_engine_steps() if save_restore: self.save_restore() @@ -154,7 +154,7 @@ class ResetTokenTestParallelMatrix(BaseTestCase): firsttaskid = task.id self.assertEqual(step['taskname'], task.task_spec.name) task.update_data({step['formvar']: step['answer']}) - self.workflow.complete_task_from_id(task.id) + self.workflow.run_task_from_id(task.id) self.workflow.do_engine_steps() if save_restore: self.save_restore() @@ -190,7 +190,7 @@ class ResetTokenTestParallelMatrix(BaseTestCase): task = self.workflow.get_ready_user_tasks()[0] self.assertEqual(step['taskname'], task.task_spec.name) task.update_data({step['formvar']: step['answer']}) - self.workflow.complete_task_from_id(task.id) + self.workflow.run_task_from_id(task.id) self.workflow.do_engine_steps() if save_restore: self.save_restore() diff --git a/tests/SpiffWorkflow/camunda/ResetTokenParallelTaskCountTest.py b/tests/SpiffWorkflow/camunda/ResetTokenParallelTaskCountTest.py index 04eb7cf97..bce088cb0 100644 --- a/tests/SpiffWorkflow/camunda/ResetTokenParallelTaskCountTest.py +++ b/tests/SpiffWorkflow/camunda/ResetTokenParallelTaskCountTest.py @@ -29,22 +29,19 @@ class ResetTokenParallelTaskCountTest(BaseTestCase): # number of tasks self.workflow.do_engine_steps() - self.assertEquals(total, len(self.workflow.get_tasks())) + self.assertEqual(total, len(self.workflow.get_tasks())) # Tell the exclusive gateway to skip the parallel tasks section. # We should still have the same number of tasks. data = {'skipParallel': True} task = self.workflow.get_ready_user_tasks()[0] task.data = data - self.workflow.complete_task_from_id(task.id) + self.workflow.run_task_from_id(task.id) self.assertEquals(total, len(self.workflow.get_tasks())) # Reset the token to the first user task. # We should still have the same number of tasks. - self.workflow.task_tree.dump() task.reset_token({}, reset_data=True) - print('=-----') - self.workflow.task_tree.dump() self.assertEquals(total, len(self.workflow.get_tasks())) self.assertEquals(1, len(self.workflow.get_ready_user_tasks())) diff --git a/tests/SpiffWorkflow/camunda/ResetTokenSubWorkflowTest.py b/tests/SpiffWorkflow/camunda/ResetTokenSubWorkflowTest.py index f9236c88f..f8a288e00 100644 --- a/tests/SpiffWorkflow/camunda/ResetTokenSubWorkflowTest.py +++ b/tests/SpiffWorkflow/camunda/ResetTokenSubWorkflowTest.py @@ -51,7 +51,7 @@ class ResetTokenTestSubProcess(BaseTestCase): firsttaskid = task.id self.assertEqual(step['taskname'], task.task_spec.name) task.update_data({step['formvar']: step['answer']}) - self.workflow.complete_task_from_id(task.id) + self.workflow.run_task_from_id(task.id) self.workflow.do_engine_steps() if save_restore: self.save_restore() @@ -75,7 +75,7 @@ class ResetTokenTestSubProcess(BaseTestCase): task = self.workflow.get_ready_user_tasks()[0] self.assertEqual(step['taskname'], task.task_spec.name) task.update_data({step['formvar']: step['answer']}) - self.workflow.complete_task_from_id(task.id) + self.workflow.run_task_from_id(task.id) self.workflow.do_engine_steps() if save_restore: self.save_restore() @@ -128,7 +128,7 @@ class ResetTokenTestSubProcess(BaseTestCase): firsttaskid = task.id self.assertEqual(step['taskname'], task.task_spec.name) task.update_data({step['formvar']: step['answer']}) - self.workflow.complete_task_from_id(task.id) + self.workflow.run_task_from_id(task.id) self.workflow.do_engine_steps() if save_restore: self.save_restore() @@ -164,7 +164,7 @@ class ResetTokenTestSubProcess(BaseTestCase): task = self.workflow.get_ready_user_tasks()[0] self.assertEqual(step['taskname'], task.task_spec.name) task.update_data({step['formvar']: step['answer']}) - self.workflow.complete_task_from_id(task.id) + self.workflow.run_task_from_id(task.id) self.workflow.do_engine_steps() if save_restore: self.save_restore() diff --git a/tests/SpiffWorkflow/camunda/ResetTokenTest.py b/tests/SpiffWorkflow/camunda/ResetTokenTest.py index 555e2068c..495e940e7 100644 --- a/tests/SpiffWorkflow/camunda/ResetTokenTest.py +++ b/tests/SpiffWorkflow/camunda/ResetTokenTest.py @@ -54,7 +54,7 @@ class ResetTokenTest(BaseTestCase): firsttaskid = task.id self.assertEqual(step['taskname'], task.task_spec.name) task.update_data({step['formvar']: step['answer']}) - self.workflow.complete_task_from_id(task.id) + self.workflow.run_task_from_id(task.id) self.workflow.do_engine_steps() if save_restore: self.save_restore() @@ -70,7 +70,7 @@ class ResetTokenTest(BaseTestCase): task = self.workflow.get_ready_user_tasks()[0] self.assertEqual(step['taskname'], task.task_spec.name) task.update_data({step['formvar']: step['answer']}) - self.workflow.complete_task_from_id(task.id) + self.workflow.run_task_from_id(task.id) self.workflow.do_engine_steps() if save_restore: self.save_restore() diff --git a/tests/SpiffWorkflow/camunda/StartMessageEventTest.py b/tests/SpiffWorkflow/camunda/StartMessageEventTest.py index dd6200f53..07e4bf0f6 100644 --- a/tests/SpiffWorkflow/camunda/StartMessageEventTest.py +++ b/tests/SpiffWorkflow/camunda/StartMessageEventTest.py @@ -48,7 +48,7 @@ class StartMessageTest(BaseTestCase): current_task = ready_tasks[0] self.assertEqual(current_task.task_spec.name,step[0]) current_task.update_data(step[1]) - current_task.complete() + current_task.run() self.workflow.do_engine_steps() self.workflow.refresh_waiting_tasks() if save_restore: diff --git a/tests/SpiffWorkflow/camunda/SubWorkflowTest.py b/tests/SpiffWorkflow/camunda/SubWorkflowTest.py index 75331022e..97aed8de8 100644 --- a/tests/SpiffWorkflow/camunda/SubWorkflowTest.py +++ b/tests/SpiffWorkflow/camunda/SubWorkflowTest.py @@ -31,7 +31,7 @@ class SubWorkflowTest(BaseTestCase): task = self.workflow.get_ready_user_tasks()[0] self.assertEqual("Activity_"+answer, task.task_spec.name) task.update_data({"Field"+answer: answer}) - self.workflow.complete_task_from_id(task.id) + self.workflow.run_task_from_id(task.id) self.workflow.do_engine_steps() if save_restore: self.save_restore() diff --git a/tests/SpiffWorkflow/camunda/UserTaskParserTest.py b/tests/SpiffWorkflow/camunda/UserTaskParserTest.py index 56c4f4747..d69dcdcc6 100644 --- a/tests/SpiffWorkflow/camunda/UserTaskParserTest.py +++ b/tests/SpiffWorkflow/camunda/UserTaskParserTest.py @@ -16,22 +16,22 @@ class UserTaskParserTest(BaseTestCase): def testGetEnumField(self): form = self.spec.task_specs['Task_User_Select_Type'].form - self.assertEquals("Fact", form.key) - self.assertEquals(1, len(form.fields)) - self.assertEquals("type", form.fields[0].id) - self.assertEquals(3, len(form.fields[0].options)) + self.assertEqual("Fact", form.key) + self.assertEqual(1, len(form.fields)) + self.assertEqual("type", form.fields[0].id) + self.assertEqual(3, len(form.fields[0].options)) def testGetFieldProperties(self): form = self.spec.task_specs['Task_User_Select_Type'].form - self.assertEquals(1, len(form.fields[0].properties)) - self.assertEquals('description', form.fields[0].properties[0].id) - self.assertEquals('Choose from the list of available types of random facts', form.fields[0].properties[0].value) + self.assertEqual(1, len(form.fields[0].properties)) + self.assertEqual('description', form.fields[0].properties[0].id) + self.assertEqual('Choose from the list of available types of random facts', form.fields[0].properties[0].value) def testGetFieldValidation(self): form = self.spec.task_specs['Task_User_Select_Type'].form - self.assertEquals(1, len(form.fields[0].validation)) - self.assertEquals('maxlength', form.fields[0].validation[0].name) - self.assertEquals('25', form.fields[0].validation[0].config) + self.assertEqual(1, len(form.fields[0].validation)) + self.assertEqual('maxlength', form.fields[0].validation[0].name) + self.assertEqual('25', form.fields[0].validation[0].config) def testNoFormDoesNotBombOut(self): self.load_workflow_spec('no_form.bpmn', 'no_form') diff --git a/tests/SpiffWorkflow/camunda/specs/UserTaskSpecTest.py b/tests/SpiffWorkflow/camunda/specs/UserTaskSpecTest.py index b24f1c373..74726f8c4 100644 --- a/tests/SpiffWorkflow/camunda/specs/UserTaskSpecTest.py +++ b/tests/SpiffWorkflow/camunda/specs/UserTaskSpecTest.py @@ -20,12 +20,11 @@ class UserTaskSpecTest(unittest.TestCase): self.user_spec = self.create_instance() def testConstructor(self): - self.assertEquals(self.user_spec.name, 'userTask') + self.assertEqual(self.user_spec.name, 'userTask') self.assertEqual(self.user_spec.data, {}) self.assertEqual(self.user_spec.defines, {}) self.assertEqual(self.user_spec.pre_assign, []) self.assertEqual(self.user_spec.post_assign, []) - self.assertEqual(self.user_spec.locks, []) def test_set_form(self): self.assertEqual(self.form, self.user_spec.form) diff --git a/tests/SpiffWorkflow/core/ControlFlowPatternTest.py b/tests/SpiffWorkflow/core/ControlFlowPatternTest.py new file mode 100644 index 000000000..52286ae2b --- /dev/null +++ b/tests/SpiffWorkflow/core/ControlFlowPatternTest.py @@ -0,0 +1,185 @@ +# -*- coding: utf-8 -*- +from unittest import TestCase +from .pattern_base import WorkflowPatternTestCase + +# This combines the old pattern tests with the old serializer tests, creating one test per pattern +# that tests the tasks in it can be serialized with our serializers and the workflows run with the +# expected output. This format is a little annoying (inheriting from two classes with the actual +# work being done in the secondary class); however, this is the most concise thing I could manage. +# +# There were also a fair amount of never-used options in those tests, so the tests in the base case +# are a lot simpler than the ones they replaced. + +class SequenceTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/sequence') + +class ParallelSplitTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/parallel_split') + +class SynchronizationTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/synchronization') + +class ExclusiveChoiceTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/exclusive_choice') + +class SimpleMergeTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/simple_merge') + +class MultiChoiceTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/multi_choice') + +class StructuredSynchronizingMergeTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/structured_synchronizing_merge') + +class MultiMergeTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/multi_merge') + +class StructuredDiscriminatorTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/structured_discriminator') + +class BlockingDiscriminatorTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/blocking_discriminator') + +class CacncellingDiscriminatorTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/cancelling_discriminator') + +class StructuredPartialJoin(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/structured_partial_join') + +class BlockingPartialJoin(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/blocking_partial_join') + +class CancellingPartialJoin(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/cancelling_partial_join') + +class GeneralizedAndJoin(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/generalized_and_join') + +class LocalSynchronizingMergeTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/acyclic_synchronizing_merge') + +class GeneralSynchronizingMergeTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/general_synchronizing_merge') + +class ThreadMergeTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/thread_merge') + +class ThreadSplitTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/thread_split') + +class MultiInstanceWithoutSynchonizationTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/multi_instance_without_synch') + +class MultiInstanceWithDesignTimeKnowledgeTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/multi_instance_with_a_priori_design_time_knowledge') + +class MultiInstanceWithRunTimeKnowledgeTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/multi_instance_with_a_priori_run_time_knowledge') + +class StaticPartialJoinMultiInstanceTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/static_partial_join_for_multi_instance') + +class CancellingPartialJoinMultiInstanceTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/cancelling_partial_join_for_multi_instance') + +class DynamicPartialJoinMultiInstanceTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/dynamic_partial_join_for_multi_instance') + +class DeferredChoiceTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/deferred_choice') + +class InterleavedParallelRoutingTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/interleaved_parallel_routing') + +class MilestoneTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/milestone') + +class CriticalSectionTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/critical_section') + +class InterleavedRoutingTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/interleaved_routing') + +class CancelTaskTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/cancel_task') + +class CancelCaseTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/cancel_case') + +class CancelRegionTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/cancel_region') + +class CancelMultiInstanceTaskTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/cancel_multi_instance_task') + +class CompleteMultiInstanceTaskTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/complete_multiple_instance_activity') + +class ArbitraryCyclesTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/arbitrary_cycles') + +class RecursionTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/recursion') + + # I am disabling this test becuse I have wasted an entire day trying to make it pass + # The workflow completes and the task tree is as expected, but the subworkflow tasks + # no longer appear in the taken path. This is because they are connected to the subworkflow + # in on_reached_cb, which now occurs after they are executed. + # Moving subworkflow creation to predict would likely fix the problem, but there are problems + # with prediction that also need to be fixed as well. + + #def test_run_workflow(self): + # pass + +class ImplicitTerminationTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/implicit_termination') + +class ExplicitTerminationTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/explicit_termination') + +class TransientTriggerTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/transient_trigger') + +class PersistentTriggerTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('control-flow/persistent_trigger') diff --git a/tests/SpiffWorkflow/core/DataPatternTest.py b/tests/SpiffWorkflow/core/DataPatternTest.py new file mode 100644 index 000000000..2561afb45 --- /dev/null +++ b/tests/SpiffWorkflow/core/DataPatternTest.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +from unittest import TestCase +from .pattern_base import WorkflowPatternTestCase + + +class TaskDataTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('data/task_data') + +class BlockDataTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('data/block_data') + +class TaskToTaskTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('data/task_to_task') + +class BlockToSubworkflowTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('data/block_to_subworkflow') + +class SubworkflowTOBlockTest(TestCase, WorkflowPatternTestCase): + def setUp(self): + self.load_from_xml('data/subworkflow_to_block') \ No newline at end of file diff --git a/tests/SpiffWorkflow/ExecuteProcessMock.py b/tests/SpiffWorkflow/core/ExecuteProcessMock.py similarity index 100% rename from tests/SpiffWorkflow/ExecuteProcessMock.py rename to tests/SpiffWorkflow/core/ExecuteProcessMock.py diff --git a/tests/SpiffWorkflow/PersistSmallWorkflowTest.py b/tests/SpiffWorkflow/core/PersistSmallWorkflowTest.py similarity index 92% rename from tests/SpiffWorkflow/PersistSmallWorkflowTest.py rename to tests/SpiffWorkflow/core/PersistSmallWorkflowTest.py index b554be189..2b2b03c02 100644 --- a/tests/SpiffWorkflow/PersistSmallWorkflowTest.py +++ b/tests/SpiffWorkflow/core/PersistSmallWorkflowTest.py @@ -1,9 +1,5 @@ # -*- coding: utf-8 -*- - -import sys import unittest -import os.path -sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..')) from SpiffWorkflow.workflow import Workflow from SpiffWorkflow.specs.Join import Join @@ -51,15 +47,15 @@ class PersistSmallWorkflowTest(unittest.TestCase): tasks = workflow.get_tasks(TaskState.READY) task_start = tasks[0] - workflow.complete_task_from_id(task_start.id) + workflow.run_task_from_id(task_start.id) tasks = workflow.get_tasks(TaskState.READY) multichoice = tasks[0] - workflow.complete_task_from_id(multichoice.id) + workflow.run_task_from_id(multichoice.id) tasks = workflow.get_tasks(TaskState.READY) task_a1 = tasks[0] - workflow.complete_task_from_id(task_a1.id) + workflow.run_task_from_id(task_a1.id) return workflow def testDictionarySerializer(self): @@ -104,7 +100,7 @@ class PersistSmallWorkflowTest(unittest.TestCase): """ old_workflow = self.workflow - old_workflow.complete_next() + old_workflow.run_next() self.assertEqual('task_a2', old_workflow.last_task.get_name()) serializer = DictionarySerializer() serialized_workflow = old_workflow.serialize(serializer) @@ -112,7 +108,7 @@ class PersistSmallWorkflowTest(unittest.TestCase): serializer = DictionarySerializer() new_workflow = Workflow.deserialize(serializer, serialized_workflow) self.assertEqual('task_a2', old_workflow.last_task.get_name()) - new_workflow.complete_all() + new_workflow.run_all() self.assertEqual('task_a2', old_workflow.last_task.get_name()) diff --git a/tests/SpiffWorkflow/TaskTest.py b/tests/SpiffWorkflow/core/TaskTest.py similarity index 97% rename from tests/SpiffWorkflow/TaskTest.py rename to tests/SpiffWorkflow/core/TaskTest.py index 77e28df61..9f5e0d120 100644 --- a/tests/SpiffWorkflow/TaskTest.py +++ b/tests/SpiffWorkflow/core/TaskTest.py @@ -69,7 +69,7 @@ class TaskTest(unittest.TestCase): # Run the iterator test. result = '' - for thetask in Task.Iterator(root, Task.MAYBE): + for thetask in Task.Iterator(root, TaskState.MAYBE): result += thetask.get_dump(0, False) + '\n' self.assertTrue(expected2.match(result), 'Expected:\n' + repr(expected2.pattern) + '\n' + diff --git a/tests/SpiffWorkflow/WorkflowTest.py b/tests/SpiffWorkflow/core/WorkflowTest.py similarity index 86% rename from tests/SpiffWorkflow/WorkflowTest.py rename to tests/SpiffWorkflow/core/WorkflowTest.py index 273ced0d7..726598e96 100644 --- a/tests/SpiffWorkflow/WorkflowTest.py +++ b/tests/SpiffWorkflow/core/WorkflowTest.py @@ -1,10 +1,7 @@ # -*- coding: utf-8 -*- -import sys import unittest import os -data_dir = os.path.join(os.path.dirname(__file__), 'data') -sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..')) from lxml import etree @@ -15,6 +12,7 @@ from SpiffWorkflow.specs.WorkflowSpec import WorkflowSpec from SpiffWorkflow.task import TaskState from SpiffWorkflow.serializer.prettyxml import XmlSerializer +data_dir = os.path.join(os.path.dirname(__file__), 'data') class WorkflowTest(unittest.TestCase): @@ -27,7 +25,7 @@ class WorkflowTest(unittest.TestCase): """ Simulates interactive calls, as would be issued by a user. """ - xml_file = os.path.join(data_dir, 'spiff', 'workflow1.xml') + xml_file = os.path.join(data_dir, 'workflow1.xml') with open(xml_file) as fp: xml = etree.parse(fp).getroot() wf_spec = WorkflowSpec.deserialize(XmlSerializer(), xml) @@ -36,7 +34,7 @@ class WorkflowTest(unittest.TestCase): tasks = workflow.get_tasks(TaskState.READY) self.assertEqual(len(tasks), 1) self.assertEqual(tasks[0].task_spec.name, 'Start') - workflow.complete_task_from_id(tasks[0].id) + workflow.run_task_from_id(tasks[0].id) self.assertEqual(tasks[0].state, TaskState.COMPLETED) tasks = workflow.get_tasks(TaskState.READY) @@ -47,7 +45,7 @@ class WorkflowTest(unittest.TestCase): self.assertEqual(task_a1.task_spec.name, 'task_a1') self.assertEqual(task_b1.task_spec.__class__, Simple) self.assertEqual(task_b1.task_spec.name, 'task_b1') - workflow.complete_task_from_id(task_a1.id) + workflow.run_task_from_id(task_a1.id) self.assertEqual(task_a1.state, TaskState.COMPLETED) tasks = workflow.get_tasks(TaskState.READY) @@ -56,16 +54,16 @@ class WorkflowTest(unittest.TestCase): task_a2 = tasks[0] self.assertEqual(task_a2.task_spec.__class__, Simple) self.assertEqual(task_a2.task_spec.name, 'task_a2') - workflow.complete_task_from_id(task_a2.id) + workflow.run_task_from_id(task_a2.id) tasks = workflow.get_tasks(TaskState.READY) self.assertEqual(len(tasks), 1) self.assertTrue(task_b1 in tasks) - workflow.complete_task_from_id(task_b1.id) + workflow.run_task_from_id(task_b1.id) tasks = workflow.get_tasks(TaskState.READY) self.assertEqual(len(tasks), 1) - workflow.complete_task_from_id(tasks[0].id) + workflow.run_task_from_id(tasks[0].id) tasks = workflow.get_tasks(TaskState.READY) self.assertEqual(len(tasks), 1) diff --git a/tests/SpiffWorkflow/data/__init__.py b/tests/SpiffWorkflow/core/__init__.py similarity index 100% rename from tests/SpiffWorkflow/data/__init__.py rename to tests/SpiffWorkflow/core/__init__.py diff --git a/tests/SpiffWorkflow/data/spiff/__init__.py b/tests/SpiffWorkflow/core/data/__init__.py similarity index 100% rename from tests/SpiffWorkflow/data/spiff/__init__.py rename to tests/SpiffWorkflow/core/data/__init__.py diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/acyclic_synchronizing_merge.path b/tests/SpiffWorkflow/core/data/control-flow/acyclic_synchronizing_merge.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/acyclic_synchronizing_merge.path rename to tests/SpiffWorkflow/core/data/control-flow/acyclic_synchronizing_merge.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/acyclic_synchronizing_merge.xml b/tests/SpiffWorkflow/core/data/control-flow/acyclic_synchronizing_merge.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/acyclic_synchronizing_merge.xml rename to tests/SpiffWorkflow/core/data/control-flow/acyclic_synchronizing_merge.xml diff --git a/tests/SpiffWorkflow/core/data/control-flow/arbitrary_cycles.path b/tests/SpiffWorkflow/core/data/control-flow/arbitrary_cycles.path new file mode 100644 index 000000000..3bc55e36e --- /dev/null +++ b/tests/SpiffWorkflow/core/data/control-flow/arbitrary_cycles.path @@ -0,0 +1,9 @@ +Start + first + excl_choice_1 + go_to_repetition + first + excl_choice_1 + task_c1 + last + End diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/arbitrary_cycles.xml b/tests/SpiffWorkflow/core/data/control-flow/arbitrary_cycles.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/arbitrary_cycles.xml rename to tests/SpiffWorkflow/core/data/control-flow/arbitrary_cycles.xml diff --git a/tests/SpiffWorkflow/core/data/control-flow/blocking_discriminator.path b/tests/SpiffWorkflow/core/data/control-flow/blocking_discriminator.path new file mode 100644 index 000000000..c17c3fcd6 --- /dev/null +++ b/tests/SpiffWorkflow/core/data/control-flow/blocking_discriminator.path @@ -0,0 +1,15 @@ +Start + first + task_f1 + struct_discriminator_1 + excl_choice_1 + first + task_f1 + struct_discriminator_1 + excl_choice_1 + last + End + task_f2 + task_f3 + task_f2 + task_f3 diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/blocking_discriminator.xml b/tests/SpiffWorkflow/core/data/control-flow/blocking_discriminator.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/blocking_discriminator.xml rename to tests/SpiffWorkflow/core/data/control-flow/blocking_discriminator.xml diff --git a/tests/SpiffWorkflow/core/data/control-flow/blocking_partial_join.path b/tests/SpiffWorkflow/core/data/control-flow/blocking_partial_join.path new file mode 100644 index 000000000..147b4346e --- /dev/null +++ b/tests/SpiffWorkflow/core/data/control-flow/blocking_partial_join.path @@ -0,0 +1,15 @@ +Start + multi_choice_1 + task_e1 + task_e3 + struct_synch_merge_1 + excl_choice_1 + multi_choice_1 + task_e1 + task_e3 + struct_synch_merge_1 + excl_choice_1 + last + End + task_e4 + task_e4 diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/blocking_partial_join.xml b/tests/SpiffWorkflow/core/data/control-flow/blocking_partial_join.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/blocking_partial_join.xml rename to tests/SpiffWorkflow/core/data/control-flow/blocking_partial_join.xml diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/cancel_case.path b/tests/SpiffWorkflow/core/data/control-flow/cancel_case.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/cancel_case.path rename to tests/SpiffWorkflow/core/data/control-flow/cancel_case.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/cancel_case.xml b/tests/SpiffWorkflow/core/data/control-flow/cancel_case.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/cancel_case.xml rename to tests/SpiffWorkflow/core/data/control-flow/cancel_case.xml diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/cancel_multi_instance_task.path b/tests/SpiffWorkflow/core/data/control-flow/cancel_multi_instance_task.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/cancel_multi_instance_task.path rename to tests/SpiffWorkflow/core/data/control-flow/cancel_multi_instance_task.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/cancel_multi_instance_task.xml b/tests/SpiffWorkflow/core/data/control-flow/cancel_multi_instance_task.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/cancel_multi_instance_task.xml rename to tests/SpiffWorkflow/core/data/control-flow/cancel_multi_instance_task.xml diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/cancel_region.path b/tests/SpiffWorkflow/core/data/control-flow/cancel_region.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/cancel_region.path rename to tests/SpiffWorkflow/core/data/control-flow/cancel_region.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/cancel_region.xml b/tests/SpiffWorkflow/core/data/control-flow/cancel_region.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/cancel_region.xml rename to tests/SpiffWorkflow/core/data/control-flow/cancel_region.xml diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/cancel_task.path b/tests/SpiffWorkflow/core/data/control-flow/cancel_task.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/cancel_task.path rename to tests/SpiffWorkflow/core/data/control-flow/cancel_task.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/cancel_task.xml b/tests/SpiffWorkflow/core/data/control-flow/cancel_task.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/cancel_task.xml rename to tests/SpiffWorkflow/core/data/control-flow/cancel_task.xml diff --git a/tests/SpiffWorkflow/core/data/control-flow/cancelling_discriminator.path b/tests/SpiffWorkflow/core/data/control-flow/cancelling_discriminator.path new file mode 100644 index 000000000..91efc8671 --- /dev/null +++ b/tests/SpiffWorkflow/core/data/control-flow/cancelling_discriminator.path @@ -0,0 +1,11 @@ +Start + first + task_f1 + struct_discriminator_1 + excl_choice_1 + first + task_f1 + struct_discriminator_1 + excl_choice_1 + last + End diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/cancelling_discriminator.xml b/tests/SpiffWorkflow/core/data/control-flow/cancelling_discriminator.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/cancelling_discriminator.xml rename to tests/SpiffWorkflow/core/data/control-flow/cancelling_discriminator.xml diff --git a/tests/SpiffWorkflow/core/data/control-flow/cancelling_partial_join.path b/tests/SpiffWorkflow/core/data/control-flow/cancelling_partial_join.path new file mode 100644 index 000000000..4c0ef3a7a --- /dev/null +++ b/tests/SpiffWorkflow/core/data/control-flow/cancelling_partial_join.path @@ -0,0 +1,13 @@ +Start + multi_choice_1 + task_e1 + task_e3 + struct_synch_merge_1 + excl_choice_1 + multi_choice_1 + task_e1 + task_e3 + struct_synch_merge_1 + excl_choice_1 + last + End diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/cancelling_partial_join.xml b/tests/SpiffWorkflow/core/data/control-flow/cancelling_partial_join.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/cancelling_partial_join.xml rename to tests/SpiffWorkflow/core/data/control-flow/cancelling_partial_join.xml diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/cancelling_partial_join_for_multi_instance.path b/tests/SpiffWorkflow/core/data/control-flow/cancelling_partial_join_for_multi_instance.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/cancelling_partial_join_for_multi_instance.path rename to tests/SpiffWorkflow/core/data/control-flow/cancelling_partial_join_for_multi_instance.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/cancelling_partial_join_for_multi_instance.xml b/tests/SpiffWorkflow/core/data/control-flow/cancelling_partial_join_for_multi_instance.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/cancelling_partial_join_for_multi_instance.xml rename to tests/SpiffWorkflow/core/data/control-flow/cancelling_partial_join_for_multi_instance.xml diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/complete_multiple_instance_activity.path b/tests/SpiffWorkflow/core/data/control-flow/complete_multiple_instance_activity.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/complete_multiple_instance_activity.path rename to tests/SpiffWorkflow/core/data/control-flow/complete_multiple_instance_activity.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/complete_multiple_instance_activity.xml b/tests/SpiffWorkflow/core/data/control-flow/complete_multiple_instance_activity.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/complete_multiple_instance_activity.xml rename to tests/SpiffWorkflow/core/data/control-flow/complete_multiple_instance_activity.xml diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/critical_section.path b/tests/SpiffWorkflow/core/data/control-flow/critical_section.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/critical_section.path rename to tests/SpiffWorkflow/core/data/control-flow/critical_section.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/critical_section.xml b/tests/SpiffWorkflow/core/data/control-flow/critical_section.xml similarity index 91% rename from tests/SpiffWorkflow/data/spiff/control-flow/critical_section.xml rename to tests/SpiffWorkflow/core/data/control-flow/critical_section.xml index cb3e93b88..94e88460f 100644 --- a/tests/SpiffWorkflow/data/spiff/control-flow/critical_section.xml +++ b/tests/SpiffWorkflow/core/data/control-flow/critical_section.xml @@ -10,20 +10,16 @@ - lock_one one_2 - lock_two one_3 - lock_three two_2 one_4 - lock_four last diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/deferred_choice.path b/tests/SpiffWorkflow/core/data/control-flow/deferred_choice.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/deferred_choice.path rename to tests/SpiffWorkflow/core/data/control-flow/deferred_choice.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/deferred_choice.xml b/tests/SpiffWorkflow/core/data/control-flow/deferred_choice.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/deferred_choice.xml rename to tests/SpiffWorkflow/core/data/control-flow/deferred_choice.xml diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/dynamic_partial_join_for_multi_instance.path b/tests/SpiffWorkflow/core/data/control-flow/dynamic_partial_join_for_multi_instance.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/dynamic_partial_join_for_multi_instance.path rename to tests/SpiffWorkflow/core/data/control-flow/dynamic_partial_join_for_multi_instance.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/dynamic_partial_join_for_multi_instance.xml b/tests/SpiffWorkflow/core/data/control-flow/dynamic_partial_join_for_multi_instance.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/dynamic_partial_join_for_multi_instance.xml rename to tests/SpiffWorkflow/core/data/control-flow/dynamic_partial_join_for_multi_instance.xml diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/exclusive_choice.path b/tests/SpiffWorkflow/core/data/control-flow/exclusive_choice.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/exclusive_choice.path rename to tests/SpiffWorkflow/core/data/control-flow/exclusive_choice.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/exclusive_choice.xml b/tests/SpiffWorkflow/core/data/control-flow/exclusive_choice.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/exclusive_choice.xml rename to tests/SpiffWorkflow/core/data/control-flow/exclusive_choice.xml diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/explicit_termination.path b/tests/SpiffWorkflow/core/data/control-flow/explicit_termination.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/explicit_termination.path rename to tests/SpiffWorkflow/core/data/control-flow/explicit_termination.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/explicit_termination.xml b/tests/SpiffWorkflow/core/data/control-flow/explicit_termination.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/explicit_termination.xml rename to tests/SpiffWorkflow/core/data/control-flow/explicit_termination.xml diff --git a/tests/SpiffWorkflow/core/data/control-flow/general_synchronizing_merge.path b/tests/SpiffWorkflow/core/data/control-flow/general_synchronizing_merge.path new file mode 100644 index 000000000..60f862fa5 --- /dev/null +++ b/tests/SpiffWorkflow/core/data/control-flow/general_synchronizing_merge.path @@ -0,0 +1,19 @@ +Start + first + task_a1 + task_b1 + task_c1 + loop_back_to_c1_once + task_c1 + loop_back_to_c1_once + task_c2 + go_to_stub + stub_1 + loop_back_to_stub_1_once + stub_1 + loop_back_to_stub_1_once + join + End + go_to_stub_3 + stub_3 + foo diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/general_synchronizing_merge.xml b/tests/SpiffWorkflow/core/data/control-flow/general_synchronizing_merge.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/general_synchronizing_merge.xml rename to tests/SpiffWorkflow/core/data/control-flow/general_synchronizing_merge.xml diff --git a/tests/SpiffWorkflow/core/data/control-flow/generalized_and_join.path b/tests/SpiffWorkflow/core/data/control-flow/generalized_and_join.path new file mode 100644 index 000000000..436467f63 --- /dev/null +++ b/tests/SpiffWorkflow/core/data/control-flow/generalized_and_join.path @@ -0,0 +1,21 @@ +Start + first + task_e1 + task_f1 + task_e2 + task_f2 + task_e3 + task_f3 + struct_synch_merge_1 + excl_choice_1 + first + task_e1 + task_f1 + task_e2 + task_f2 + task_e3 + task_f3 + struct_synch_merge_1 + excl_choice_1 + last + End diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/generalized_and_join.xml b/tests/SpiffWorkflow/core/data/control-flow/generalized_and_join.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/generalized_and_join.xml rename to tests/SpiffWorkflow/core/data/control-flow/generalized_and_join.xml diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/implicit_termination.path b/tests/SpiffWorkflow/core/data/control-flow/implicit_termination.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/implicit_termination.path rename to tests/SpiffWorkflow/core/data/control-flow/implicit_termination.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/implicit_termination.xml b/tests/SpiffWorkflow/core/data/control-flow/implicit_termination.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/implicit_termination.xml rename to tests/SpiffWorkflow/core/data/control-flow/implicit_termination.xml diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/interleaved_parallel_routing.path b/tests/SpiffWorkflow/core/data/control-flow/interleaved_parallel_routing.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/interleaved_parallel_routing.path rename to tests/SpiffWorkflow/core/data/control-flow/interleaved_parallel_routing.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/interleaved_parallel_routing.xml b/tests/SpiffWorkflow/core/data/control-flow/interleaved_parallel_routing.xml similarity index 87% rename from tests/SpiffWorkflow/data/spiff/control-flow/interleaved_parallel_routing.xml rename to tests/SpiffWorkflow/core/data/control-flow/interleaved_parallel_routing.xml index 6ff3f7f1e..cc4e5d321 100644 --- a/tests/SpiffWorkflow/data/spiff/control-flow/interleaved_parallel_routing.xml +++ b/tests/SpiffWorkflow/core/data/control-flow/interleaved_parallel_routing.xml @@ -10,18 +10,15 @@ - one_task_at_a_time join - one_task_at_a_time two2 - one_task_at_a_time join diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/interleaved_routing.path b/tests/SpiffWorkflow/core/data/control-flow/interleaved_routing.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/interleaved_routing.path rename to tests/SpiffWorkflow/core/data/control-flow/interleaved_routing.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/interleaved_routing.xml b/tests/SpiffWorkflow/core/data/control-flow/interleaved_routing.xml similarity index 81% rename from tests/SpiffWorkflow/data/spiff/control-flow/interleaved_routing.xml rename to tests/SpiffWorkflow/core/data/control-flow/interleaved_routing.xml index 7cf4a99dd..d9bb123a0 100644 --- a/tests/SpiffWorkflow/data/spiff/control-flow/interleaved_routing.xml +++ b/tests/SpiffWorkflow/core/data/control-flow/interleaved_routing.xml @@ -9,7 +9,6 @@ - one_task_at_a_time one1 two1 three1 @@ -18,25 +17,20 @@ - one_task_at_a_time join - one_task_at_a_time join - one_task_at_a_time join - one_task_at_a_time join - one_task_at_a_time last diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/milestone.path b/tests/SpiffWorkflow/core/data/control-flow/milestone.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/milestone.path rename to tests/SpiffWorkflow/core/data/control-flow/milestone.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/milestone.xml b/tests/SpiffWorkflow/core/data/control-flow/milestone.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/milestone.xml rename to tests/SpiffWorkflow/core/data/control-flow/milestone.xml diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/multi_choice.path b/tests/SpiffWorkflow/core/data/control-flow/multi_choice.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/multi_choice.path rename to tests/SpiffWorkflow/core/data/control-flow/multi_choice.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/multi_choice.xml b/tests/SpiffWorkflow/core/data/control-flow/multi_choice.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/multi_choice.xml rename to tests/SpiffWorkflow/core/data/control-flow/multi_choice.xml diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/multi_instance_with_a_priori_design_time_knowledge.path b/tests/SpiffWorkflow/core/data/control-flow/multi_instance_with_a_priori_design_time_knowledge.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/multi_instance_with_a_priori_design_time_knowledge.path rename to tests/SpiffWorkflow/core/data/control-flow/multi_instance_with_a_priori_design_time_knowledge.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/multi_instance_with_a_priori_design_time_knowledge.xml b/tests/SpiffWorkflow/core/data/control-flow/multi_instance_with_a_priori_design_time_knowledge.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/multi_instance_with_a_priori_design_time_knowledge.xml rename to tests/SpiffWorkflow/core/data/control-flow/multi_instance_with_a_priori_design_time_knowledge.xml diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/multi_instance_with_a_priori_run_time_knowledge.path b/tests/SpiffWorkflow/core/data/control-flow/multi_instance_with_a_priori_run_time_knowledge.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/multi_instance_with_a_priori_run_time_knowledge.path rename to tests/SpiffWorkflow/core/data/control-flow/multi_instance_with_a_priori_run_time_knowledge.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/multi_instance_with_a_priori_run_time_knowledge.xml b/tests/SpiffWorkflow/core/data/control-flow/multi_instance_with_a_priori_run_time_knowledge.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/multi_instance_with_a_priori_run_time_knowledge.xml rename to tests/SpiffWorkflow/core/data/control-flow/multi_instance_with_a_priori_run_time_knowledge.xml diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/multi_instance_without_a_priori.path b/tests/SpiffWorkflow/core/data/control-flow/multi_instance_without_a_priori.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/multi_instance_without_a_priori.path rename to tests/SpiffWorkflow/core/data/control-flow/multi_instance_without_a_priori.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/multi_instance_without_a_priori.xml b/tests/SpiffWorkflow/core/data/control-flow/multi_instance_without_a_priori.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/multi_instance_without_a_priori.xml rename to tests/SpiffWorkflow/core/data/control-flow/multi_instance_without_a_priori.xml diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/multi_instance_without_synch.path b/tests/SpiffWorkflow/core/data/control-flow/multi_instance_without_synch.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/multi_instance_without_synch.path rename to tests/SpiffWorkflow/core/data/control-flow/multi_instance_without_synch.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/multi_instance_without_synch.xml b/tests/SpiffWorkflow/core/data/control-flow/multi_instance_without_synch.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/multi_instance_without_synch.xml rename to tests/SpiffWorkflow/core/data/control-flow/multi_instance_without_synch.xml diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/multi_merge.path b/tests/SpiffWorkflow/core/data/control-flow/multi_merge.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/multi_merge.path rename to tests/SpiffWorkflow/core/data/control-flow/multi_merge.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/multi_merge.xml b/tests/SpiffWorkflow/core/data/control-flow/multi_merge.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/multi_merge.xml rename to tests/SpiffWorkflow/core/data/control-flow/multi_merge.xml diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/parallel_split.path b/tests/SpiffWorkflow/core/data/control-flow/parallel_split.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/parallel_split.path rename to tests/SpiffWorkflow/core/data/control-flow/parallel_split.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/parallel_split.xml b/tests/SpiffWorkflow/core/data/control-flow/parallel_split.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/parallel_split.xml rename to tests/SpiffWorkflow/core/data/control-flow/parallel_split.xml diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/persistent_trigger.path b/tests/SpiffWorkflow/core/data/control-flow/persistent_trigger.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/persistent_trigger.path rename to tests/SpiffWorkflow/core/data/control-flow/persistent_trigger.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/persistent_trigger.xml b/tests/SpiffWorkflow/core/data/control-flow/persistent_trigger.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/persistent_trigger.xml rename to tests/SpiffWorkflow/core/data/control-flow/persistent_trigger.xml diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/recursion.path b/tests/SpiffWorkflow/core/data/control-flow/recursion.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/recursion.path rename to tests/SpiffWorkflow/core/data/control-flow/recursion.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/recursion.xml b/tests/SpiffWorkflow/core/data/control-flow/recursion.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/recursion.xml rename to tests/SpiffWorkflow/core/data/control-flow/recursion.xml diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/sequence.path b/tests/SpiffWorkflow/core/data/control-flow/sequence.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/sequence.path rename to tests/SpiffWorkflow/core/data/control-flow/sequence.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/sequence.xml b/tests/SpiffWorkflow/core/data/control-flow/sequence.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/sequence.xml rename to tests/SpiffWorkflow/core/data/control-flow/sequence.xml diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/simple_merge.path b/tests/SpiffWorkflow/core/data/control-flow/simple_merge.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/simple_merge.path rename to tests/SpiffWorkflow/core/data/control-flow/simple_merge.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/simple_merge.xml b/tests/SpiffWorkflow/core/data/control-flow/simple_merge.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/simple_merge.xml rename to tests/SpiffWorkflow/core/data/control-flow/simple_merge.xml diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/static_partial_join_for_multi_instance.path b/tests/SpiffWorkflow/core/data/control-flow/static_partial_join_for_multi_instance.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/static_partial_join_for_multi_instance.path rename to tests/SpiffWorkflow/core/data/control-flow/static_partial_join_for_multi_instance.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/static_partial_join_for_multi_instance.xml b/tests/SpiffWorkflow/core/data/control-flow/static_partial_join_for_multi_instance.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/static_partial_join_for_multi_instance.xml rename to tests/SpiffWorkflow/core/data/control-flow/static_partial_join_for_multi_instance.xml diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/structured_discriminator.path b/tests/SpiffWorkflow/core/data/control-flow/structured_discriminator.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/structured_discriminator.path rename to tests/SpiffWorkflow/core/data/control-flow/structured_discriminator.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/structured_discriminator.xml b/tests/SpiffWorkflow/core/data/control-flow/structured_discriminator.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/structured_discriminator.xml rename to tests/SpiffWorkflow/core/data/control-flow/structured_discriminator.xml diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/structured_partial_join.path b/tests/SpiffWorkflow/core/data/control-flow/structured_partial_join.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/structured_partial_join.path rename to tests/SpiffWorkflow/core/data/control-flow/structured_partial_join.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/structured_partial_join.xml b/tests/SpiffWorkflow/core/data/control-flow/structured_partial_join.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/structured_partial_join.xml rename to tests/SpiffWorkflow/core/data/control-flow/structured_partial_join.xml diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/structured_synchronizing_merge.path b/tests/SpiffWorkflow/core/data/control-flow/structured_synchronizing_merge.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/structured_synchronizing_merge.path rename to tests/SpiffWorkflow/core/data/control-flow/structured_synchronizing_merge.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/structured_synchronizing_merge.xml b/tests/SpiffWorkflow/core/data/control-flow/structured_synchronizing_merge.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/structured_synchronizing_merge.xml rename to tests/SpiffWorkflow/core/data/control-flow/structured_synchronizing_merge.xml diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/subworkflow_to_join.path b/tests/SpiffWorkflow/core/data/control-flow/subworkflow_to_join.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/subworkflow_to_join.path rename to tests/SpiffWorkflow/core/data/control-flow/subworkflow_to_join.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/subworkflow_to_join.xml b/tests/SpiffWorkflow/core/data/control-flow/subworkflow_to_join.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/subworkflow_to_join.xml rename to tests/SpiffWorkflow/core/data/control-flow/subworkflow_to_join.xml diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/subworkflow_to_join_inner.xml b/tests/SpiffWorkflow/core/data/control-flow/subworkflow_to_join_inner.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/subworkflow_to_join_inner.xml rename to tests/SpiffWorkflow/core/data/control-flow/subworkflow_to_join_inner.xml diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/synchronization.path b/tests/SpiffWorkflow/core/data/control-flow/synchronization.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/synchronization.path rename to tests/SpiffWorkflow/core/data/control-flow/synchronization.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/synchronization.xml b/tests/SpiffWorkflow/core/data/control-flow/synchronization.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/synchronization.xml rename to tests/SpiffWorkflow/core/data/control-flow/synchronization.xml diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/thread_merge.path b/tests/SpiffWorkflow/core/data/control-flow/thread_merge.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/thread_merge.path rename to tests/SpiffWorkflow/core/data/control-flow/thread_merge.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/thread_merge.xml b/tests/SpiffWorkflow/core/data/control-flow/thread_merge.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/thread_merge.xml rename to tests/SpiffWorkflow/core/data/control-flow/thread_merge.xml diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/thread_split.path b/tests/SpiffWorkflow/core/data/control-flow/thread_split.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/thread_split.path rename to tests/SpiffWorkflow/core/data/control-flow/thread_split.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/thread_split.xml b/tests/SpiffWorkflow/core/data/control-flow/thread_split.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/thread_split.xml rename to tests/SpiffWorkflow/core/data/control-flow/thread_split.xml diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/transient_trigger.path b/tests/SpiffWorkflow/core/data/control-flow/transient_trigger.path similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/transient_trigger.path rename to tests/SpiffWorkflow/core/data/control-flow/transient_trigger.path diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/transient_trigger.xml b/tests/SpiffWorkflow/core/data/control-flow/transient_trigger.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/control-flow/transient_trigger.xml rename to tests/SpiffWorkflow/core/data/control-flow/transient_trigger.xml diff --git a/tests/SpiffWorkflow/data/spiff/data/block_data.xml b/tests/SpiffWorkflow/core/data/data/block_data.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/data/block_data.xml rename to tests/SpiffWorkflow/core/data/data/block_data.xml diff --git a/tests/SpiffWorkflow/data/spiff/data/block_data.xml.data b/tests/SpiffWorkflow/core/data/data/block_data.xml.data similarity index 100% rename from tests/SpiffWorkflow/data/spiff/data/block_data.xml.data rename to tests/SpiffWorkflow/core/data/data/block_data.xml.data diff --git a/tests/SpiffWorkflow/data/spiff/data/block_data_inner.xml b/tests/SpiffWorkflow/core/data/data/block_data_inner.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/data/block_data_inner.xml rename to tests/SpiffWorkflow/core/data/data/block_data_inner.xml diff --git a/tests/SpiffWorkflow/data/spiff/data/block_to_subworkflow.xml b/tests/SpiffWorkflow/core/data/data/block_to_subworkflow.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/data/block_to_subworkflow.xml rename to tests/SpiffWorkflow/core/data/data/block_to_subworkflow.xml diff --git a/tests/SpiffWorkflow/data/spiff/data/block_to_subworkflow.xml.data b/tests/SpiffWorkflow/core/data/data/block_to_subworkflow.xml.data similarity index 100% rename from tests/SpiffWorkflow/data/spiff/data/block_to_subworkflow.xml.data rename to tests/SpiffWorkflow/core/data/data/block_to_subworkflow.xml.data diff --git a/tests/SpiffWorkflow/data/spiff/data/block_to_subworkflow_inner.xml b/tests/SpiffWorkflow/core/data/data/block_to_subworkflow_inner.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/data/block_to_subworkflow_inner.xml rename to tests/SpiffWorkflow/core/data/data/block_to_subworkflow_inner.xml diff --git a/tests/SpiffWorkflow/data/spiff/data/subworkflow_to_block.xml b/tests/SpiffWorkflow/core/data/data/subworkflow_to_block.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/data/subworkflow_to_block.xml rename to tests/SpiffWorkflow/core/data/data/subworkflow_to_block.xml diff --git a/tests/SpiffWorkflow/data/spiff/data/subworkflow_to_block.xml.data b/tests/SpiffWorkflow/core/data/data/subworkflow_to_block.xml.data similarity index 100% rename from tests/SpiffWorkflow/data/spiff/data/subworkflow_to_block.xml.data rename to tests/SpiffWorkflow/core/data/data/subworkflow_to_block.xml.data diff --git a/tests/SpiffWorkflow/data/spiff/data/subworkflow_to_block_inner.xml b/tests/SpiffWorkflow/core/data/data/subworkflow_to_block_inner.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/data/subworkflow_to_block_inner.xml rename to tests/SpiffWorkflow/core/data/data/subworkflow_to_block_inner.xml diff --git a/tests/SpiffWorkflow/data/spiff/data/task_data.xml b/tests/SpiffWorkflow/core/data/data/task_data.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/data/task_data.xml rename to tests/SpiffWorkflow/core/data/data/task_data.xml diff --git a/tests/SpiffWorkflow/data/spiff/data/task_data.xml.data b/tests/SpiffWorkflow/core/data/data/task_data.xml.data similarity index 100% rename from tests/SpiffWorkflow/data/spiff/data/task_data.xml.data rename to tests/SpiffWorkflow/core/data/data/task_data.xml.data diff --git a/tests/SpiffWorkflow/data/spiff/data/task_to_task.xml b/tests/SpiffWorkflow/core/data/data/task_to_task.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/data/task_to_task.xml rename to tests/SpiffWorkflow/core/data/data/task_to_task.xml diff --git a/tests/SpiffWorkflow/data/spiff/data/task_to_task.xml.data b/tests/SpiffWorkflow/core/data/data/task_to_task.xml.data similarity index 100% rename from tests/SpiffWorkflow/data/spiff/data/task_to_task.xml.data rename to tests/SpiffWorkflow/core/data/data/task_to_task.xml.data diff --git a/tests/SpiffWorkflow/data/spiff/resource/.gitignore b/tests/SpiffWorkflow/core/data/resource/.gitignore similarity index 100% rename from tests/SpiffWorkflow/data/spiff/resource/.gitignore rename to tests/SpiffWorkflow/core/data/resource/.gitignore diff --git a/tests/SpiffWorkflow/core/data/workflow1.path b/tests/SpiffWorkflow/core/data/workflow1.path new file mode 100644 index 000000000..fa7bb65aa --- /dev/null +++ b/tests/SpiffWorkflow/core/data/workflow1.path @@ -0,0 +1,42 @@ +Start + task_a1 + task_a2 + task_b1 + task_b2 + synch_1 + excl_choice_1 + task_c1 + excl_choice_2 + task_d3 + multi_choice_1 + task_e1 + task_e3 + struct_synch_merge_1 + task_f1 + struct_discriminator_1 + excl_choice_3 + excl_choice_1 + task_c1 + excl_choice_2 + task_d3 + multi_choice_1 + task_e1 + task_e3 + struct_synch_merge_1 + task_f1 + struct_discriminator_1 + excl_choice_3 + multi_instance_1 + task_g1 + task_g2 + task_g1 + task_g2 + task_g1 + task_g2 + struct_synch_merge_2 + last + End + task_f2 + task_f3 + task_f2 + task_f3 diff --git a/tests/SpiffWorkflow/data/spiff/workflow1.py b/tests/SpiffWorkflow/core/data/workflow1.py similarity index 100% rename from tests/SpiffWorkflow/data/spiff/workflow1.py rename to tests/SpiffWorkflow/core/data/workflow1.py diff --git a/tests/SpiffWorkflow/data/spiff/workflow1.xml b/tests/SpiffWorkflow/core/data/workflow1.xml similarity index 100% rename from tests/SpiffWorkflow/data/spiff/workflow1.xml rename to tests/SpiffWorkflow/core/data/workflow1.xml diff --git a/tests/SpiffWorkflow/docTest.py b/tests/SpiffWorkflow/core/docTest.py similarity index 90% rename from tests/SpiffWorkflow/docTest.py rename to tests/SpiffWorkflow/core/docTest.py index 3a1ef1cf5..7d600eb3c 100644 --- a/tests/SpiffWorkflow/docTest.py +++ b/tests/SpiffWorkflow/core/docTest.py @@ -4,8 +4,8 @@ import sys import unittest import os dirname = os.path.abspath(os.path.dirname(__file__)) -sys.path.insert(0, os.path.join(dirname, '..', '..')) -doc_dir = os.path.join(dirname, '..', '..', 'doc') +sys.path.insert(0, os.path.join(dirname, '..', '..', '..')) +doc_dir = os.path.join(dirname, '..', '..', '..', 'doc') class TutorialTest(object): diff --git a/tests/SpiffWorkflow/core/pattern_base.py b/tests/SpiffWorkflow/core/pattern_base.py new file mode 100644 index 000000000..50cb6c783 --- /dev/null +++ b/tests/SpiffWorkflow/core/pattern_base.py @@ -0,0 +1,123 @@ +import os +import time +import warnings + +from lxml import etree + +from SpiffWorkflow.workflow import Workflow +from SpiffWorkflow.task import Task +from SpiffWorkflow.specs.WorkflowSpec import WorkflowSpec + +from SpiffWorkflow.serializer.prettyxml import XmlSerializer as PrettyXmlSerializer +from SpiffWorkflow.serializer.xml import XmlSerializer +from SpiffWorkflow.serializer.dict import DictionarySerializer +from SpiffWorkflow.serializer.json import JSONSerializer + +from SpiffWorkflow.serializer.exceptions import TaskNotSupportedError + +from .util import track_workflow + +data_dir = os.path.join(os.path.dirname(__file__), 'data') +xml_serializer = XmlSerializer() +dict_serializer = DictionarySerializer() +json_serializer = JSONSerializer() + +class WorkflowPatternTestCase: + + def init_thread_pool(self): + Task.id_pool = 0 + Task.thread_id_pool = 0 + + def load_from_xml(self, pattern): + + self.init_thread_pool() + prefix = os.path.join(data_dir, pattern) + filename = f'{prefix}.xml' + with open(filename) as fp: + xml = etree.parse(fp).getroot() + # This "serializer" is a parser; it doesn't deserialize. + # Because we use it to load all the workflows, consider it tested here. + serializer = PrettyXmlSerializer() + self.spec = WorkflowSpec.deserialize(serializer, xml, filename=filename) + + path_file = f'{prefix}.path' + if os.path.exists(path_file): + with open(path_file) as fp: + self.expected_path = fp.read() + else: + self.expected_path = None + + data_file = f'{prefix}.data' + if os.path.exists(data_file): + with open(data_file) as fp: + self.expected_data = fp.read() + else: + self.expected_data = None + + self.taken_path = track_workflow(self.spec) + self.workflow = Workflow(self.spec) + + def serialize(self, spec_or_workflow, serializer): + + try: + before = spec_or_workflow.serialize(serializer) + restored = spec_or_workflow.deserialize(serializer, before) + after = restored.serialize(serializer) + return before, after + except TaskNotSupportedError as exc: + warnings.warn(f'Unsupported task spec: {exc}') + return None, None + + def run_workflow(self): + # We allow the workflow to require a maximum of 5 seconds to complete, to allow for testing long running tasks. + for i in range(10): + self.workflow.run_all(False) + if self.workflow.is_completed(): + break + time.sleep(0.5) + + def test_run_workflow(self): + + self.run_workflow() + self.assertTrue(self.workflow.is_completed()) + + # Check whether the correct route was taken. + if self.expected_path is not None: + taken_path = '\n'.join(self.taken_path) + '\n' + self.assertEqual(taken_path, self.expected_path) + + # Check data availibility. + if self.expected_data is not None: + result = self.workflow.get_data('data', '') + self.assertIn(result, self.expected_data) + + def test_xml_serializer(self): + + prepare_result = lambda item: etree.tostring(item, pretty_print=True) + + before, after = self.serialize(self.spec, xml_serializer) + self.assertEqual(prepare_result(before), prepare_result(after)) + self.assertIsInstance(before, etree._Element) + + before, after = self.serialize(self.workflow, xml_serializer) + if before is not None: + self.assertEqual(prepare_result(before), prepare_result(after)) + + def test_dictionary_serializer(self): + + before, after = self.serialize(self.spec, dict_serializer) + self.assertDictEqual(before, after) + self.assertIsInstance(before, dict) + + before, after = self.serialize(self.workflow, dict_serializer) + if before is not None: + self.assertDictEqual(before, after) + + def test_json_serializer(self): + + before, after = self.serialize(self.spec, json_serializer) + self.assertEqual(before, after) + self.assertIsInstance(before, str) + + before, after = self.serialize(self.workflow, json_serializer) + self.assertEqual(before, after) \ No newline at end of file diff --git a/tests/SpiffWorkflow/specs/CeleryTest.py b/tests/SpiffWorkflow/core/specs/CeleryTest.py similarity index 90% rename from tests/SpiffWorkflow/specs/CeleryTest.py rename to tests/SpiffWorkflow/core/specs/CeleryTest.py index ac8116881..5f4232d72 100644 --- a/tests/SpiffWorkflow/specs/CeleryTest.py +++ b/tests/SpiffWorkflow/core/specs/CeleryTest.py @@ -1,10 +1,8 @@ # -*- coding: utf-8 -*- -import os -import sys import unittest import pickle -sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', '..')) + from .TaskSpecTest import TaskSpecTest from SpiffWorkflow.specs.Celery import Celery from SpiffWorkflow.specs.WorkflowSpec import WorkflowSpec @@ -64,12 +62,17 @@ class CeleryTest(TaskSpecTest): data = {'R': b64encode(pickle.dumps('1'))} # Comes from live data. Bug not identified, but there we are... data = {'inputs': ['Wait:1'], 'lookahead': 2, 'description': '', - 'outputs': [], 'args': args, + 'outputs': [], + 'args': args, 'manual': False, - 'data': data, 'locks': [], 'pre_assign': [], + 'data': data, + 'pre_assign': [], 'call': 'call.x', - 'internal': False, 'post_assign': [], 'id': 8, - 'result_key': None, 'defines': data, + 'internal': False, + 'post_assign': [], + 'id': 8, + 'result_key': None, + 'defines': data, 'class': 'SpiffWorkflow.specs.Celery.Celery', 'name': 'RS1:1'} Celery.deserialize(serializer, new_wf_spec, data) diff --git a/tests/SpiffWorkflow/specs/DeepMergeTest.py b/tests/SpiffWorkflow/core/specs/DeepMergeTest.py similarity index 100% rename from tests/SpiffWorkflow/specs/DeepMergeTest.py rename to tests/SpiffWorkflow/core/specs/DeepMergeTest.py diff --git a/tests/SpiffWorkflow/specs/ExecuteTest.py b/tests/SpiffWorkflow/core/specs/ExecuteTest.py similarity index 96% rename from tests/SpiffWorkflow/specs/ExecuteTest.py rename to tests/SpiffWorkflow/core/specs/ExecuteTest.py index 3a10ae75d..7bb677d79 100644 --- a/tests/SpiffWorkflow/specs/ExecuteTest.py +++ b/tests/SpiffWorkflow/core/specs/ExecuteTest.py @@ -1,15 +1,12 @@ # -*- coding: utf-8 -*- - - - import os import unittest -from tests.SpiffWorkflow.util import run_workflow -from .TaskSpecTest import TaskSpecTest from SpiffWorkflow.task import TaskState from SpiffWorkflow.specs.Execute import Execute +from .TaskSpecTest import TaskSpecTest +from ..util import run_workflow class ExecuteTest(TaskSpecTest): CORRELATE = Execute diff --git a/tests/SpiffWorkflow/specs/JoinTest.py b/tests/SpiffWorkflow/core/specs/JoinTest.py similarity index 85% rename from tests/SpiffWorkflow/specs/JoinTest.py rename to tests/SpiffWorkflow/core/specs/JoinTest.py index 7224701f5..9aca17d65 100644 --- a/tests/SpiffWorkflow/specs/JoinTest.py +++ b/tests/SpiffWorkflow/core/specs/JoinTest.py @@ -1,15 +1,10 @@ # -*- coding: utf-8 -*- - - -import os -import sys import unittest -sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', '..')) -from .TaskSpecTest import TaskSpecTest from SpiffWorkflow.specs.Join import Join +from .TaskSpecTest import TaskSpecTest class JoinTest(TaskSpecTest): CORRELATE = Join diff --git a/tests/SpiffWorkflow/specs/MergeTest.py b/tests/SpiffWorkflow/core/specs/MergeTest.py similarity index 96% rename from tests/SpiffWorkflow/specs/MergeTest.py rename to tests/SpiffWorkflow/core/specs/MergeTest.py index 6fc692a66..745e18b25 100644 --- a/tests/SpiffWorkflow/specs/MergeTest.py +++ b/tests/SpiffWorkflow/core/specs/MergeTest.py @@ -1,11 +1,6 @@ # -*- coding: utf-8 -*- - - -import os -import sys import unittest -sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', '..')) from .JoinTest import JoinTest from SpiffWorkflow.specs.Merge import Merge @@ -61,7 +56,7 @@ class MergeTest(JoinTest): workflow.task_tree.set_data(everywhere=1) for task in workflow.get_tasks(): task.set_data(**{'name': task.get_name(), task.get_name(): 1}) - workflow.complete_all() + workflow.run_all() self.assertTrue(workflow.is_completed()) found = {} for task in workflow.get_tasks(): diff --git a/tests/SpiffWorkflow/specs/SubWorkflowTest.py b/tests/SpiffWorkflow/core/specs/SubWorkflowTest.py similarity index 93% rename from tests/SpiffWorkflow/specs/SubWorkflowTest.py rename to tests/SpiffWorkflow/core/specs/SubWorkflowTest.py index 3e99f9931..892fff216 100644 --- a/tests/SpiffWorkflow/specs/SubWorkflowTest.py +++ b/tests/SpiffWorkflow/core/specs/SubWorkflowTest.py @@ -1,13 +1,9 @@ # -*- coding: utf-8 -*- - -import sys import unittest import os from lxml import etree -sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', '..')) - from SpiffWorkflow.specs.WorkflowSpec import WorkflowSpec from SpiffWorkflow.specs.SubWorkflow import SubWorkflow from SpiffWorkflow.serializer.prettyxml import XmlSerializer @@ -29,7 +25,7 @@ class TaskSpecTest(unittest.TestCase): def load_workflow_spec(self, folder, f): file = os.path.join( - os.path.dirname(__file__), '..', 'data', 'spiff', folder, f) + os.path.dirname(__file__), '..', 'data', folder, f) serializer = XmlSerializer() with open(file) as fp: xml = etree.parse(fp).getroot() @@ -46,17 +42,16 @@ class TaskSpecTest(unittest.TestCase): self.assertEqual(1, len(ready_tasks)) task = ready_tasks[0] self.assertEqual(name, task.task_spec.name) - task.complete() + task.run() def do_next_named_step(self, name, other_ready_tasks): # This method completes a single task from the specified set of ready # tasks ready_tasks = self.workflow.get_tasks(TaskState.READY) all_tasks = sorted([name] + other_ready_tasks) - self.assertEqual( - all_tasks, sorted([t.task_spec.name for t in ready_tasks])) + self.assertEqual(all_tasks, sorted([t.task_spec.name for t in ready_tasks])) task = list([t for t in ready_tasks if t.task_spec.name == name])[0] - task.complete() + task.run() def test_block_to_subworkflow(self): self.load_workflow_spec('data', 'block_to_subworkflow.xml') diff --git a/tests/SpiffWorkflow/specs/TaskSpecTest.py b/tests/SpiffWorkflow/core/specs/TaskSpecTest.py similarity index 96% rename from tests/SpiffWorkflow/specs/TaskSpecTest.py rename to tests/SpiffWorkflow/core/specs/TaskSpecTest.py index 717846566..ea36f7586 100644 --- a/tests/SpiffWorkflow/specs/TaskSpecTest.py +++ b/tests/SpiffWorkflow/core/specs/TaskSpecTest.py @@ -1,9 +1,5 @@ # -*- coding: utf-8 -*- - -import sys import unittest -import os -sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', '..')) from SpiffWorkflow.specs.Join import Join from SpiffWorkflow.specs.Simple import Simple @@ -32,7 +28,6 @@ class TaskSpecTest(unittest.TestCase): self.assertEqual(self.spec.defines, {}) self.assertEqual(self.spec.pre_assign, []) self.assertEqual(self.spec.post_assign, []) - self.assertEqual(self.spec.locks, []) def testSetData(self): self.assertEqual(self.spec.get_data('foo'), None) diff --git a/tests/SpiffWorkflow/specs/TransformTest.py b/tests/SpiffWorkflow/core/specs/TransformTest.py similarity index 91% rename from tests/SpiffWorkflow/specs/TransformTest.py rename to tests/SpiffWorkflow/core/specs/TransformTest.py index 228a038ec..77d826714 100644 --- a/tests/SpiffWorkflow/specs/TransformTest.py +++ b/tests/SpiffWorkflow/core/specs/TransformTest.py @@ -1,13 +1,7 @@ # -*- coding: utf-8 -*- - - - -import os -import sys import unittest -sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', '..')) -from tests.SpiffWorkflow.util import run_workflow +from ..util import run_workflow from .TaskSpecTest import TaskSpecTest from SpiffWorkflow.specs.Transform import Transform from SpiffWorkflow.specs.Simple import Simple diff --git a/tests/SpiffWorkflow/specs/WorkflowSpecTest.py b/tests/SpiffWorkflow/core/specs/WorkflowSpecTest.py similarity index 83% rename from tests/SpiffWorkflow/specs/WorkflowSpecTest.py rename to tests/SpiffWorkflow/core/specs/WorkflowSpecTest.py index 1ad5b1256..8c619ad74 100644 --- a/tests/SpiffWorkflow/specs/WorkflowSpecTest.py +++ b/tests/SpiffWorkflow/core/specs/WorkflowSpecTest.py @@ -1,26 +1,20 @@ # -*- coding: utf-8 -*- - -from builtins import zip -from builtins import range -import os -import sys import unittest -data_dir = os.path.join(os.path.dirname(__file__), '..', 'data') -sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', '..')) - +import os +import pickle from lxml import etree -import pickle from random import randint -try: - from util import track_workflow -except ImportError as e: - from tests.SpiffWorkflow.util import track_workflow + from SpiffWorkflow.workflow import Workflow from SpiffWorkflow.specs.Join import Join from SpiffWorkflow.specs.WorkflowSpec import WorkflowSpec from SpiffWorkflow.serializer.prettyxml import XmlSerializer +from ..util import track_workflow + +data_dir = os.path.join(os.path.dirname(__file__), '..', 'data') + serializer = XmlSerializer() data_file = 'data.pkl' @@ -49,7 +43,7 @@ class WorkflowSpecTest(unittest.TestCase): # Execute a random number of steps. for i in range(randint(0, len(workflow.spec.task_specs))): - workflow.complete_next() + workflow.run_next() # Store the workflow instance in a file. with open(data_file, 'wb') as fp: @@ -70,19 +64,14 @@ class WorkflowSpecTest(unittest.TestCase): taken_path = track_workflow(workflow.spec, taken_path) # Run the rest of the workflow. - workflow.complete_all() + workflow.run_all() after = workflow.get_dump() self.assertTrue(workflow.is_completed(), 'Workflow not complete:' + after) - # taken_path = '\n'.join(taken_path) + '\n' - if taken_path != expected_path: - for taken, expected in zip(taken_path, expected_path): - print("TAKEN: ", taken) - print("EXPECTED:", expected) self.assertEqual(expected_path, taken_path) def testSerialize(self): # Read a complete workflow spec. - xml_file = os.path.join(data_dir, 'spiff', 'workflow1.xml') + xml_file = os.path.join(data_dir, 'workflow1.xml') with open(xml_file) as fp: xml = etree.parse(fp).getroot() path_file = os.path.splitext(xml_file)[0] + '.path' diff --git a/tests/SpiffWorkflow/serializer/__init__.py b/tests/SpiffWorkflow/core/specs/__init__.py similarity index 100% rename from tests/SpiffWorkflow/serializer/__init__.py rename to tests/SpiffWorkflow/core/specs/__init__.py diff --git a/tests/SpiffWorkflow/util.py b/tests/SpiffWorkflow/core/util.py similarity index 83% rename from tests/SpiffWorkflow/util.py rename to tests/SpiffWorkflow/core/util.py index eeba7d52b..c8f02a4f0 100644 --- a/tests/SpiffWorkflow/util.py +++ b/tests/SpiffWorkflow/core/util.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- import time -from SpiffWorkflow.task import Task, TaskState from SpiffWorkflow.workflow import Workflow +from SpiffWorkflow.specs.SubWorkflow import SubWorkflow def on_reached_cb(workflow, task, taken_path): @@ -38,7 +38,12 @@ def on_reached_cb(workflow, task, taken_path): old = task.get_data('data', '') data = task.get_name() + ': ' + atts + '/' + props + '\n' task.set_data(data=old + data) + return True +def on_complete_cb(workflow, task, taken_path): + # Record the path. + indent = ' ' * (task._get_depth() - 1) + taken_path.append('%s%s' % (indent, task.get_name())) # In workflows that load a subworkflow, the newly loaded children # will not have on_reached_cb() assigned. By using this function, we # re-assign the function in every step, thus making sure that new @@ -47,22 +52,24 @@ def on_reached_cb(workflow, task, taken_path): track_task(child.task_spec, taken_path) return True - -def on_complete_cb(workflow, task, taken_path): - # Record the path. - indent = ' ' * (task._get_depth() - 1) - taken_path.append('%s%s' % (indent, task.get_name())) +def on_entered_cb(workflow, task, taken_path): + for child in task.children: + track_task(child.task_spec, taken_path) return True - def track_task(task_spec, taken_path): + # Disconnecting and reconnecting makes absolutely no sense but inexplicably these tests break + # if just connected based on a check that they're not if task_spec.reached_event.is_connected(on_reached_cb): task_spec.reached_event.disconnect(on_reached_cb) task_spec.reached_event.connect(on_reached_cb, taken_path) if task_spec.completed_event.is_connected(on_complete_cb): task_spec.completed_event.disconnect(on_complete_cb) task_spec.completed_event.connect(on_complete_cb, taken_path) - + if isinstance(task_spec, SubWorkflow): + if task_spec.entered_event.is_connected(on_entered_cb): + task_spec.entered_event.disconnect(on_entered_cb) + task_spec.entered_event.connect(on_entered_cb, taken_path) def track_workflow(wf_spec, taken_path=None): if taken_path is None: @@ -71,7 +78,6 @@ def track_workflow(wf_spec, taken_path=None): track_task(wf_spec.task_specs[name], taken_path) return taken_path - def run_workflow(test, wf_spec, expected_path, expected_data, workflow=None): # Execute all tasks within the Workflow. if workflow is None: @@ -85,7 +91,7 @@ def run_workflow(test, wf_spec, expected_path, expected_data, workflow=None): # We allow the workflow to require a maximum of 5 seconds to # complete, to allow for testing long running tasks. for i in range(10): - workflow.complete_all(False) + workflow.run_all(False) if workflow.is_completed(): break time.sleep(0.5) @@ -93,13 +99,7 @@ def run_workflow(test, wf_spec, expected_path, expected_data, workflow=None): workflow.task_tree.dump() raise - # workflow.task_tree.dump() - test.assertTrue(workflow.is_completed(), workflow.task_tree.get_dump()) - - # Make sure that there are no waiting tasks left in the tree. - for thetask in Task.Iterator(workflow.task_tree, TaskState.READY): - workflow.task_tree.dump() - raise Exception('Task with state READY: %s' % thetask.name) + test.assertTrue(workflow.is_completed()) # Check whether the correct route was taken. if expected_path is not None: diff --git a/tests/SpiffWorkflow/data/empty1.xml b/tests/SpiffWorkflow/data/empty1.xml deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/SpiffWorkflow/data/empty2.xml b/tests/SpiffWorkflow/data/empty2.xml deleted file mode 100644 index 4adc209d8..000000000 --- a/tests/SpiffWorkflow/data/empty2.xml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/arbitrary_cycles.path b/tests/SpiffWorkflow/data/spiff/control-flow/arbitrary_cycles.path deleted file mode 100644 index 3009ea82e..000000000 --- a/tests/SpiffWorkflow/data/spiff/control-flow/arbitrary_cycles.path +++ /dev/null @@ -1,10 +0,0 @@ -Start - first - excl_choice_1 - go_to_repetition - return_to_first - first - excl_choice_1 - task_c1 - last - End diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/blocking_discriminator.path b/tests/SpiffWorkflow/data/spiff/control-flow/blocking_discriminator.path deleted file mode 100644 index aa1fa1eb1..000000000 --- a/tests/SpiffWorkflow/data/spiff/control-flow/blocking_discriminator.path +++ /dev/null @@ -1,14 +0,0 @@ -Start - first - task_f1 - struct_discriminator_1 - excl_choice_1 - return_to_first - first - task_f1 - struct_discriminator_1 - excl_choice_1 - last - End - task_f2 - task_f3 diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/blocking_partial_join.path b/tests/SpiffWorkflow/data/spiff/control-flow/blocking_partial_join.path deleted file mode 100644 index ac1c7c858..000000000 --- a/tests/SpiffWorkflow/data/spiff/control-flow/blocking_partial_join.path +++ /dev/null @@ -1,15 +0,0 @@ -Start - multi_choice_1 - task_e1 - task_e3 - struct_synch_merge_1 - excl_choice_1 - return_to_multi_choice_1 - multi_choice_1 - task_e1 - task_e3 - struct_synch_merge_1 - excl_choice_1 - last - End - task_e4 diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/cancelling_discriminator.path b/tests/SpiffWorkflow/data/spiff/control-flow/cancelling_discriminator.path deleted file mode 100644 index a56b255eb..000000000 --- a/tests/SpiffWorkflow/data/spiff/control-flow/cancelling_discriminator.path +++ /dev/null @@ -1,12 +0,0 @@ -Start - first - task_f1 - struct_discriminator_1 - excl_choice_1 - return_to_first - first - task_f1 - struct_discriminator_1 - excl_choice_1 - last - End diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/cancelling_partial_join.path b/tests/SpiffWorkflow/data/spiff/control-flow/cancelling_partial_join.path deleted file mode 100644 index 74fd5b2fb..000000000 --- a/tests/SpiffWorkflow/data/spiff/control-flow/cancelling_partial_join.path +++ /dev/null @@ -1,13 +0,0 @@ -Start - multi_choice_1 - task_e1 - task_e3 - struct_synch_merge_1 - excl_choice_1 - return_to_multi_choice_1 - multi_choice_1 - task_e1 - struct_synch_merge_1 - excl_choice_1 - last - End diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/general_synchronizing_merge.path b/tests/SpiffWorkflow/data/spiff/control-flow/general_synchronizing_merge.path deleted file mode 100644 index 4c5758087..000000000 --- a/tests/SpiffWorkflow/data/spiff/control-flow/general_synchronizing_merge.path +++ /dev/null @@ -1,21 +0,0 @@ -Start - first - task_a1 - task_b1 - task_c1 - loop_back_to_c1_once - join - End - return_to_task_c1 - task_c1 - loop_back_to_c1_once - task_c2 - go_to_stub - stub_1 - loop_back_to_stub_1_once - return_to_stub_1 - stub_1 - loop_back_to_stub_1_once - go_to_stub_3 - stub_3 - foo diff --git a/tests/SpiffWorkflow/data/spiff/control-flow/generalized_and_join.path b/tests/SpiffWorkflow/data/spiff/control-flow/generalized_and_join.path deleted file mode 100644 index 7fbb5ffff..000000000 --- a/tests/SpiffWorkflow/data/spiff/control-flow/generalized_and_join.path +++ /dev/null @@ -1,22 +0,0 @@ -Start - first - task_e1 - task_f1 - task_e2 - task_f2 - task_e3 - task_f3 - struct_synch_merge_1 - excl_choice_1 - return_to_first - first - task_e1 - task_f1 - task_e2 - task_f2 - task_e3 - task_f3 - struct_synch_merge_1 - excl_choice_1 - last - End diff --git a/tests/SpiffWorkflow/data/spiff/workflow1.path b/tests/SpiffWorkflow/data/spiff/workflow1.path deleted file mode 100644 index 0b5bc042b..000000000 --- a/tests/SpiffWorkflow/data/spiff/workflow1.path +++ /dev/null @@ -1,41 +0,0 @@ -Start - task_a1 - task_a2 - task_b1 - task_b2 - synch_1 - excl_choice_1 - task_c1 - excl_choice_2 - task_d3 - multi_choice_1 - task_e1 - task_e3 - struct_synch_merge_1 - task_f1 - struct_discriminator_1 - excl_choice_3 - return_to_excl_choice_1 - excl_choice_1 - task_c1 - excl_choice_2 - task_d3 - multi_choice_1 - task_e1 - task_e3 - struct_synch_merge_1 - task_f1 - struct_discriminator_1 - excl_choice_3 - multi_instance_1 - task_g1 - task_g2 - task_g1 - task_g2 - task_g1 - task_g2 - struct_synch_merge_2 - last - End - task_f2 - task_f3 diff --git a/tests/SpiffWorkflow/dmn/python_engine/InvalidBusinessRuleNameErrorTest.py b/tests/SpiffWorkflow/dmn/python_engine/InvalidBusinessRuleNameErrorTest.py index 4e6130576..adc474d40 100644 --- a/tests/SpiffWorkflow/dmn/python_engine/InvalidBusinessRuleNameErrorTest.py +++ b/tests/SpiffWorkflow/dmn/python_engine/InvalidBusinessRuleNameErrorTest.py @@ -10,7 +10,7 @@ class InvalidBusinessRuleNameErrorTest(unittest.TestCase): try: res = runner.decide({'spam': 1}) except Exception as e: - self.assertRegexpMatches(str(e), "Did you mean 'spam'") + self.assertRegex(str(e), "Did you mean 'spam'") def suite(): return unittest.TestLoader().loadTestsFromTestCase(InvalidBusinessRuleNameErrorTest) diff --git a/tests/SpiffWorkflow/serializer/baseTest.py b/tests/SpiffWorkflow/serializer/baseTest.py deleted file mode 100644 index 7ac41f3c7..000000000 --- a/tests/SpiffWorkflow/serializer/baseTest.py +++ /dev/null @@ -1,88 +0,0 @@ -# -*- coding: utf-8 -*- - -from builtins import str -import sys -import unittest -import os -import warnings -dirname = os.path.dirname(__file__) -data_dir = os.path.join(dirname, '..', 'data') -sys.path.insert(0, os.path.join(dirname, '..')) - -from PatternTest import run_workflow, PatternTest -from SpiffWorkflow.serializer.base import Serializer -from SpiffWorkflow.specs.WorkflowSpec import WorkflowSpec -from SpiffWorkflow.workflow import Workflow -from SpiffWorkflow.serializer.exceptions import TaskNotSupportedError - - -class SerializerTest(PatternTest): - - def setUp(self): - super(SerializerTest, self).setUp() - self.serializer = Serializer() - self.return_type = None - - def _prepare_result(self, item): - return item - - def _compare_results(self, item1, item2, exclude_dynamic=False, - exclude_items=None): - #with open('1.xml', 'w') as fp: fp.write(item1) - #with open('2.xml', 'w') as fp: fp.write(item2) - self.assertEqual(item1.decode('utf8'), item2.decode('utf8')) - - def _test_roundtrip_serialization(self, obj): - # Test round trip serialization. - try: - serialized1 = obj.serialize(self.serializer) - restored = obj.__class__.deserialize(self.serializer, serialized1) - serialized2 = restored.serialize(self.serializer) - except TaskNotSupportedError as e: - warnings.warn('unsupported task spec: ' + str(e)) - return - self.assertIsInstance(serialized1, self.return_type) - self.assertIsInstance(serialized2, self.return_type) - serialized1 = self._prepare_result(serialized1) - serialized2 = self._prepare_result(serialized2) - self._compare_results(serialized1, serialized2) - return serialized1 - - def _test_workflow_spec(self, test): - spec_result1 = self._test_roundtrip_serialization(test.spec) - spec_result2 = self._test_roundtrip_serialization(test.spec) - self.assertEqual(spec_result1, spec_result2) - self._compare_results(spec_result1, spec_result2) - - workflow = run_workflow(self, test.spec, test.path, test.data) - spec_result3 = self._test_roundtrip_serialization(test.spec) - wf_result3 = self._test_roundtrip_serialization(workflow) - # We can't compare spec_result 2 and 3, because starting a workflow - # implicitely causes a Root node to be added to the workflow spec. - # (No, that doesn't seem to be a clean solution.) - # self.assertEqual(spec_result2, spec_result3) - # self._compare_results(spec_result2, spec_result3) - - def testWorkflowSpec(self): - if type(self.serializer) is Serializer: - spec = self.workflows[0].spec - wf = Workflow(spec) - self.assertRaises(NotImplementedError, spec.serialize, - self.serializer) - self.assertRaises(NotImplementedError, - WorkflowSpec.deserialize, self.serializer, None) - self.assertRaises(NotImplementedError, wf.serialize, - self.serializer) - self.assertRaises(NotImplementedError, - Workflow.deserialize, self.serializer, None) - return - - for test in self.workflows: - print(test.filename) - self._test_workflow_spec(test) - - -def suite(): - return unittest.defaultTestLoader.loadTestsFromTestCase(SerializerTest) -if __name__ == '__main__': - unittest.TextTestRunner(verbosity=2).run(suite()) diff --git a/tests/SpiffWorkflow/serializer/dictTest.py b/tests/SpiffWorkflow/serializer/dictTest.py deleted file mode 100644 index 4143ec605..000000000 --- a/tests/SpiffWorkflow/serializer/dictTest.py +++ /dev/null @@ -1,73 +0,0 @@ -# -*- coding: utf-8 -*- - -from builtins import str -import sys -import unittest -import os -dirname = os.path.dirname(__file__) -sys.path.insert(0, os.path.join(dirname, '..', '..', '..')) - -import uuid -from SpiffWorkflow.serializer.dict import DictionarySerializer -from .baseTest import SerializerTest -from SpiffWorkflow.workflow import Workflow - - -class DictionarySerializerTest(SerializerTest): - - def setUp(self): - super(DictionarySerializerTest, self).setUp() - self.serializer = DictionarySerializer() - self.return_type = dict - - def _compare_results(self, item1, item2, - exclude_dynamic=False, - exclude_items=None): - exclude_items = exclude_items if exclude_items is not None else [] - if exclude_dynamic: - if 'last_state_change' not in exclude_items: - exclude_items.append('last_state_change') - if 'last_task' not in exclude_items: - exclude_items.append('last_task') - if uuid.UUID not in exclude_items: - exclude_items.append(uuid.UUID) - if type(item1) in exclude_items: - return - - if isinstance(item1, dict): - self.assertIsInstance(item2, dict) - for key, value in list(item1.items()): - self.assertIn(key, item2) - if key in exclude_items: - continue - self._compare_results(value, item2[key], - exclude_dynamic=exclude_dynamic, - exclude_items=exclude_items) - for key in item2: - self.assertIn(key, item1) - - elif isinstance(item1, list): - msg = "item is not a list (is a " + str(type(item2)) + ")" - self.assertIsInstance(item2, list, msg) - msg = "list lengths differ: {} vs {}".format( - len(item1), len(item2)) - self.assertEqual(len(item1), len(item2), msg) - for i, listitem in enumerate(item1): - self._compare_results(listitem, item2[i], - exclude_dynamic=exclude_dynamic, - exclude_items=exclude_items) - - elif isinstance(item1, Workflow): - raise Exception("Item is a Workflow") - - else: - msg = "{}: types differ: {} vs {}".format( - str(item2), type(item1), type(item2)) - self.assertEqual(type(item1), type(item2), msg) - self.assertEqual(item1, item2) - - -def suite(): - return unittest.defaultTestLoader.loadTestsFromTestCase(DictionarySerializerTest) -if __name__ == '__main__': - unittest.TextTestRunner(verbosity=2).run(suite()) diff --git a/tests/SpiffWorkflow/serializer/jsonTest.py b/tests/SpiffWorkflow/serializer/jsonTest.py deleted file mode 100644 index cfdaa4d6b..000000000 --- a/tests/SpiffWorkflow/serializer/jsonTest.py +++ /dev/null @@ -1,38 +0,0 @@ -# -*- coding: utf-8 -*- - -import sys -import unittest -import os -dirname = os.path.dirname(__file__) -sys.path.insert(0, os.path.join(dirname, '..', '..', '..')) - -import json -from SpiffWorkflow.serializer.json import JSONSerializer -from .dictTest import DictionarySerializerTest - - -class JSONSerializerTest(DictionarySerializerTest): - - def setUp(self): - super(JSONSerializerTest, self).setUp() - self.serializer = JSONSerializer() - self.return_type = str - - def _prepare_result(self, item): - return json.loads(item) - - def _compare_results(self, item1, item2, exclude_dynamic=False, - exclude_items=None): - if exclude_dynamic: - exclude_items = ['__uuid__'] - else: - exclude_items = [] - super(JSONSerializerTest, self)._compare_results(item1, item2, - exclude_dynamic=exclude_dynamic, - exclude_items=exclude_items) - - -def suite(): - return unittest.defaultTestLoader.loadTestsFromTestCase(JSONSerializerTest) -if __name__ == '__main__': - unittest.TextTestRunner(verbosity=2).run(suite()) diff --git a/tests/SpiffWorkflow/serializer/prettyxmlTest.py b/tests/SpiffWorkflow/serializer/prettyxmlTest.py deleted file mode 100644 index 25a604c66..000000000 --- a/tests/SpiffWorkflow/serializer/prettyxmlTest.py +++ /dev/null @@ -1,30 +0,0 @@ -# -*- coding: utf-8 -*- - -import sys -import unittest -import os -dirname = os.path.dirname(__file__) -data_dir = os.path.join(dirname, '..', 'data') -sys.path.insert(0, os.path.join(dirname, '..', '..', '..')) - -from SpiffWorkflow.serializer.prettyxml import XmlSerializer -from .baseTest import SerializerTest - - -class XmlSerializerTest(SerializerTest): - - def setUp(self): - super(XmlSerializerTest, self).setUp() - self.serializer = XmlSerializer() - self.return_type = str - - def testWorkflowSpec(self): - # Nothing to test here: The deserialization is already used in setUp() - # to load all specs, and serialization is not supported. - pass - - -def suite(): - return unittest.TestLoader().loadTestsFromTestCase(XmlSerializerTest) -if __name__ == '__main__': - unittest.TextTestRunner(verbosity=2).run(suite()) diff --git a/tests/SpiffWorkflow/serializer/xmlTest.py b/tests/SpiffWorkflow/serializer/xmlTest.py deleted file mode 100644 index bdffc6e9e..000000000 --- a/tests/SpiffWorkflow/serializer/xmlTest.py +++ /dev/null @@ -1,29 +0,0 @@ -# -*- coding: utf-8 -*- - -import sys -import unittest -import os -dirname = os.path.dirname(__file__) -sys.path.insert(0, os.path.join(dirname, '..')) -sys.path.insert(0, os.path.join(dirname, '..', '..', '..')) - -from lxml import etree -from SpiffWorkflow.serializer.xml import XmlSerializer -from serializer.baseTest import SerializerTest - - -class XmlSerializerTest(SerializerTest): - - def setUp(self): - super(XmlSerializerTest, self).setUp() - self.serializer = XmlSerializer() - self.return_type = etree._Element - - def _prepare_result(self, item): - return etree.tostring(item, pretty_print=True) - - -def suite(): - return unittest.TestLoader().loadTestsFromTestCase(XmlSerializerTest) -if __name__ == '__main__': - unittest.TextTestRunner(verbosity=2).run(suite()) diff --git a/tests/SpiffWorkflow/specs/__init__.py b/tests/SpiffWorkflow/specs/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/SpiffWorkflow/spiff/BaseTestCase.py b/tests/SpiffWorkflow/spiff/BaseTestCase.py index 5b8533f50..fc54e82b7 100644 --- a/tests/SpiffWorkflow/spiff/BaseTestCase.py +++ b/tests/SpiffWorkflow/spiff/BaseTestCase.py @@ -3,13 +3,10 @@ import os from SpiffWorkflow.spiff.parser.process import SpiffBpmnParser, VALIDATOR from SpiffWorkflow.spiff.serializer.config import SPIFF_SPEC_CONFIG -from SpiffWorkflow.dmn.serializer.task_spec import BusinessRuleTaskConverter from SpiffWorkflow.bpmn.serializer.workflow import BpmnWorkflowSerializer from tests.SpiffWorkflow.bpmn.BpmnWorkflowTestCase import BpmnWorkflowTestCase -SPIFF_SPEC_CONFIG['task_specs'].append(BusinessRuleTaskConverter) - wf_spec_converter = BpmnWorkflowSerializer.configure_workflow_spec_converter(SPIFF_SPEC_CONFIG) class BaseTestCase(BpmnWorkflowTestCase): diff --git a/tests/SpiffWorkflow/spiff/BusinessRuleTaskTest.py b/tests/SpiffWorkflow/spiff/BusinessRuleTaskTest.py index f738b7da7..c32262c5f 100644 --- a/tests/SpiffWorkflow/spiff/BusinessRuleTaskTest.py +++ b/tests/SpiffWorkflow/spiff/BusinessRuleTaskTest.py @@ -9,4 +9,4 @@ class BusinessRuleTaskTest(BaseTestCase): self.workflow = BpmnWorkflow(spec, subprocesses) self.save_restore() self.workflow.do_engine_steps() - self.assertTrue(self.workflow.is_completed()) \ No newline at end of file + self.assertTrue(self.workflow.is_completed()) diff --git a/tests/SpiffWorkflow/spiff/CorrelationTest.py b/tests/SpiffWorkflow/spiff/CorrelationTest.py index c44be2a45..014e8f8ed 100644 --- a/tests/SpiffWorkflow/spiff/CorrelationTest.py +++ b/tests/SpiffWorkflow/spiff/CorrelationTest.py @@ -23,14 +23,14 @@ class CorrelationTest(BaseTestCase): task.data['task_num'] = idx task.data['task_name'] = f'subprocess {idx}' task.data['extra_data'] = f'unused data' - task.complete() + task.run() self.workflow.do_engine_steps() ready_tasks = self.workflow.get_ready_user_tasks() for task in ready_tasks: self.assertEqual(task.task_spec.name, 'prepare_response') response = 'OK' if task.data['source_task']['num'] else 'No' task.data.update(response=response) - task.complete() + task.run() self.workflow.do_engine_steps() # If the messages were routed properly, the task number should match the response id for task in self.workflow.get_tasks_from_spec_name('subprocess_end'): diff --git a/tests/SpiffWorkflow/spiff/MultiInstanceTaskTest.py b/tests/SpiffWorkflow/spiff/MultiInstanceTaskTest.py index 61e89e1fd..31108b9b9 100644 --- a/tests/SpiffWorkflow/spiff/MultiInstanceTaskTest.py +++ b/tests/SpiffWorkflow/spiff/MultiInstanceTaskTest.py @@ -19,7 +19,7 @@ class MultiInstanceTaskTest(BaseTestCase): ready_tasks = self.workflow.get_ready_user_tasks() for task in ready_tasks: task.data['output_item'] = task.data['input_item'] * 2 - task.complete() + task.run() self.workflow.do_engine_steps() self.assertTrue(self.workflow.is_completed()) diff --git a/tests/SpiffWorkflow/spiff/PrescriptPostscriptTest.py b/tests/SpiffWorkflow/spiff/PrescriptPostscriptTest.py index 320586a9b..f928f80c8 100644 --- a/tests/SpiffWorkflow/spiff/PrescriptPostscriptTest.py +++ b/tests/SpiffWorkflow/spiff/PrescriptPostscriptTest.py @@ -27,7 +27,7 @@ class PrescriptPostsciptTest(BaseTestCase): self.set_process_data({'b': 2}) ready_tasks = self.workflow.get_tasks(TaskState.READY) # This execute the same script as task_test - ready_tasks[0].complete() + ready_tasks[0].run() # a should be removed, b should be unchanged, and c and z should be present (but not x & y) self.assertDictEqual({'b': 2, 'c': 12, 'z': 6}, ready_tasks[0].data) @@ -43,7 +43,7 @@ class PrescriptPostsciptTest(BaseTestCase): # The prescript sets x, y = a * 2, b * 2 and creates the variable z = x + y # The postscript sets c = z * 2 and deletes x and y # a and b should remain unchanged, and c and z should be added - ready_tasks[0].complete() + ready_tasks[0].run() self.assertDictEqual({'a': 1, 'b': 2, 'c': 12, 'z': 6}, ready_tasks[0].data) def test_for_error(self, save_restore=False):