Test that we set file data_store values correctly when using the file_data property
This commit is contained in:
parent
354e20c34b
commit
82bf25cbc6
Binary file not shown.
|
@ -0,0 +1,68 @@
|
|||
<?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_0b469f0" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.0.0-dev">
|
||||
<bpmn:process id="Process_4b7fa29" isExecutable="true">
|
||||
<bpmn:startEvent id="StartEvent_1">
|
||||
<bpmn:outgoing>Flow_1kvuzs1</bpmn:outgoing>
|
||||
</bpmn:startEvent>
|
||||
<bpmn:sequenceFlow id="Flow_1kvuzs1" sourceRef="StartEvent_1" targetRef="Activity_0gtrm5e" />
|
||||
<bpmn:userTask id="Activity_0gtrm5e" name="Select Enum" camunda:formKey="Upload Application">
|
||||
<bpmn:extensionElements>
|
||||
<camunda:formData>
|
||||
<camunda:formField id="IRB_HSR_Application_Type" label="IRB-HSR Application Type" type="enum">
|
||||
<camunda:properties>
|
||||
<camunda:property id="file_data" value="Study_App_Doc" />
|
||||
<camunda:property id="spreadsheet.name" value="IRB_HSR_Application_Type.xlsx" />
|
||||
<camunda:property id="spreadsheet.label.column" value="Label" />
|
||||
<camunda:property id="spreadsheet.value.column" value="Value" />
|
||||
<camunda:property id="group" value="Application" />
|
||||
</camunda:properties>
|
||||
<camunda:validation>
|
||||
<camunda:constraint name="required" config="True" />
|
||||
</camunda:validation>
|
||||
</camunda:formField>
|
||||
<camunda:formField id="Study_App_Doc" label="IRB-HSR Application" type="file" />
|
||||
</camunda:formData>
|
||||
</bpmn:extensionElements>
|
||||
<bpmn:incoming>Flow_1kvuzs1</bpmn:incoming>
|
||||
<bpmn:outgoing>Flow_0han7ki</bpmn:outgoing>
|
||||
</bpmn:userTask>
|
||||
<bpmn:sequenceFlow id="Flow_0han7ki" sourceRef="Activity_0gtrm5e" targetRef="Activity_0gpetln" />
|
||||
<bpmn:manualTask id="Activity_0gpetln" name="Print Enum">
|
||||
<bpmn:documentation># Enum</bpmn:documentation>
|
||||
<bpmn:incoming>Flow_0han7ki</bpmn:incoming>
|
||||
<bpmn:outgoing>Flow_0h5cdg9</bpmn:outgoing>
|
||||
</bpmn:manualTask>
|
||||
<bpmn:endEvent id="Event_124aupd">
|
||||
<bpmn:incoming>Flow_0h5cdg9</bpmn:incoming>
|
||||
</bpmn:endEvent>
|
||||
<bpmn:sequenceFlow id="Flow_0h5cdg9" sourceRef="Activity_0gpetln" targetRef="Event_124aupd" />
|
||||
</bpmn:process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_4b7fa29">
|
||||
<bpmndi:BPMNEdge id="Flow_0h5cdg9_di" bpmnElement="Flow_0h5cdg9">
|
||||
<di:waypoint x="530" y="177" />
|
||||
<di:waypoint x="592" y="177" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="Flow_0han7ki_di" bpmnElement="Flow_0han7ki">
|
||||
<di:waypoint x="370" y="177" />
|
||||
<di:waypoint x="430" y="177" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="Flow_1kvuzs1_di" bpmnElement="Flow_1kvuzs1">
|
||||
<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_11t0hqf_di" bpmnElement="Activity_0gtrm5e">
|
||||
<dc:Bounds x="270" y="137" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Activity_0fax1lv_di" bpmnElement="Activity_0gpetln">
|
||||
<dc:Bounds x="430" y="137" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Event_124aupd_di" bpmnElement="Event_124aupd">
|
||||
<dc:Bounds x="592" y="159" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn:definitions>
|
|
@ -1,18 +1,17 @@
|
|||
import json
|
||||
from tests.base_test import BaseTest
|
||||
|
||||
from crc import db
|
||||
from crc.models.data_store import DataStoreModel
|
||||
from crc.services.file_service import FileService
|
||||
from crc.services.workflow_processor import WorkflowProcessor
|
||||
from tests.base_test import BaseTest
|
||||
from crc.models.workflow import WorkflowStatus
|
||||
from crc import db
|
||||
from crc.api.common import ApiError
|
||||
from crc.models.task_event import TaskEventModel, TaskEventSchema
|
||||
from crc.services.workflow_service import WorkflowService
|
||||
|
||||
from io import BytesIO
|
||||
|
||||
import json
|
||||
|
||||
|
||||
class TestFileDatastore(BaseTest):
|
||||
|
||||
|
||||
def test_file_datastore_workflow(self):
|
||||
self.load_example_data()
|
||||
self.create_reference_document()
|
||||
|
@ -32,3 +31,25 @@ class TestFileDatastore(BaseTest):
|
|||
self.assertEqual(task_data['output'], 'me')
|
||||
self.assertEqual(task_data['output2'], 'nope')
|
||||
|
||||
def test_file_data_store_file_data_property(self):
|
||||
self.load_example_data()
|
||||
workflow = self.create_workflow('enum_file_data')
|
||||
workflow_api = self.get_workflow_api(workflow)
|
||||
task = workflow_api.next_task
|
||||
|
||||
# upload the file
|
||||
correct_name = task.form['fields'][1]['id']
|
||||
data = {'file': (BytesIO(b"abcdef"), 'test_file.txt')}
|
||||
rv = self.app.post('/v1.0/file?study_id=%i&workflow_id=%s&task_id=%s&form_field_key=%s' %
|
||||
(workflow.study_id, workflow.id, task.id, correct_name), data=data, follow_redirects=True,
|
||||
content_type='multipart/form-data', headers=self.logged_in_headers())
|
||||
self.assert_success(rv)
|
||||
file_id = json.loads(rv.get_data())['id']
|
||||
|
||||
# process the form that sets the datastore values
|
||||
self.complete_form(workflow, task, {'Study_App_Doc': {'id': file_id},
|
||||
'IRB_HSR_Application_Type': {'label': 'Expedited Application'}})
|
||||
data_store = db.session.query(DataStoreModel).filter(DataStoreModel.file_id==file_id).first()
|
||||
self.assertEqual('IRB_HSR_Application_Type', data_store.key)
|
||||
self.assertEqual('Expedited Application', data_store.value)
|
||||
print('test_file_data_store_file_data_property')
|
||||
|
|
Loading…
Reference in New Issue