Adds basic status-setting workflow spec and minimal test

This commit is contained in:
Aaron Louie 2020-03-13 14:58:07 -04:00
parent 0da07ad9e7
commit b1a6c9b6c7
6 changed files with 291 additions and 0 deletions

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/DMN/20151101/dmn.xsd" xmlns:biodi="http://bpmn.io/schema/dmn/biodi/1.0" id="Definitions_1p34ouw" name="DRD" namespace="http://camunda.org/schema/1.0/dmn" exporter="Camunda Modeler" exporterVersion="3.7.0">
<decision id="should_enable_pb_responses" name="should_enable_pb_responses">
<extensionElements>
<biodi:bounds x="190" y="80" width="180" height="80" />
</extensionElements>
<decisionTable id="DecisionTable_1mjqwlv">
<input id="InputClause_18pwfqu" label="some_input">
<inputExpression id="LiteralExpression_1y84stb" typeRef="boolean" expressionLanguage="feel" />
</input>
<output id="OutputClause_05y0j7c" label="pb_responses" name="pb_responses" typeRef="boolean" />
<rule id="DecisionRule_17xsr74">
<inputEntry id="UnaryTests_05ldcq4">
<text>false</text>
</inputEntry>
<outputEntry id="LiteralExpression_09oao3s">
<text>false</text>
</outputEntry>
</rule>
<rule id="DecisionRule_0zavblw">
<inputEntry id="UnaryTests_09xdkib">
<text>true</text>
</inputEntry>
<outputEntry id="LiteralExpression_0y2v9zc">
<text>true</text>
</outputEntry>
</rule>
</decisionTable>
</decision>
</definitions>

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/DMN/20151101/dmn.xsd" xmlns:biodi="http://bpmn.io/schema/dmn/biodi/1.0" id="Definitions_1p34ouw" name="DRD" namespace="http://camunda.org/schema/1.0/dmn" exporter="Camunda Modeler" exporterVersion="3.7.0">
<decision id="should_enable_random_fact" name="should_enable_random_fact">
<extensionElements>
<biodi:bounds x="170" y="60" width="180" height="80" />
</extensionElements>
<decisionTable id="decisionTable_1">
<input id="input_1" label="some_input">
<inputExpression id="inputExpression_1" typeRef="boolean" expressionLanguage="FEEL">
<text></text>
</inputExpression>
</input>
<output id="output_1" label="random_fact" name="random_fact" typeRef="boolean" />
<rule id="DecisionRule_10oo3ms">
<inputEntry id="UnaryTests_1ozg74s">
<text>false</text>
</inputEntry>
<outputEntry id="LiteralExpression_1d9565g">
<text>false</text>
</outputEntry>
</rule>
<rule id="DecisionRule_16ptqq8">
<inputEntry id="UnaryTests_1er4nj8">
<text>true</text>
</inputEntry>
<outputEntry id="LiteralExpression_1f34b59">
<text>true</text>
</outputEntry>
</rule>
</decisionTable>
</decision>
</definitions>

View File

@ -0,0 +1,144 @@
<?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_1kudwnk" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.7.0">
<bpmn:process id="Process_0jhpidf" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>SequenceFlow_1ees8ka</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="SequenceFlow_1ees8ka" sourceRef="StartEvent_1" targetRef="Activity_00rh8pw" />
<bpmn:businessRuleTask id="Activity_1k5eeun" name="Enable pb_responses" camunda:decisionRef="should_enable_pb_responses">
<bpmn:incoming>Flow_1nimppb</bpmn:incoming>
<bpmn:outgoing>Flow_1txrak2</bpmn:outgoing>
</bpmn:businessRuleTask>
<bpmn:businessRuleTask id="Activity_1yqy50i" name="Enable random_fact" camunda:decisionRef="should_enable_random_fact">
<bpmn:incoming>Flow_1m8285h</bpmn:incoming>
<bpmn:outgoing>Flow_1sggkit</bpmn:outgoing>
</bpmn:businessRuleTask>
<bpmn:businessRuleTask id="Activity_16cm213" name="Enable study_details" camunda:decisionRef="should_enable_study_details">
<bpmn:incoming>Flow_18pl92p</bpmn:incoming>
<bpmn:outgoing>Flow_0x9580l</bpmn:outgoing>
</bpmn:businessRuleTask>
<bpmn:businessRuleTask id="Activity_0rbzgsm" name="Enable two_forms" camunda:decisionRef="should_enable_two_forms">
<bpmn:incoming>Flow_03u23vt</bpmn:incoming>
<bpmn:outgoing>Flow_0pkxa8l</bpmn:outgoing>
</bpmn:businessRuleTask>
<bpmn:parallelGateway id="Gateway_1nta7st">
<bpmn:incoming>Flow_024q2cw</bpmn:incoming>
<bpmn:outgoing>Flow_1m8285h</bpmn:outgoing>
<bpmn:outgoing>Flow_1nimppb</bpmn:outgoing>
<bpmn:outgoing>Flow_03u23vt</bpmn:outgoing>
<bpmn:outgoing>Flow_18pl92p</bpmn:outgoing>
</bpmn:parallelGateway>
<bpmn:sequenceFlow id="Flow_1m8285h" sourceRef="Gateway_1nta7st" targetRef="Activity_1yqy50i" />
<bpmn:sequenceFlow id="Flow_1nimppb" sourceRef="Gateway_1nta7st" targetRef="Activity_1k5eeun" />
<bpmn:sequenceFlow id="Flow_18pl92p" sourceRef="Gateway_1nta7st" targetRef="Activity_16cm213" />
<bpmn:sequenceFlow id="Flow_03u23vt" sourceRef="Gateway_1nta7st" targetRef="Activity_0rbzgsm" />
<bpmn:parallelGateway id="Gateway_12tpgcy">
<bpmn:incoming>Flow_1txrak2</bpmn:incoming>
<bpmn:incoming>Flow_0pkxa8l</bpmn:incoming>
<bpmn:incoming>Flow_1sggkit</bpmn:incoming>
<bpmn:incoming>Flow_0x9580l</bpmn:incoming>
<bpmn:outgoing>Flow_0pwtiqm</bpmn:outgoing>
</bpmn:parallelGateway>
<bpmn:sequenceFlow id="Flow_0pkxa8l" sourceRef="Activity_0rbzgsm" targetRef="Gateway_12tpgcy" />
<bpmn:endEvent id="Event_135x8jg">
<bpmn:incoming>Flow_0pwtiqm</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="Flow_0pwtiqm" sourceRef="Gateway_12tpgcy" targetRef="Event_135x8jg" />
<bpmn:sequenceFlow id="Flow_0x9580l" sourceRef="Activity_16cm213" targetRef="Gateway_12tpgcy" />
<bpmn:sequenceFlow id="Flow_1txrak2" sourceRef="Activity_1k5eeun" targetRef="Gateway_12tpgcy" />
<bpmn:sequenceFlow id="Flow_1sggkit" sourceRef="Activity_1yqy50i" targetRef="Gateway_12tpgcy" />
<bpmn:sequenceFlow id="Flow_024q2cw" sourceRef="Activity_00rh8pw" targetRef="Gateway_1nta7st" />
<bpmn:userTask id="Activity_00rh8pw" name="Enable specs" camunda:formKey="form_key">
<bpmn:extensionElements>
<camunda:formData>
<camunda:formField id="some_input" label="some_input" type="boolean" />
</camunda:formData>
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_1ees8ka</bpmn:incoming>
<bpmn:outgoing>Flow_024q2cw</bpmn:outgoing>
</bpmn:userTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_0jhpidf">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="152" y="281" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1ees8ka_di" bpmnElement="SequenceFlow_1ees8ka">
<di:waypoint x="188" y="299" />
<di:waypoint x="230" y="299" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Activity_1k5eeun_di" bpmnElement="Activity_1k5eeun">
<dc:Bounds x="460" y="84" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1yqy50i_di" bpmnElement="Activity_1yqy50i">
<dc:Bounds x="460" y="199" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_16cm213_di" bpmnElement="Activity_16cm213">
<dc:Bounds x="460" y="319" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0rbzgsm_di" bpmnElement="Activity_0rbzgsm">
<dc:Bounds x="460" y="440" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Gateway_1m22g4p_di" bpmnElement="Gateway_1nta7st">
<dc:Bounds x="378" y="274" width="50" height="50" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_1m8285h_di" bpmnElement="Flow_1m8285h">
<di:waypoint x="403" y="274" />
<di:waypoint x="403" y="239" />
<di:waypoint x="460" y="239" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1nimppb_di" bpmnElement="Flow_1nimppb">
<di:waypoint x="403" y="274" />
<di:waypoint x="403" y="124" />
<di:waypoint x="460" y="124" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_18pl92p_di" bpmnElement="Flow_18pl92p">
<di:waypoint x="403" y="324" />
<di:waypoint x="403" y="359" />
<di:waypoint x="460" y="359" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_03u23vt_di" bpmnElement="Flow_03u23vt">
<di:waypoint x="403" y="324" />
<di:waypoint x="403" y="480" />
<di:waypoint x="460" y="480" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Gateway_1kk6x70_di" bpmnElement="Gateway_12tpgcy">
<dc:Bounds x="595" y="274" width="50" height="50" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_0pkxa8l_di" bpmnElement="Flow_0pkxa8l">
<di:waypoint x="560" y="480" />
<di:waypoint x="620" y="480" />
<di:waypoint x="620" y="324" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Event_135x8jg_di" bpmnElement="Event_135x8jg">
<dc:Bounds x="682" y="281" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_0pwtiqm_di" bpmnElement="Flow_0pwtiqm">
<di:waypoint x="645" y="299" />
<di:waypoint x="682" y="299" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0x9580l_di" bpmnElement="Flow_0x9580l">
<di:waypoint x="560" y="359" />
<di:waypoint x="620" y="359" />
<di:waypoint x="620" y="324" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1txrak2_di" bpmnElement="Flow_1txrak2">
<di:waypoint x="560" y="124" />
<di:waypoint x="620" y="124" />
<di:waypoint x="620" y="274" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1sggkit_di" bpmnElement="Flow_1sggkit">
<di:waypoint x="560" y="239" />
<di:waypoint x="620" y="239" />
<di:waypoint x="620" y="274" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_024q2cw_di" bpmnElement="Flow_024q2cw">
<di:waypoint x="330" y="299" />
<di:waypoint x="378" y="299" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="Activity_0vfs7g0_di" bpmnElement="Activity_00rh8pw">
<dc:Bounds x="230" y="259" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/DMN/20151101/dmn.xsd" xmlns:biodi="http://bpmn.io/schema/dmn/biodi/1.0" id="Definitions_1p34ouw" name="DRD" namespace="http://camunda.org/schema/1.0/dmn" exporter="Camunda Modeler" exporterVersion="3.7.0">
<decision id="should_enable_study_details" name="should_enable_study_details">
<extensionElements>
<biodi:bounds x="190" y="70" width="180" height="80" />
</extensionElements>
<decisionTable id="DecisionTable_00zdxg0">
<input id="InputClause_02n3ccs" label="some_input">
<inputExpression id="LiteralExpression_1ju4o1o" typeRef="boolean" expressionLanguage="feel" />
</input>
<output id="OutputClause_1ybi1ud" label="study_details" name="study_details" typeRef="boolean" />
<rule id="DecisionRule_1t97mw4">
<inputEntry id="UnaryTests_0ym4ln2">
<text>false</text>
</inputEntry>
<outputEntry id="LiteralExpression_1pweuqc">
<text>false</text>
</outputEntry>
</rule>
<rule id="DecisionRule_0j9wah0">
<inputEntry id="UnaryTests_0dzq6w4">
<text>true</text>
</inputEntry>
<outputEntry id="LiteralExpression_119lstj">
<text>true</text>
</outputEntry>
</rule>
</decisionTable>
</decision>
</definitions>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/DMN/20151101/dmn.xsd" xmlns:biodi="http://bpmn.io/schema/dmn/biodi/1.0" id="Definitions_1p34ouw" name="DRD" namespace="http://camunda.org/schema/1.0/dmn" exporter="Camunda Modeler" exporterVersion="3.7.0">
<decision id="should_enable_two_forms" name="should_enable_two_forms">
<extensionElements>
<biodi:bounds x="150" y="80" width="180" height="80" />
</extensionElements>
<decisionTable id="DecisionTable_15l972l">
<input id="InputClause_0lms091" label="some_input">
<inputExpression id="LiteralExpression_0ypio3f" typeRef="boolean" expressionLanguage="feel" />
</input>
<output id="OutputClause_1f7iind" label="two_forms" name="two_forms" typeRef="boolean" />
<rule id="DecisionRule_0914coi">
<inputEntry id="UnaryTests_1efs7cx">
<text>false</text>
</inputEntry>
<outputEntry id="LiteralExpression_0utnzi4">
<text>false</text>
</outputEntry>
</rule>
<rule id="DecisionRule_0zcj74u">
<inputEntry id="UnaryTests_0v2q8t3">
<text>true</text>
</inputEntry>
<outputEntry id="LiteralExpression_1jh1u0c">
<text>true</text>
</outputEntry>
</rule>
</decisionTable>
</decision>
</definitions>

View File

@ -323,3 +323,28 @@ class TestWorkflowProcessor(BaseTest):
workflow_spec_model = self.load_test_spec("two_forms")
version = WorkflowProcessor.get_latest_version_string("two_forms")
self.assertTrue(version.startswith("v1 "))
def test_status_bpmn(self):
self.load_example_data()
study = session.query(StudyModel).first()
workflow_spec_model = self.load_test_spec("status")
for enabled in [True, False]:
processor = WorkflowProcessor.create(study.id, workflow_spec_model.id)
task = processor.next_task()
# Turn all specs on or off
task.data = {"some_input": enabled}
processor.complete_task(task)
# Finish out rest of workflow
while processor.get_status() == WorkflowStatus.waiting:
task = processor.next_task()
processor.complete_task(task)
self.assertEqual(processor.get_status(), WorkflowStatus.complete)
# Enabled status of all specs should match the value set in the first task
for spec_id in ['two_forms', 'random_fact', 'pb_responses', 'study_details']:
self.assertEqual(task.data[spec_id], enabled)