Added test and workflow for updating `short_name` and `proposal_name`

This commit is contained in:
mike cullerton 2021-09-17 12:05:29 -04:00
parent deb3d7bf67
commit 1e48cbea1a
2 changed files with 104 additions and 0 deletions

View File

@ -0,0 +1,85 @@
<?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_3435c8d" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.0.0-dev">
<bpmn:process id="Process_3435c8d" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>Flow_0g8e1jy</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="Flow_0g8e1jy" sourceRef="StartEvent_1" targetRef="Activity_GetData" />
<bpmn:userTask id="Activity_GetData" name="Get Data" camunda:formKey="GetDataForm">
<bpmn:extensionElements>
<camunda:formData>
<camunda:formField id="short_name" label="Short Name" type="string" />
<camunda:formField id="proposal_name" label="Proposal Name" type="string" />
</camunda:formData>
</bpmn:extensionElements>
<bpmn:incoming>Flow_0g8e1jy</bpmn:incoming>
<bpmn:outgoing>Flow_09flr91</bpmn:outgoing>
</bpmn:userTask>
<bpmn:sequenceFlow id="Flow_09flr91" sourceRef="Activity_GetData" targetRef="Activity_UpdateStudy" />
<bpmn:scriptTask id="Activity_UpdateStudy" name="Update Study">
<bpmn:incoming>Flow_09flr91</bpmn:incoming>
<bpmn:outgoing>Flow_0xf0u0k</bpmn:outgoing>
<bpmn:script>update_study(short_name=short_name, proposal_name=proposal_name)</bpmn:script>
</bpmn:scriptTask>
<bpmn:sequenceFlow id="Flow_0xf0u0k" sourceRef="Activity_UpdateStudy" targetRef="Activity_GetStudyInfo" />
<bpmn:scriptTask id="Activity_GetStudyInfo" name="Get Study Info">
<bpmn:incoming>Flow_0xf0u0k</bpmn:incoming>
<bpmn:outgoing>Flow_0tzamxo</bpmn:outgoing>
<bpmn:script>study_info = study_info("info")</bpmn:script>
</bpmn:scriptTask>
<bpmn:sequenceFlow id="Flow_0tzamxo" sourceRef="Activity_GetStudyInfo" targetRef="Activity_DisplayInfo" />
<bpmn:manualTask id="Activity_DisplayInfo" name="Display Study Info">
<bpmn:documentation># Info
{{ study_info }}
</bpmn:documentation>
<bpmn:incoming>Flow_0tzamxo</bpmn:incoming>
<bpmn:outgoing>Flow_0x5ex3d</bpmn:outgoing>
</bpmn:manualTask>
<bpmn:endEvent id="Event_05xjsir">
<bpmn:incoming>Flow_0x5ex3d</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="Flow_0x5ex3d" sourceRef="Activity_DisplayInfo" targetRef="Event_05xjsir" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_3435c8d">
<bpmndi:BPMNEdge id="Flow_0x5ex3d_di" bpmnElement="Flow_0x5ex3d">
<di:waypoint x="850" y="177" />
<di:waypoint x="912" y="177" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0tzamxo_di" bpmnElement="Flow_0tzamxo">
<di:waypoint x="690" y="177" />
<di:waypoint x="750" y="177" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0xf0u0k_di" bpmnElement="Flow_0xf0u0k">
<di:waypoint x="530" y="177" />
<di:waypoint x="590" y="177" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_09flr91_di" bpmnElement="Flow_09flr91">
<di:waypoint x="370" y="177" />
<di:waypoint x="430" y="177" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0g8e1jy_di" bpmnElement="Flow_0g8e1jy">
<di:waypoint x="215" y="177" />
<di:waypoint x="270" y="177" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="179" y="159" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_06lg3xc_di" bpmnElement="Activity_GetData">
<dc:Bounds x="270" y="137" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0ulzpsr_di" bpmnElement="Activity_UpdateStudy">
<dc:Bounds x="430" y="137" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_15xfbrf_di" bpmnElement="Activity_GetStudyInfo">
<dc:Bounds x="590" y="137" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1yteq9j_di" bpmnElement="Activity_DisplayInfo">
<dc:Bounds x="750" y="137" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_05xjsir_di" bpmnElement="Event_05xjsir">
<dc:Bounds x="912" y="159" width="36" height="36" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>

View File

@ -33,6 +33,25 @@ class TestStudyInfoScript(BaseTest):
self.assertEqual(study_info['primary_investigator_id'], second_task.data['info']['primary_investigator_id'])
self.assertIn(study_info['title'], second_task.documentation)
def test_info_script_updated_study_info(self):
self.load_example_data()
short_name = "My Short Name"
proposal_name = "My Proposal Name"
workflow = self.create_workflow('update_study_info')
workflow_api = self.get_workflow_api(workflow)
task = workflow_api.next_task
workflow_api = self.complete_form(workflow, task, {'short_name': short_name, 'proposal_name': proposal_name})
task = workflow_api.next_task
# The workflow calls study_info('info') and puts the result in Element Documentation
# I create a dictionary of that info with `eval` to make the asserts easier to read
study_info = eval(task.documentation)
self.assertIn('short_name', study_info.keys())
self.assertEqual(short_name, study_info['short_name'])
self.assertIn('proposal_name', study_info.keys())
self.assertIn(proposal_name, study_info['proposal_name'])
@patch('crc.services.protocol_builder.requests.get')
def test_info_script_investigators(self, mock_get):
app.config['PB_ENABLED'] = True