work in progress

This commit is contained in:
burnettk 2022-09-30 16:46:30 -04:00
parent ce1e605fb5
commit a964fb4ea0
2 changed files with 111 additions and 45 deletions

View File

@ -16,29 +16,47 @@
<bpmn:incoming>SequenceFlow_0qyd2b7</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_1h46b40</bpmn:outgoing>
</bpmn:userTask>
<bpmn:sequenceFlow id="SequenceFlow_1h46b40" sourceRef="Task_GetName" targetRef="Task_SayHello" />
<bpmn:sequenceFlow id="SequenceFlow_1h46b40" sourceRef="Task_GetName" targetRef="Activity_subprocess" />
<bpmn:manualTask id="Task_SayHello" name="Say Hello">
<bpmn:documentation>Hello {{name}}</bpmn:documentation>
<bpmn:incoming>SequenceFlow_1h46b40</bpmn:incoming>
<bpmn:incoming>Flow_1d27j6f</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_0lqrc6e</bpmn:outgoing>
</bpmn:manualTask>
<bpmn:endEvent id="EndEvent_1l03lqw">
<bpmn:incoming>SequenceFlow_0lqrc6e</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="SequenceFlow_0lqrc6e" sourceRef="Task_SayHello" targetRef="EndEvent_1l03lqw" />
<bpmn:subProcess id="Activity_0uv5ubt">
<bpmn:startEvent id="Event_0jubmia" />
<bpmn:subProcess id="Activity_subprocess" name="Hot Subprocess">
<bpmn:incoming>SequenceFlow_1h46b40</bpmn:incoming>
<bpmn:outgoing>Flow_1d27j6f</bpmn:outgoing>
<bpmn:startEvent id="Event_0jubmia">
<bpmn:outgoing>Flow_1s17tt0</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="Flow_1s17tt0" sourceRef="Event_0jubmia" targetRef="hot_script_task_OH_YEEEEEEEEEEEEEEEEEEEEAH" />
<bpmn:scriptTask id="hot_script_task_OH_YEEEEEEEEEEEEEEEEEEEEAH">
<bpmn:incoming>Flow_1s17tt0</bpmn:incoming>
<bpmn:outgoing>Flow_1mcaszp</bpmn:outgoing>
</bpmn:scriptTask>
<bpmn:endEvent id="Event_1vch1y0">
<bpmn:incoming>Flow_1mcaszp</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="Flow_1mcaszp" sourceRef="hot_script_task_OH_YEEEEEEEEEEEEEEEEEEEEAH" targetRef="Event_1vch1y0" />
</bpmn:subProcess>
<bpmn:sequenceFlow id="Flow_1d27j6f" sourceRef="Activity_subprocess" targetRef="Task_SayHello" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_HelloWorld">
<bpmndi:BPMNEdge id="Flow_1d27j6f_di" bpmnElement="Flow_1d27j6f">
<di:waypoint x="510" y="117" />
<di:waypoint x="600" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_0lqrc6e_di" bpmnElement="SequenceFlow_0lqrc6e">
<di:waypoint x="530" y="117" />
<di:waypoint x="592" y="117" />
<di:waypoint x="700" y="117" />
<di:waypoint x="752" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_1h46b40_di" bpmnElement="SequenceFlow_1h46b40">
<di:waypoint x="370" y="117" />
<di:waypoint x="430" y="117" />
<di:waypoint x="410" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_0qyd2b7_di" bpmnElement="SequenceFlow_0qyd2b7">
<di:waypoint x="215" y="117" />
@ -51,21 +69,36 @@
<dc:Bounds x="270" y="77" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="ManualTask_1tia2zr_di" bpmnElement="Task_SayHello">
<dc:Bounds x="430" y="77" width="100" height="80" />
<dc:Bounds x="600" y="77" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="EndEvent_1l03lqw_di" bpmnElement="EndEvent_1l03lqw">
<dc:Bounds x="592" y="99" width="36" height="36" />
<dc:Bounds x="752" y="99" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0uv5ubt_di" bpmnElement="Activity_0uv5ubt" isExpanded="false">
<dc:Bounds x="365" y="200" width="100" height="80" />
<bpmndi:BPMNShape id="Activity_subprocess_di" bpmnElement="Activity_subprocess" isExpanded="false">
<dc:Bounds x="410" y="77" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
<bpmndi:BPMNDiagram id="BPMNDiagram_04r6k7u">
<bpmndi:BPMNPlane id="BPMNPlane_15oexby" bpmnElement="Activity_0uv5ubt">
<bpmndi:BPMNPlane id="BPMNPlane_15oexby" bpmnElement="Activity_subprocess">
<bpmndi:BPMNEdge id="Flow_1mcaszp_di" bpmnElement="Flow_1mcaszp">
<di:waypoint x="370" y="98" />
<di:waypoint x="432" y="98" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1s17tt0_di" bpmnElement="Flow_1s17tt0">
<di:waypoint x="216" y="98" />
<di:waypoint x="270" y="98" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Event_0jubmia_di" bpmnElement="Event_0jubmia">
<dc:Bounds x="180" y="80" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0818vnx_di" bpmnElement="hot_script_task_OH_YEEEEEEEEEEEEEEEEEEEEAH">
<dc:Bounds x="270" y="58" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_1vch1y0_di" bpmnElement="Event_1vch1y0">
<dc:Bounds x="432" y="80" width="36" height="36" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>

View File

@ -1,44 +1,77 @@
"""Test_process_instance_processor."""
# from SpiffWorkflow import TaskState
from flask.app import Flask
from SpiffWorkflow import TaskState # type: ignore
from tests.spiffworkflow_backend.helpers.base_test import BaseTest
from tests.spiffworkflow_backend.helpers.test_data import load_test_spec
from spiffworkflow_backend.services.process_instance_processor import (
ProcessInstanceProcessor,
)
# from tests.spiffworkflow_backend.helpers.test_data import load_test_spec
from spiffworkflow_backend.services.process_instance_service import (
ProcessInstanceService,
)
# it's not totally obvious we want to keep this test/file
def test_script_engine_takes_data_and_returns_expected_results(
app: Flask,
with_db_and_bpmn_file_cleanup: None,
) -> None:
"""Test_script_engine_takes_data_and_returns_expected_results."""
script_engine = ProcessInstanceProcessor._script_engine
class TestProcessInstanceProcessor(BaseTest):
"""TestProcessInstanceProcessor."""
result = script_engine._evaluate("a", {"a": 1})
assert result == 1
# it's not totally obvious we want to keep this test/file
def test_script_engine_takes_data_and_returns_expected_results(
self,
app: Flask,
with_db_and_bpmn_file_cleanup: None,
) -> None:
"""Test_script_engine_takes_data_and_returns_expected_results."""
script_engine = ProcessInstanceProcessor._script_engine
result = script_engine._evaluate("a", {"a": 1})
assert result == 1
def test_get_bpmn_process_instance_from_process_model_can_acccess_tasks_from_subprocesses(
app: Flask,
with_db_and_bpmn_file_cleanup: None,
) -> None:
"""Test_get_bpmn_process_instance_from_process_model_can_acccess_tasks_from_subprocesses."""
assert True
# load_test_spec(
# "multiinstance",
# process_model_source_directory="spiff_example",
# )
#
# # BpmnWorkflow
# bpmn_process_instance = (
# ProcessInstanceProcessor.get_bpmn_process_instance_from_process_model(
# process_group_identifier='test_process_group_id', process_model_identifier='multiinstance'
# )
# )
#
# tasks = bpmn_process_instance.get_tasks(TaskState.ANY_MASK)
# task_ids = [t.task_spec.name for t in tasks]
# print(f"task_ids: {task_ids}")
# FIXME: print statements for debugging
def test_get_bpmn_process_instance_from_process_model_can_access_tasks_from_subprocesses(
self,
app: Flask,
with_db_and_bpmn_file_cleanup: None,
) -> None:
"""Test_get_bpmn_process_instance_from_process_model_can_access_tasks_from_subprocesses."""
app.config["THREAD_LOCAL_DATA"].process_instance_id = None
process_model = load_test_spec(
"hello_world",
process_model_source_directory="hello_world",
)
# BpmnWorkflow instance
bpmn_process_instance = (
ProcessInstanceProcessor.get_bpmn_process_instance_from_process_model(
process_group_identifier="test_process_group_id",
process_model_identifier="hello_world",
)
)
tasks = bpmn_process_instance.get_tasks(TaskState.ANY_MASK)
subprocess_specs = bpmn_process_instance.subprocess_specs
task_ids = [t.task_spec.name for t in tasks]
print("\nWITHOUT INSTANCE")
print(f"task_ids: {task_ids}\n")
print(f"task_ids length: {len(task_ids)}\n")
print(f"subprocess_specs: {subprocess_specs}")
user = self.find_or_create_user()
process_instance = ProcessInstanceService.create_process_instance(
process_model.id,
user,
process_group_identifier=process_model.process_group_id,
)
processor = ProcessInstanceProcessor(process_instance)
processor.do_engine_steps()
processor.save()
print("\nWITH INSTANCE")
bpmn_process_instance = processor.bpmn_process_instance
tasks = bpmn_process_instance.get_tasks(TaskState.ANY_MASK)
subprocess_specs = bpmn_process_instance.subprocess_specs
task_ids = [t.task_spec.name for t in tasks]
print(f"task_ids: {task_ids}\n")
print(f"subprocess_specs: {subprocess_specs}")