mirror of
https://github.com/status-im/spiff-arena.git
synced 2025-01-10 02:05:40 +00:00
f1b8cfcc07
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
104 lines
3.3 KiB
Python
104 lines
3.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
from SpiffWorkflow.bpmn.specs.data_spec import BpmnDataStoreSpecification
|
|
from SpiffWorkflow.bpmn.specs.ExclusiveGateway import ExclusiveGateway
|
|
from SpiffWorkflow.bpmn.specs.UserTask import UserTask
|
|
from SpiffWorkflow.bpmn.parser.BpmnParser import BpmnParser
|
|
from SpiffWorkflow.bpmn.parser.TaskParser import TaskParser
|
|
from SpiffWorkflow.bpmn.parser.task_parsers import ConditionalGatewayParser
|
|
from SpiffWorkflow.bpmn.parser.util import full_tag
|
|
|
|
from SpiffWorkflow.bpmn.serializer.helpers.spec import BpmnSpecConverter, TaskSpecConverter
|
|
|
|
# Many of our tests relied on the Packager to set the calledElement attribute on
|
|
# Call Activities. I've moved that code to a customized parser.
|
|
from SpiffWorkflow.signavio.parser.tasks import CallActivityParser
|
|
from SpiffWorkflow.bpmn.specs.SubWorkflowTask import CallActivity
|
|
|
|
__author__ = 'matth'
|
|
|
|
# This provides some extensions to the BPMN parser that make it easier to
|
|
# implement testcases
|
|
|
|
|
|
class TestUserTask(UserTask):
|
|
|
|
def get_user_choices(self):
|
|
if not self.outputs:
|
|
return []
|
|
assert len(self.outputs) == 1
|
|
next_node = self.outputs[0]
|
|
if isinstance(next_node, ExclusiveGateway):
|
|
return next_node.get_outgoing_sequence_names()
|
|
return self.get_outgoing_sequence_names()
|
|
|
|
def do_choice(self, task, choice):
|
|
task.set_data(choice=choice)
|
|
task.run()
|
|
|
|
|
|
class TestExclusiveGatewayParser(ConditionalGatewayParser):
|
|
|
|
def parse_condition(self, sequence_flow_node):
|
|
cond = super().parse_condition(sequence_flow_node)
|
|
if cond is not None:
|
|
return cond
|
|
return "choice == '%s'" % sequence_flow_node.get('name', None)
|
|
|
|
class TestUserTaskConverter(TaskSpecConverter):
|
|
|
|
def __init__(self, data_converter=None):
|
|
super().__init__(TestUserTask, data_converter)
|
|
|
|
def to_dict(self, spec):
|
|
dct = self.get_default_attributes(spec)
|
|
dct.update(self.get_bpmn_attributes(spec))
|
|
return dct
|
|
|
|
def from_dict(self, dct):
|
|
return self.task_spec_from_dict(dct)
|
|
|
|
class TestDataStore(BpmnDataStoreSpecification):
|
|
|
|
_value = None
|
|
|
|
def get(self, my_task):
|
|
"""Copy a value from a data store into task data."""
|
|
my_task.data[self.name] = TestDataStore._value
|
|
|
|
def set(self, my_task):
|
|
"""Copy a value from the task data to the data store"""
|
|
TestDataStore._value = my_task.data[self.name]
|
|
del my_task.data[self.name]
|
|
|
|
class TestDataStoreConverter(BpmnSpecConverter):
|
|
|
|
def __init__(self, registry):
|
|
super().__init__(TestDataStore, registry)
|
|
|
|
def to_dict(self, spec):
|
|
return {
|
|
"name": spec.name,
|
|
"description": spec.description,
|
|
"capacity": spec.capacity,
|
|
"is_unlimited": spec.is_unlimited,
|
|
"_value": TestDataStore._value,
|
|
}
|
|
|
|
def from_dict(self, dct):
|
|
_value = dct.pop("_value")
|
|
data_store = TestDataStore(**dct)
|
|
TestDataStore._value = _value
|
|
return data_store
|
|
|
|
class TestBpmnParser(BpmnParser):
|
|
OVERRIDE_PARSER_CLASSES = {
|
|
full_tag('userTask'): (TaskParser, TestUserTask),
|
|
full_tag('exclusiveGateway'): (TestExclusiveGatewayParser, ExclusiveGateway),
|
|
full_tag('callActivity'): (CallActivityParser, CallActivity)
|
|
}
|
|
|
|
DATA_STORE_CLASSES = {
|
|
"TestDataStore": TestDataStore,
|
|
}
|