started test for test_script_unit_test_run
This commit is contained in:
parent
f41fe5f9ae
commit
aeea99c0ff
|
@ -1,67 +1,87 @@
|
|||
<?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_1kbzkan" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.0.0">
|
||||
<bpmn:process id="Process_SimpleScript" name="Simple Script" isExecutable="true">
|
||||
<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:spiffworkflow="http://spiffworkflow.org/bpmn/schema/1.0/core" 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="Proccess_SimpleScript" name="Simple Script" isExecutable="true">
|
||||
<bpmn:startEvent id="StartEvent_1">
|
||||
<bpmn:outgoing>Flow_1k9q28c</bpmn:outgoing>
|
||||
<bpmn:outgoing>Flow_0r3ua0i</bpmn:outgoing>
|
||||
</bpmn:startEvent>
|
||||
<bpmn:sequenceFlow id="Flow_1k9q28c" sourceRef="StartEvent_1" targetRef="Activity_RunScript" />
|
||||
<bpmn:sequenceFlow id="Flow_1fviiob" sourceRef="Activity_RunScript" targetRef="Activity_DisplayData" />
|
||||
<bpmn:endEvent id="Event_1fep863">
|
||||
<bpmn:incoming>Flow_10610n2</bpmn:incoming>
|
||||
</bpmn:endEvent>
|
||||
<bpmn:sequenceFlow id="Flow_10610n2" sourceRef="Activity_DisplayData" targetRef="Event_1fep863" />
|
||||
<bpmn:scriptTask id="Activity_RunScript" name="Run Script">
|
||||
<bpmn:incoming>Flow_1k9q28c</bpmn:incoming>
|
||||
<bpmn:outgoing>Flow_1fviiob</bpmn:outgoing>
|
||||
<bpmn:sequenceFlow id="Flow_0r3ua0i" sourceRef="StartEvent_1" targetRef="Activity_SetInitialData" />
|
||||
<bpmn:scriptTask id="Activity_SetInitialData" name="Set Initial Data">
|
||||
<bpmn:incoming>Flow_0r3ua0i</bpmn:incoming>
|
||||
<bpmn:outgoing>Flow_19g4f88</bpmn:outgoing>
|
||||
<bpmn:script>a = 1
|
||||
b = 2
|
||||
c = a + b
|
||||
norris=fact_service(type='norris')</bpmn:script>
|
||||
b = 2</bpmn:script>
|
||||
</bpmn:scriptTask>
|
||||
<bpmn:sequenceFlow id="Flow_19g4f88" sourceRef="Activity_SetInitialData" targetRef="Activity_CalculateNewData" />
|
||||
<bpmn:scriptTask id="Activity_CalculateNewData" name="Calculate New Data">
|
||||
<bpmn:extensionElements>
|
||||
<spiffworkflow:unitTests>
|
||||
<spiffworkflow:unitTest id="ScriptUnitTest_SimpleScript">
|
||||
<spiffworkflow:inputJson>{'a': 1, 'b': 2}</spiffworkflow:inputJson>
|
||||
<spiffworkflow:expectedOutputJson>{'a': 1, 'b': 2, 'c': 3}</spiffworkflow:expectedOutputJson>
|
||||
</spiffworkflow:unitTest>
|
||||
</spiffworkflow:unitTests>
|
||||
</bpmn:extensionElements>
|
||||
<bpmn:incoming>Flow_19g4f88</bpmn:incoming>
|
||||
<bpmn:outgoing>Flow_152cqfw</bpmn:outgoing>
|
||||
<bpmn:script>c = a + b</bpmn:script>
|
||||
</bpmn:scriptTask>
|
||||
<bpmn:sequenceFlow id="Flow_152cqfw" sourceRef="Activity_CalculateNewData" targetRef="Activity_DisplayData" />
|
||||
<bpmn:manualTask id="Activity_DisplayData" name="Display Data">
|
||||
<bpmn:documentation>## Display Data
|
||||
<bpmn:extensionElements>
|
||||
<spiffworkflow:instructionsForEndUser>## Data
|
||||
|
||||
|
||||
### a
|
||||
### A
|
||||
{{ a }}
|
||||
|
||||
|
||||
### b
|
||||
### B
|
||||
{{ b }}
|
||||
|
||||
|
||||
### c
|
||||
{{ c }}</bpmn:documentation>
|
||||
<bpmn:incoming>Flow_1fviiob</bpmn:incoming>
|
||||
<bpmn:outgoing>Flow_10610n2</bpmn:outgoing>
|
||||
### C
|
||||
{{ c }}</spiffworkflow:instructionsForEndUser>
|
||||
</bpmn:extensionElements>
|
||||
<bpmn:incoming>Flow_152cqfw</bpmn:incoming>
|
||||
<bpmn:outgoing>Flow_1vqk60p</bpmn:outgoing>
|
||||
</bpmn:manualTask>
|
||||
<bpmn:endEvent id="Event_19fiqu4">
|
||||
<bpmn:incoming>Flow_1vqk60p</bpmn:incoming>
|
||||
</bpmn:endEvent>
|
||||
<bpmn:sequenceFlow id="Flow_1vqk60p" sourceRef="Activity_DisplayData" targetRef="Event_19fiqu4" />
|
||||
</bpmn:process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_SimpleScript">
|
||||
<bpmndi:BPMNEdge id="Flow_10610n2_di" bpmnElement="Flow_10610n2">
|
||||
<di:waypoint x="530" y="117" />
|
||||
<di:waypoint x="592" y="117" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="Flow_1fviiob_di" bpmnElement="Flow_1fviiob">
|
||||
<di:waypoint x="370" y="117" />
|
||||
<di:waypoint x="430" y="117" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="Flow_1k9q28c_di" bpmnElement="Flow_1k9q28c">
|
||||
<di:waypoint x="215" y="117" />
|
||||
<di:waypoint x="270" y="117" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Proccess_SimpleScript">
|
||||
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
|
||||
<dc:Bounds x="179" y="99" width="36" height="36" />
|
||||
<dc:Bounds x="179" y="159" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Event_1fep863_di" bpmnElement="Event_1fep863">
|
||||
<dc:Bounds x="592" y="99" width="36" height="36" />
|
||||
<bpmndi:BPMNShape id="Activity_0l45w13_di" bpmnElement="Activity_SetInitialData">
|
||||
<dc:Bounds x="270" y="137" width="100" height="80" />
|
||||
<bpmndi:BPMNLabel />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Activity_12kpu89_di" bpmnElement="Activity_RunScript">
|
||||
<dc:Bounds x="270" y="77" width="100" height="80" />
|
||||
<bpmndi:BPMNShape id="Activity_00n1s76_di" bpmnElement="Activity_CalculateNewData">
|
||||
<dc:Bounds x="430" y="137" width="100" height="80" />
|
||||
<bpmndi:BPMNLabel />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Activity_17mrit2_di" bpmnElement="Activity_DisplayData">
|
||||
<dc:Bounds x="430" y="77" width="100" height="80" />
|
||||
<bpmndi:BPMNShape id="Activity_1nhghi0_di" bpmnElement="Activity_DisplayData">
|
||||
<dc:Bounds x="590" y="137" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Event_19fiqu4_di" bpmnElement="Event_19fiqu4">
|
||||
<dc:Bounds x="752" y="159" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNEdge id="Flow_0r3ua0i_di" bpmnElement="Flow_0r3ua0i">
|
||||
<di:waypoint x="215" y="177" />
|
||||
<di:waypoint x="270" y="177" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="Flow_19g4f88_di" bpmnElement="Flow_19g4f88">
|
||||
<di:waypoint x="370" y="177" />
|
||||
<di:waypoint x="430" y="177" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="Flow_152cqfw_di" bpmnElement="Flow_152cqfw">
|
||||
<di:waypoint x="530" y="177" />
|
||||
<di:waypoint x="590" y="177" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="Flow_1vqk60p_di" bpmnElement="Flow_1vqk60p">
|
||||
<di:waypoint x="690" y="177" />
|
||||
<di:waypoint x="752" y="177" />
|
||||
</bpmndi:BPMNEdge>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn:definitions>
|
||||
|
|
|
@ -2287,3 +2287,61 @@ class TestProcessApi(BaseTest):
|
|||
# task = response.json['next_task']
|
||||
|
||||
print("test_process_instance_suspend")
|
||||
|
||||
def test_script_unit_test_run(
|
||||
self,
|
||||
app: Flask,
|
||||
client: FlaskClient,
|
||||
with_db_and_bpmn_file_cleanup: None,
|
||||
with_super_admin_user: UserModel,
|
||||
) -> None:
|
||||
process_group_id = "test_group"
|
||||
process_model_id = "simple_script"
|
||||
bpmn_file_name = "simple_script.bpmn"
|
||||
bpmn_file_location = "simple_script"
|
||||
process_model_identifier = self.basic_test_setup(
|
||||
client=client,
|
||||
user=with_super_admin_user,
|
||||
process_group_id=process_group_id,
|
||||
process_model_id=process_model_id,
|
||||
bpmn_file_name=bpmn_file_name,
|
||||
bpmn_file_location=bpmn_file_location
|
||||
)
|
||||
|
||||
bpmn_file_data_bytes = self.get_test_data_file_contents(
|
||||
bpmn_file_name, bpmn_file_location
|
||||
)
|
||||
self.create_spec_file(
|
||||
client=client,
|
||||
process_model_id=process_model_identifier,
|
||||
process_model_location=process_model_identifier,
|
||||
file_name=bpmn_file_name,
|
||||
file_data=bpmn_file_data_bytes,
|
||||
user=with_super_admin_user
|
||||
)
|
||||
|
||||
# python_script = _get_required_parameter_or_raise("python_script", body)
|
||||
# input_json = _get_required_parameter_or_raise("input_json", body)
|
||||
# expected_output_json = _get_required_parameter_or_raise(
|
||||
# "expected_output_json", body
|
||||
# )
|
||||
python_script = "c = a + b"
|
||||
input_json = {'a': 1, 'b': 2}
|
||||
expected_output_json = {'a': 1, 'b': 2, 'c': 3}
|
||||
# bpmn_task_identifier = "Activity_CalculateNewData"
|
||||
|
||||
data = {
|
||||
'python_script': python_script,
|
||||
'input_json': input_json,
|
||||
'expected_output_json': expected_output_json,
|
||||
}
|
||||
|
||||
response = client.post(
|
||||
f"/v1.0/process-models/{process_group_id}/{process_model_id}/script-unit-tests/run",
|
||||
headers=self.logged_in_headers(with_super_admin_user),
|
||||
content_type="application/json",
|
||||
data=json.dumps(data),
|
||||
)
|
||||
|
||||
|
||||
print("test_script_unit_test_run")
|
||||
|
|
Loading…
Reference in New Issue