cleaned up runner tests and rsyncd back to sample w/ burnettk

This commit is contained in:
jasquat 2023-05-18 17:16:58 -04:00
parent 50761c7033
commit 101ed1d46f
No known key found for this signature in database
35 changed files with 492 additions and 53 deletions

View File

@ -115,7 +115,7 @@ sphinx-click = "^4.3.0"
Pygments = "^2.10.0"
pyupgrade = "^3.1.0"
furo = ">=2021.11.12"
myst-parser = "^0.15.1"
# myst-parser = "^0.15.1"
[tool.poetry.scripts]
spiffworkflow-backend = "spiffworkflow_backend.__main__:main"

View File

@ -39,6 +39,10 @@ class NoTestCasesFoundError(Exception):
pass
class MissingInputTaskData(Exception):
pass
@dataclass
class TestCaseResult:
passed: bool
@ -115,13 +119,11 @@ class ProcessModelTestRunner:
def failing_tests_formatted(self) -> str:
formatted_tests = ["FAILING TESTS:"]
for failing_test in self.failing_tests():
msg = ''
msg = ""
if failing_test.error_messages:
msg = '\n\t\t'.join(failing_test.error_messages)
formatted_tests.append(
f'\t{failing_test.bpmn_file}: {failing_test.test_case_name}: {msg}'
)
return '\n'.join(formatted_tests)
msg = "\n\t\t".join(failing_test.error_messages)
formatted_tests.append(f"\t{failing_test.bpmn_file}: {failing_test.test_case_name}: {msg}")
return "\n".join(formatted_tests)
def run(self) -> None:
if len(self.test_mappings.items()) < 1:
@ -133,10 +135,11 @@ class ProcessModelTestRunner:
json_file_contents = json.loads(f.read())
for test_case_name, test_case_contents in json_file_contents.items():
self.task_data_index = {}
try:
self.run_test_case(bpmn_file, test_case_name, test_case_contents)
except Exception as ex:
ex_as_array = str(ex).split('\n')
ex_as_array = str(ex).split("\n")
self._add_test_result(False, bpmn_file, test_case_name, ex_as_array)
def run_test_case(self, bpmn_file: str, test_case_name: str, test_case_contents: dict) -> None:
@ -224,7 +227,9 @@ class ProcessModelTestRunner:
bpmn_process_identifier = bpmn_process_element.attrib["id"]
self.bpmn_processes_to_file_mappings[bpmn_process_identifier] = file_norm
def _execute_task(self, spiff_task: SpiffTask, test_case_task_key: str, test_case_task_properties: Optional[dict]) -> None:
def _execute_task(
self, spiff_task: SpiffTask, test_case_task_key: str, test_case_task_properties: Optional[dict]
) -> None:
if self.execute_task_callback:
self.execute_task_callback(spiff_task, test_case_task_key, test_case_task_properties)
self._default_execute_task(spiff_task, test_case_task_key, test_case_task_properties)
@ -245,12 +250,21 @@ class ProcessModelTestRunner:
return ready_tasks[0]
return None
def _default_execute_task(self, spiff_task: SpiffTask, test_case_task_key: str, test_case_task_properties: Optional[dict]) -> None:
def _default_execute_task(
self, spiff_task: SpiffTask, test_case_task_key: str, test_case_task_properties: Optional[dict]
) -> None:
if spiff_task.task_spec.manual or spiff_task.task_spec.__class__.__name__ == "ServiceTask":
if test_case_task_properties and "data" in test_case_task_properties:
if test_case_task_key not in self.task_data_index:
self.task_data_index[test_case_task_key] = 0
spiff_task.update_data(test_case_task_properties["data"][self.task_data_index[test_case_task_key]])
task_data_length = len(test_case_task_properties["data"])
test_case_index = self.task_data_index[test_case_task_key]
if task_data_length <= test_case_index:
raise MissingInputTaskData(
f"Missing input task data for task: {test_case_task_key}. "
f"Only {task_data_length} given in the json but task was called {test_case_index + 1} times"
)
spiff_task.update_data(test_case_task_properties["data"][test_case_index])
self.task_data_index[test_case_task_key] += 1
spiff_task.complete()
else:
@ -297,7 +311,9 @@ class ProcessModelTestRunner:
def _get_relative_path_of_bpmn_file(self, bpmn_file: str) -> str:
return os.path.relpath(bpmn_file, start=self.process_model_directory_path)
def _add_test_result(self, passed: bool, bpmn_file: str, test_case_name: str, error_messages: Optional[list[str]] = None) -> None:
def _add_test_result(
self, passed: bool, bpmn_file: str, test_case_name: str, error_messages: Optional[list[str]] = None
) -> None:
bpmn_file_relative = self._get_relative_path_of_bpmn_file(bpmn_file)
test_result = TestCaseResult(
passed=passed,

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_96f6665" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.0.0-dev">
<bpmn:process id="BasicCallActivityProcess" isExecutable="true">
<bpmn:process id="CallActivityProcess" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>Flow_0ext5lt</bpmn:outgoing>
</bpmn:startEvent>
@ -9,7 +9,7 @@
<bpmn:incoming>Flow_1hzwssi</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="Flow_1hzwssi" sourceRef="Activity_0irfg4l" targetRef="Event_0bz40ol" />
<bpmn:callActivity id="Activity_0irfg4l" name="Call Activity" calledElement="BasicManualTaskProcess">
<bpmn:callActivity id="Activity_0irfg4l" name="Call Activity" calledElement="ManualTaskProcess">
<bpmn:incoming>Flow_0ext5lt</bpmn:incoming>
<bpmn:outgoing>Flow_1hzwssi</bpmn:outgoing>
</bpmn:callActivity>

View File

@ -0,0 +1,9 @@
{
"description": "",
"display_name": "Call Activity",
"exception_notification_addresses": [],
"fault_or_suspend_on_exception": "fault",
"files": [],
"primary_file_name": "call_activity.bpmn",
"primary_process_id": "CallActivityProcess"
}

View File

@ -0,0 +1,11 @@
{
"title": "Choose Your Branch",
"description": "",
"properties": {
"branch": {
"type": "string",
"title": "branch"
}
},
"required": []
}

View File

@ -0,0 +1,98 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:spiffworkflow="http://spiffworkflow.org/bpmn/schema/1.0/core" id="Definitions_96f6665" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.0.0-dev">
<bpmn:process id="exclusive_gateway_based_on_user_task_process" name="ExclusiveGatewayBasedOnUserTaskProcess" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>Flow_19j3jcx</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="Flow_19j3jcx" sourceRef="StartEvent_1" targetRef="user_task_choose_branch" />
<bpmn:exclusiveGateway id="Gateway_0xwvfep" default="Flow_10m4g0q">
<bpmn:incoming>Flow_0qa66xz</bpmn:incoming>
<bpmn:outgoing>Flow_1ww41l3</bpmn:outgoing>
<bpmn:outgoing>Flow_10m4g0q</bpmn:outgoing>
</bpmn:exclusiveGateway>
<bpmn:sequenceFlow id="Flow_0qa66xz" sourceRef="user_task_choose_branch" targetRef="Gateway_0xwvfep" />
<bpmn:sequenceFlow id="Flow_1ww41l3" sourceRef="Gateway_0xwvfep" targetRef="script_task_branch_a">
<bpmn:conditionExpression>branch == 'a'</bpmn:conditionExpression>
</bpmn:sequenceFlow>
<bpmn:sequenceFlow id="Flow_10m4g0q" sourceRef="Gateway_0xwvfep" targetRef="script_task_branch_b" />
<bpmn:endEvent id="Event_05ovp79">
<bpmn:incoming>Flow_1oxbb75</bpmn:incoming>
<bpmn:incoming>Flow_1ck9lfk</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="Flow_1oxbb75" sourceRef="script_task_branch_b" targetRef="Event_05ovp79" />
<bpmn:sequenceFlow id="Flow_1ck9lfk" sourceRef="script_task_branch_a" targetRef="Event_05ovp79" />
<bpmn:userTask id="user_task_choose_branch" name="User Task Choose Branch">
<bpmn:extensionElements>
<spiffworkflow:properties>
<spiffworkflow:property name="formJsonSchemaFilename" value="choose-your-branch-schema.json" />
<spiffworkflow:property name="formUiSchemaFilename" value="choose-your-branch-uischema.json" />
</spiffworkflow:properties>
</bpmn:extensionElements>
<bpmn:incoming>Flow_19j3jcx</bpmn:incoming>
<bpmn:outgoing>Flow_0qa66xz</bpmn:outgoing>
</bpmn:userTask>
<bpmn:scriptTask id="script_task_branch_a" name="Script Task Branch A">
<bpmn:incoming>Flow_1ww41l3</bpmn:incoming>
<bpmn:outgoing>Flow_1ck9lfk</bpmn:outgoing>
<bpmn:script>chosen_branch = 'A'</bpmn:script>
</bpmn:scriptTask>
<bpmn:scriptTask id="script_task_branch_b" name="Script Task Branch B">
<bpmn:incoming>Flow_10m4g0q</bpmn:incoming>
<bpmn:outgoing>Flow_1oxbb75</bpmn:outgoing>
<bpmn:script>chosen_branch = 'B'</bpmn:script>
</bpmn:scriptTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="exclusive_gateway_based_on_user_task_process">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="179" y="159" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Gateway_0xwvfep_di" bpmnElement="Gateway_0xwvfep" isMarkerVisible="true">
<dc:Bounds x="425" y="152" width="50" height="50" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_05ovp79_di" bpmnElement="Event_05ovp79">
<dc:Bounds x="562" y="159" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_15rk06j_di" bpmnElement="user_task_choose_branch">
<dc:Bounds x="270" y="137" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0oy60uv_di" bpmnElement="script_task_branch_a">
<dc:Bounds x="500" y="20" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_02hkehe_di" bpmnElement="script_task_branch_b">
<dc:Bounds x="500" y="260" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_19j3jcx_di" bpmnElement="Flow_19j3jcx">
<di:waypoint x="215" y="177" />
<di:waypoint x="270" y="177" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0qa66xz_di" bpmnElement="Flow_0qa66xz">
<di:waypoint x="370" y="177" />
<di:waypoint x="425" y="177" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1ww41l3_di" bpmnElement="Flow_1ww41l3">
<di:waypoint x="450" y="152" />
<di:waypoint x="450" y="60" />
<di:waypoint x="500" y="60" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_10m4g0q_di" bpmnElement="Flow_10m4g0q">
<di:waypoint x="450" y="202" />
<di:waypoint x="450" y="300" />
<di:waypoint x="500" y="300" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1oxbb75_di" bpmnElement="Flow_1oxbb75">
<di:waypoint x="550" y="260" />
<di:waypoint x="550" y="233" />
<di:waypoint x="580" y="233" />
<di:waypoint x="580" y="195" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1ck9lfk_di" bpmnElement="Flow_1ck9lfk">
<di:waypoint x="550" y="100" />
<di:waypoint x="550" y="130" />
<di:waypoint x="580" y="130" />
<di:waypoint x="580" y="159" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>

View File

@ -0,0 +1,11 @@
{
"description": "",
"display_name": "Exclusive Gateway Based on User Task",
"display_order": 0,
"exception_notification_addresses": [],
"fault_or_suspend_on_exception": "fault",
"files": [],
"metadata_extraction_paths": null,
"primary_file_name": "exclusive_gateway_based_on_user_task.bpmn",
"primary_process_id": "exclusive_gateway_based_on_user_task_process"
}

View File

@ -0,0 +1,22 @@
{
"test_case_one": {
"tasks": {
"user_task_choose_branch": {
"data": [
{ "branch": "a" }
]
}
},
"expected_output_json": { "branch": "a", "chosen_branch": "A"}
},
"test_case_two": {
"tasks": {
"user_task_choose_branch": {
"data": [
{ "branch": "b" }
]
}
},
"expected_output_json": { "branch": "b", "chosen_branch": "B"}
}
}

View File

@ -0,0 +1,110 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:spiffworkflow="http://spiffworkflow.org/bpmn/schema/1.0/core" id="Definitions_96f6665" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.0.0-dev">
<bpmn:process id="loopback_to_user_task_process" name="Loopback To User Task Process" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>Flow_12xxe7w</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="Flow_12xxe7w" sourceRef="StartEvent_1" targetRef="set_variable" />
<bpmn:exclusiveGateway id="Gateway_1gap20a" default="Flow_1sg0c65">
<bpmn:incoming>Flow_1s3znr2</bpmn:incoming>
<bpmn:outgoing>Flow_0utss6p</bpmn:outgoing>
<bpmn:outgoing>Flow_1sg0c65</bpmn:outgoing>
</bpmn:exclusiveGateway>
<bpmn:sequenceFlow id="Flow_08tc3r7" sourceRef="set_variable" targetRef="user_task_enter_increment" />
<bpmn:endEvent id="Event_1il3y5o">
<bpmn:incoming>Flow_0utss6p</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="Flow_0utss6p" sourceRef="Gateway_1gap20a" targetRef="Event_1il3y5o">
<bpmn:conditionExpression>counter == 3</bpmn:conditionExpression>
</bpmn:sequenceFlow>
<bpmn:scriptTask id="set_variable" name="Set Variable">
<bpmn:incoming>Flow_12xxe7w</bpmn:incoming>
<bpmn:outgoing>Flow_08tc3r7</bpmn:outgoing>
<bpmn:script>counter = 1
the_var = 0</bpmn:script>
</bpmn:scriptTask>
<bpmn:sequenceFlow id="Flow_0wnc5ju" sourceRef="user_task_enter_increment" targetRef="add_user_input_to_variable" />
<bpmn:sequenceFlow id="Flow_1sg0c65" sourceRef="Gateway_1gap20a" targetRef="user_task_enter_increment" />
<bpmn:userTask id="user_task_enter_increment" name="User Task Enter Increment">
<bpmn:extensionElements>
<spiffworkflow:instructionsForEndUser />
<spiffworkflow:properties>
<spiffworkflow:property name="formJsonSchemaFilename" value="user-input-schema.json" />
<spiffworkflow:property name="formUiSchemaFilename" value="user-input-uischema.json" />
</spiffworkflow:properties>
</bpmn:extensionElements>
<bpmn:incoming>Flow_08tc3r7</bpmn:incoming>
<bpmn:incoming>Flow_1sg0c65</bpmn:incoming>
<bpmn:outgoing>Flow_0wnc5ju</bpmn:outgoing>
</bpmn:userTask>
<bpmn:sequenceFlow id="Flow_1s3znr2" sourceRef="add_user_input_to_variable" targetRef="Gateway_1gap20a" />
<bpmn:scriptTask id="add_user_input_to_variable" name="Add User Input to Variable">
<bpmn:incoming>Flow_0wnc5ju</bpmn:incoming>
<bpmn:outgoing>Flow_1s3znr2</bpmn:outgoing>
<bpmn:script>the_var = user_input_variable + the_var
counter += 1</bpmn:script>
</bpmn:scriptTask>
<bpmn:textAnnotation id="TextAnnotation_09y70ug">
<bpmn:text>loop back if a &lt; 3</bpmn:text>
</bpmn:textAnnotation>
<bpmn:association id="Association_0470wt9" sourceRef="Flow_1sg0c65" targetRef="TextAnnotation_09y70ug" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="loopback_to_user_task_process">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="179" y="159" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Gateway_1gap20a_di" bpmnElement="Gateway_1gap20a" isMarkerVisible="true">
<dc:Bounds x="625" y="152" width="50" height="50" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_1il3y5o_di" bpmnElement="Event_1il3y5o">
<dc:Bounds x="712" y="159" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0hrsdn8_di" bpmnElement="set_variable">
<dc:Bounds x="250" y="137" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0katfaf_di" bpmnElement="user_task_enter_increment">
<dc:Bounds x="380" y="137" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0a6owe7_di" bpmnElement="add_user_input_to_variable">
<dc:Bounds x="500" y="137" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="TextAnnotation_09y70ug_di" bpmnElement="TextAnnotation_09y70ug">
<dc:Bounds x="610" y="55" width="130" height="30" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_12xxe7w_di" bpmnElement="Flow_12xxe7w">
<di:waypoint x="215" y="177" />
<di:waypoint x="250" y="177" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_08tc3r7_di" bpmnElement="Flow_08tc3r7">
<di:waypoint x="350" y="177" />
<di:waypoint x="380" y="177" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0utss6p_di" bpmnElement="Flow_0utss6p">
<di:waypoint x="675" y="177" />
<di:waypoint x="712" y="177" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0wnc5ju_di" bpmnElement="Flow_0wnc5ju">
<di:waypoint x="480" y="177" />
<di:waypoint x="500" y="177" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1sg0c65_di" bpmnElement="Flow_1sg0c65">
<di:waypoint x="650" y="150" />
<di:waypoint x="550" y="70" />
<di:waypoint x="475" y="139" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1s3znr2_di" bpmnElement="Flow_1s3znr2">
<di:waypoint x="600" y="177" />
<di:waypoint x="625" y="177" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Association_0470wt9_di" bpmnElement="Association_0470wt9">
<di:waypoint x="579" y="93" />
<di:waypoint x="610" y="81" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>

View File

@ -0,0 +1,11 @@
{
"description": "",
"display_name": "Loopback to User Task",
"display_order": 0,
"exception_notification_addresses": [],
"fault_or_suspend_on_exception": "fault",
"files": [],
"metadata_extraction_paths": null,
"primary_file_name": "loopback_to_user_task.bpmn",
"primary_process_id": "loopback_to_user_task_process"
}

View File

@ -0,0 +1,13 @@
{
"test_case_one": {
"tasks": {
"user_task_enter_increment": {
"data": [
{ "user_input_variable": 7 },
{ "user_input_variable": 8 }
]
}
},
"expected_output_json": { "the_var": 15, "counter": 3, "user_input_variable": 8 }
}
}

View File

@ -0,0 +1,11 @@
{
"title": "User Input",
"description": "",
"properties": {
"user_input_variable": {
"type": "integer",
"title": "user_input_variable"
}
},
"required": []
}

View File

@ -0,0 +1,5 @@
{
"ui:order": [
"user_input_variable"
]
}

View File

@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:spiffworkflow="http://spiffworkflow.org/bpmn/schema/1.0/core" id="Definitions_96f6665" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.0.0-dev">
<bpmn:process id="loopback_process" name="Loopback Process" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>Flow_12xxe7w</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="Flow_12xxe7w" sourceRef="StartEvent_1" targetRef="set_variable" />
<bpmn:exclusiveGateway id="Gateway_1gap20a" default="Flow_1sg0c65">
<bpmn:incoming>Flow_0wnc5ju</bpmn:incoming>
<bpmn:outgoing>Flow_0utss6p</bpmn:outgoing>
<bpmn:outgoing>Flow_1sg0c65</bpmn:outgoing>
</bpmn:exclusiveGateway>
<bpmn:sequenceFlow id="Flow_08tc3r7" sourceRef="set_variable" targetRef="increment_variable" />
<bpmn:endEvent id="Event_1il3y5o">
<bpmn:incoming>Flow_0utss6p</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="Flow_0utss6p" sourceRef="Gateway_1gap20a" targetRef="Event_1il3y5o">
<bpmn:conditionExpression>a == 3</bpmn:conditionExpression>
</bpmn:sequenceFlow>
<bpmn:scriptTask id="set_variable" name="Set Variable">
<bpmn:incoming>Flow_12xxe7w</bpmn:incoming>
<bpmn:outgoing>Flow_08tc3r7</bpmn:outgoing>
<bpmn:script>a = 1</bpmn:script>
</bpmn:scriptTask>
<bpmn:sequenceFlow id="Flow_0wnc5ju" sourceRef="increment_variable" targetRef="Gateway_1gap20a" />
<bpmn:scriptTask id="increment_variable" name="Increment Variable">
<bpmn:extensionElements>
<spiffworkflow:instructionsForEndUser />
</bpmn:extensionElements>
<bpmn:incoming>Flow_08tc3r7</bpmn:incoming>
<bpmn:incoming>Flow_1sg0c65</bpmn:incoming>
<bpmn:outgoing>Flow_0wnc5ju</bpmn:outgoing>
<bpmn:script>a += 1</bpmn:script>
</bpmn:scriptTask>
<bpmn:sequenceFlow id="Flow_1sg0c65" sourceRef="Gateway_1gap20a" targetRef="increment_variable" />
<bpmn:textAnnotation id="TextAnnotation_09y70ug">
<bpmn:text>loop back if a &lt; 3</bpmn:text>
</bpmn:textAnnotation>
<bpmn:association id="Association_0470wt9" sourceRef="Flow_1sg0c65" targetRef="TextAnnotation_09y70ug" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="loopback_process">
<bpmndi:BPMNShape id="TextAnnotation_09y70ug_di" bpmnElement="TextAnnotation_09y70ug">
<dc:Bounds x="610" y="55" width="130" height="30" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="179" y="159" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Gateway_1gap20a_di" bpmnElement="Gateway_1gap20a" isMarkerVisible="true">
<dc:Bounds x="535" y="152" width="50" height="50" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_1il3y5o_di" bpmnElement="Event_1il3y5o">
<dc:Bounds x="632" y="159" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0hrsdn8_di" bpmnElement="set_variable">
<dc:Bounds x="270" y="137" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1g5b8wo_di" bpmnElement="increment_variable">
<dc:Bounds x="400" y="137" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Association_0470wt9_di" bpmnElement="Association_0470wt9">
<di:waypoint x="567.1081954098089" y="89.9595613114437" />
<di:waypoint x="610" y="81" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_12xxe7w_di" bpmnElement="Flow_12xxe7w">
<di:waypoint x="215" y="177" />
<di:waypoint x="270" y="177" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_08tc3r7_di" bpmnElement="Flow_08tc3r7">
<di:waypoint x="370" y="177" />
<di:waypoint x="400" y="177" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0utss6p_di" bpmnElement="Flow_0utss6p">
<di:waypoint x="585" y="177" />
<di:waypoint x="632" y="177" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0wnc5ju_di" bpmnElement="Flow_0wnc5ju">
<di:waypoint x="500" y="177" />
<di:waypoint x="535" y="177" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1sg0c65_di" bpmnElement="Flow_1sg0c65">
<di:waypoint x="560" y="150" />
<di:waypoint x="610" y="140" />
<di:waypoint x="550" y="70" />
<di:waypoint x="489" y="137" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>

View File

@ -0,0 +1,11 @@
{
"description": "",
"display_name": "Loopback",
"display_order": 0,
"exception_notification_addresses": [],
"fault_or_suspend_on_exception": "fault",
"files": [],
"metadata_extraction_paths": null,
"primary_file_name": "loopback.bpmn",
"primary_process_id": "loopback_process"
}

View File

@ -0,0 +1,5 @@
{
"test_case_1": {
"expected_output_json": { "a": 3 }
}
}

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_96f6665" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.0.0-dev">
<bpmn:process id="BasicManualTaskProcess" isExecutable="true">
<bpmn:process id="ManualTaskProcess" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>Flow_0gz6i84</bpmn:outgoing>
</bpmn:startEvent>
@ -15,7 +15,7 @@
</bpmn:manualTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="BasicManualTaskProcess">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ManualTaskProcess">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="179" y="159" width="36" height="36" />
</bpmndi:BPMNShape>

View File

@ -0,0 +1,9 @@
{
"description": "Manual Task",
"display_name": "Manual Task",
"exception_notification_addresses": [],
"fault_or_suspend_on_exception": "fault",
"files": [],
"primary_file_name": "manual_task.bpmn",
"primary_process_id": "ManualTaskProcess"
}

View File

@ -0,0 +1,9 @@
{
"admin": false,
"description": "",
"display_name": "Expected To Pass",
"display_order": 0,
"parent_groups": null,
"process_groups": [],
"process_models": []
}

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:spiffworkflow="http://spiffworkflow.org/bpmn/schema/1.0/core" id="Definitions_96f6665" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.0.0-dev">
<bpmn:process id="BasicServiceTaskProcess" isExecutable="true">
<bpmn:process id="ServiceTaskProcess" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>Flow_19ephzh</bpmn:outgoing>
</bpmn:startEvent>
@ -14,10 +14,10 @@
<spiffworkflow:serviceTaskOperator id="http/GetRequest" resultVariable="bamboo_get_employee">
<spiffworkflow:parameters>
<spiffworkflow:parameter id="basic_auth_password" type="str" value="&#34;x&#34;" />
<spiffworkflow:parameter id="basic_auth_username" type="str" value="&#34;secret:BAMBOOHR_API_KEY&#34;" />
<spiffworkflow:parameter id="basic_auth_username" type="str" value="&#34;x&#34;" />
<spiffworkflow:parameter id="headers" type="any" value="{&#34;Accept&#34;: &#34;application/json&#34;}" />
<spiffworkflow:parameter id="params" type="any" value="{&#34;fields&#34;: &#34;firstName,lastName&#34;}" />
<spiffworkflow:parameter id="url" type="str" value="f&#34;https://api.bamboohr.com/api/gateway.php/statusresearchdemo/v1/employees/113&#34;" />
<spiffworkflow:parameter id="params" type="any" value="{}" />
<spiffworkflow:parameter id="url" type="str" value="f&#34;https://example.com/api/user&#34;" />
</spiffworkflow:parameters>
</spiffworkflow:serviceTaskOperator>
<spiffworkflow:instructionsForEndUser>This is the Service Task Unit Test Screen.</spiffworkflow:instructionsForEndUser>
@ -28,7 +28,7 @@
</bpmn:serviceTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="BasicServiceTaskProcess">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ServiceTaskProcess">
<bpmndi:BPMNEdge id="Flow_19ephzh_di" bpmnElement="Flow_19ephzh">
<di:waypoint x="215" y="177" />
<di:waypoint x="270" y="177" />

View File

@ -1,7 +1,7 @@
{
"test_case_one": {
"test_case_1": {
"tasks": {
"BasicServiceTaskProcess:service_task_one": {
"ServiceTaskProcess:service_task_one": {
"data": [{ "the_result": "result_from_service" }]
}
},

View File

@ -1,9 +0,0 @@
{
"description": "",
"display_name": "Basic Call Activity",
"exception_notification_addresses": [],
"fault_or_suspend_on_exception": "fault",
"files": [],
"primary_file_name": "basic_call_activity.bpmn",
"primary_process_id": "BasicCallActivityProcess"
}

View File

@ -1,9 +0,0 @@
{
"description": "Baisc Manual Task",
"display_name": "Baisc Manual Task",
"exception_notification_addresses": [],
"fault_or_suspend_on_exception": "fault",
"files": [],
"primary_file_name": "baisc_manual_task.bpmn",
"primary_process_id": "BasicManualTaskProcess"
}

View File

@ -21,7 +21,7 @@ class TestProcessModelTestRunner(BaseTest):
with_db_and_bpmn_file_cleanup: None,
with_mocked_root_path: Any,
) -> None:
process_model_test_runner = self._run_model_tests("basic_script_task")
process_model_test_runner = self._run_model_tests("script-task")
assert len(process_model_test_runner.test_case_results) == 1
def test_will_raise_if_no_tests_found(
@ -50,7 +50,7 @@ class TestProcessModelTestRunner(BaseTest):
with_db_and_bpmn_file_cleanup: None,
with_mocked_root_path: Any,
) -> None:
process_model_test_runner = self._run_model_tests(parent_directory="failing_tests")
process_model_test_runner = self._run_model_tests(parent_directory="expected-to-fail")
assert len(process_model_test_runner.test_case_results) == 1
def test_can_test_process_model_call_activity(
@ -59,7 +59,7 @@ class TestProcessModelTestRunner(BaseTest):
with_db_and_bpmn_file_cleanup: None,
with_mocked_root_path: Any,
) -> None:
process_model_test_runner = self._run_model_tests(bpmn_process_directory_name="basic_call_activity")
process_model_test_runner = self._run_model_tests(bpmn_process_directory_name="call-activity")
assert len(process_model_test_runner.test_case_results) == 1
def test_can_test_process_model_with_service_task(
@ -68,11 +68,20 @@ class TestProcessModelTestRunner(BaseTest):
with_db_and_bpmn_file_cleanup: None,
with_mocked_root_path: Any,
) -> None:
process_model_test_runner = self._run_model_tests(bpmn_process_directory_name="basic_service_task")
process_model_test_runner = self._run_model_tests(bpmn_process_directory_name="service-task")
assert len(process_model_test_runner.test_case_results) == 1
def test_can_test_process_model_with_loopback_to_user_task(
self,
app: Flask,
with_db_and_bpmn_file_cleanup: None,
with_mocked_root_path: Any,
) -> None:
process_model_test_runner = self._run_model_tests(bpmn_process_directory_name="loopback-to-user-task")
assert len(process_model_test_runner.test_case_results) == 1
def _run_model_tests(
self, bpmn_process_directory_name: Optional[str] = None, parent_directory: str = "passing_tests"
self, bpmn_process_directory_name: Optional[str] = None, parent_directory: str = "expected-to-pass"
) -> ProcessModelTestRunner:
base_process_model_dir_path_segments = [FileSystemService.root_path(), parent_directory]
path_segments = base_process_model_dir_path_segments
@ -84,7 +93,7 @@ class TestProcessModelTestRunner(BaseTest):
)
process_model_test_runner.run()
all_tests_expected_to_pass = parent_directory == "passing_tests"
all_tests_expected_to_pass = parent_directory == "expected-to-pass"
assert (
process_model_test_runner.all_test_cases_passed() is all_tests_expected_to_pass
), process_model_test_runner.failing_tests_formatted()