mirror of
https://github.com/sartography/cr-connect-workflow.git
synced 2025-02-23 05:08:32 +00:00
Test for new script
This commit is contained in:
parent
a9326d29e2
commit
2aea4bc1ae
76
tests/data/start_workflow/start_workflow.bpmn
Normal file
76
tests/data/start_workflow/start_workflow.bpmn
Normal file
@ -0,0 +1,76 @@
|
||||
<?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:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0a7bvlf" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.2.0">
|
||||
<bpmn:process id="Process_0inkg2m" name="Start Workflow Programmatically" isExecutable="true">
|
||||
<bpmn:startEvent id="StartEvent_1">
|
||||
<bpmn:outgoing>Flow_0ac3s7d</bpmn:outgoing>
|
||||
</bpmn:startEvent>
|
||||
<bpmn:sequenceFlow id="Flow_0ac3s7d" sourceRef="StartEvent_1" targetRef="Activity_0n0md5g" />
|
||||
<bpmn:sequenceFlow id="Flow_03vp8ep" sourceRef="Activity_0n0md5g" targetRef="Activity_0qxilu1" />
|
||||
<bpmn:sequenceFlow id="Flow_0etvuwr" sourceRef="Activity_0qxilu1" targetRef="Activity_1thn0qo" />
|
||||
<bpmn:endEvent id="Event_1hlx8d1">
|
||||
<bpmn:incoming>Flow_1ppd3wf</bpmn:incoming>
|
||||
</bpmn:endEvent>
|
||||
<bpmn:sequenceFlow id="Flow_1ppd3wf" sourceRef="Activity_1thn0qo" targetRef="Event_1hlx8d1" />
|
||||
<bpmn:userTask id="Activity_0n0md5g" name="Get Required Data" camunda:formKey="DataForm">
|
||||
<bpmn:extensionElements>
|
||||
<camunda:formData>
|
||||
<camunda:formField id="workflow_spec_to_start" label="'Workflow Spec'" type="string">
|
||||
<camunda:validation>
|
||||
<camunda:constraint name="required" config="True" />
|
||||
</camunda:validation>
|
||||
</camunda:formField>
|
||||
</camunda:formData>
|
||||
</bpmn:extensionElements>
|
||||
<bpmn:incoming>Flow_0ac3s7d</bpmn:incoming>
|
||||
<bpmn:outgoing>Flow_03vp8ep</bpmn:outgoing>
|
||||
</bpmn:userTask>
|
||||
<bpmn:scriptTask id="Activity_0qxilu1" name="Start Workflow ">
|
||||
<bpmn:incoming>Flow_03vp8ep</bpmn:incoming>
|
||||
<bpmn:outgoing>Flow_0etvuwr</bpmn:outgoing>
|
||||
<bpmn:script>workflow_api = start_workflow(workflow_spec_id=workflow_spec_to_start)</bpmn:script>
|
||||
</bpmn:scriptTask>
|
||||
<bpmn:manualTask id="Activity_1thn0qo" name="Display Result">
|
||||
<bpmn:documentation>## Result
|
||||
|
||||
|
||||
{{ workflow_api }}</bpmn:documentation>
|
||||
<bpmn:incoming>Flow_0etvuwr</bpmn:incoming>
|
||||
<bpmn:outgoing>Flow_1ppd3wf</bpmn:outgoing>
|
||||
</bpmn:manualTask>
|
||||
</bpmn:process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_0inkg2m">
|
||||
<bpmndi:BPMNEdge id="Flow_1ppd3wf_di" bpmnElement="Flow_1ppd3wf">
|
||||
<di:waypoint x="690" y="117" />
|
||||
<di:waypoint x="752" y="117" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="Flow_0etvuwr_di" bpmnElement="Flow_0etvuwr">
|
||||
<di:waypoint x="530" y="117" />
|
||||
<di:waypoint x="590" y="117" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="Flow_03vp8ep_di" bpmnElement="Flow_03vp8ep">
|
||||
<di:waypoint x="370" y="117" />
|
||||
<di:waypoint x="430" y="117" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="Flow_0ac3s7d_di" bpmnElement="Flow_0ac3s7d">
|
||||
<di:waypoint x="215" y="117" />
|
||||
<di:waypoint x="270" y="117" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
|
||||
<dc:Bounds x="179" y="99" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Event_1hlx8d1_di" bpmnElement="Event_1hlx8d1">
|
||||
<dc:Bounds x="752" y="99" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Activity_0gf4hes_di" bpmnElement="Activity_0n0md5g">
|
||||
<dc:Bounds x="270" y="77" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Activity_11ydp76_di" bpmnElement="Activity_0qxilu1">
|
||||
<dc:Bounds x="430" y="77" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Activity_1sy9ble_di" bpmnElement="Activity_1thn0qo">
|
||||
<dc:Bounds x="590" y="77" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn:definitions>
|
35
tests/scripts/test_start_workflow.py
Normal file
35
tests/scripts/test_start_workflow.py
Normal file
@ -0,0 +1,35 @@
|
||||
from tests.base_test import BaseTest
|
||||
|
||||
from crc import session
|
||||
from crc.models.study import StudyModel
|
||||
from crc.models.workflow import WorkflowModel
|
||||
from crc.services.study_service import StudyService
|
||||
from crc.services.workflow_spec_service import WorkflowSpecService
|
||||
|
||||
|
||||
class TestStartWorkflow(BaseTest):
|
||||
|
||||
def test_start_workflow_validation(self):
|
||||
spec_model = self.load_test_spec('start_workflow')
|
||||
rv = self.app.get('/v1.0/workflow-specification/%s/validate' % spec_model.id, headers=self.logged_in_headers())
|
||||
self.assertEqual([], rv.json)
|
||||
|
||||
def test_start_workflow(self):
|
||||
self.add_users()
|
||||
self.create_workflow('hello_world')
|
||||
workflow_spec_to_start = WorkflowSpecService().get_spec('hello_world')
|
||||
|
||||
workflow = self.create_workflow('start_workflow')
|
||||
study_id = workflow.study_id
|
||||
study = session.query(StudyModel).filter(StudyModel.id==study_id).first()
|
||||
StudyService.add_all_workflow_specs_to_study(study, [workflow_spec_to_start])
|
||||
|
||||
workflow_before = session.query(WorkflowModel).filter(WorkflowModel.workflow_spec_id=='hello_world').first()
|
||||
self.assertEqual('not_started', workflow_before.status.value)
|
||||
|
||||
workflow_api = self.get_workflow_api(workflow)
|
||||
task = workflow_api.next_task
|
||||
self.complete_form(workflow, task, {'workflow_spec_to_start': 'hello_world'})
|
||||
|
||||
workflow_after = session.query(WorkflowModel).filter(WorkflowModel.workflow_spec_id=='hello_world').first()
|
||||
self.assertEqual('user_input_required', workflow_after.status.value)
|
Loading…
x
Reference in New Issue
Block a user