mirror of
https://github.com/sartography/cr-connect-workflow.git
synced 2025-02-21 20:28:10 +00:00
Merge pull request #235 from sartography/index-error-for-enums-186
Index error for enums 186
This commit is contained in:
commit
df25b83958
@ -322,7 +322,11 @@ class WorkflowService(object):
|
||||
data = db.session.query(LookupDataModel).filter(
|
||||
LookupDataModel.lookup_file_model == lookup_model).limit(10).all()
|
||||
options = [{"value": d.value, "label": d.label, "data": d.data} for d in data]
|
||||
return random.choice(options)
|
||||
if len(options) > 0:
|
||||
return random.choice(options)
|
||||
else:
|
||||
raise ApiError.from_task("invalid enum", "You specified an enumeration field (%s),"
|
||||
" with no options" % field.id, task)
|
||||
else:
|
||||
raise ApiError.from_task("unknown_lookup_option", "The settings for this auto complete field "
|
||||
"are incorrect: %s " % field.id, task)
|
||||
|
BIN
tests/data/enum_empty_list/empty_spreadsheet.xls
Normal file
BIN
tests/data/enum_empty_list/empty_spreadsheet.xls
Normal file
Binary file not shown.
62
tests/data/enum_empty_list/enum_empty_list.bpmn
Normal file
62
tests/data/enum_empty_list/enum_empty_list.bpmn
Normal file
@ -0,0 +1,62 @@
|
||||
<?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_0vm4ua3" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.2.0">
|
||||
<bpmn:process id="Process_EmptyEnum" name="Empty Enum" isExecutable="true">
|
||||
<bpmn:startEvent id="StartEvent_1">
|
||||
<bpmn:outgoing>Flow_08cjvuw</bpmn:outgoing>
|
||||
</bpmn:startEvent>
|
||||
<bpmn:sequenceFlow id="Flow_08cjvuw" sourceRef="StartEvent_1" targetRef="Activity_EmptyEnum" />
|
||||
<bpmn:userTask id="Activity_EmptyEnum" name="Empty Enum" camunda:formKey="EmptyEnumForm">
|
||||
<bpmn:extensionElements>
|
||||
<camunda:formData>
|
||||
<camunda:formField id="empty_select" label="Select One" type="enum">
|
||||
<camunda:properties>
|
||||
<camunda:property id="spreadsheet.name" value="empty_spreadsheet.xls" />
|
||||
<camunda:property id="spreadsheet.value.column" value="COMPANY_ID" />
|
||||
<camunda:property id="spreadsheet.label.column" value="COMPANY_NAME" />
|
||||
</camunda:properties>
|
||||
</camunda:formField>
|
||||
</camunda:formData>
|
||||
</bpmn:extensionElements>
|
||||
<bpmn:incoming>Flow_08cjvuw</bpmn:incoming>
|
||||
<bpmn:outgoing>Flow_0qm71qa</bpmn:outgoing>
|
||||
</bpmn:userTask>
|
||||
<bpmn:sequenceFlow id="Flow_0qm71qa" sourceRef="Activity_EmptyEnum" targetRef="Activity_GoodBye" />
|
||||
<bpmn:endEvent id="Event_034utr4">
|
||||
<bpmn:incoming>Flow_0ynk21r</bpmn:incoming>
|
||||
</bpmn:endEvent>
|
||||
<bpmn:sequenceFlow id="Flow_0ynk21r" sourceRef="Activity_GoodBye" targetRef="Event_034utr4" />
|
||||
<bpmn:manualTask id="Activity_GoodBye" name="Good Bye">
|
||||
<bpmn:documentation><H1>Good Bye</H1></bpmn:documentation>
|
||||
<bpmn:incoming>Flow_0qm71qa</bpmn:incoming>
|
||||
<bpmn:outgoing>Flow_0ynk21r</bpmn:outgoing>
|
||||
</bpmn:manualTask>
|
||||
</bpmn:process>
|
||||
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
|
||||
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_EmptyEnum">
|
||||
<bpmndi:BPMNEdge id="Flow_08cjvuw_di" bpmnElement="Flow_08cjvuw">
|
||||
<di:waypoint x="215" y="117" />
|
||||
<di:waypoint x="270" y="117" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="Flow_0qm71qa_di" bpmnElement="Flow_0qm71qa">
|
||||
<di:waypoint x="370" y="117" />
|
||||
<di:waypoint x="430" y="117" />
|
||||
</bpmndi:BPMNEdge>
|
||||
<bpmndi:BPMNEdge id="Flow_0ynk21r_di" bpmnElement="Flow_0ynk21r">
|
||||
<di:waypoint x="530" y="117" />
|
||||
<di:waypoint x="592" 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="Activity_1mqyx7y_di" bpmnElement="Activity_EmptyEnum">
|
||||
<dc:Bounds x="270" y="77" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Event_034utr4_di" bpmnElement="Event_034utr4">
|
||||
<dc:Bounds x="592" y="99" width="36" height="36" />
|
||||
</bpmndi:BPMNShape>
|
||||
<bpmndi:BPMNShape id="Activity_0obcp1b_di" bpmnElement="Activity_GoodBye">
|
||||
<dc:Bounds x="430" y="77" width="100" height="80" />
|
||||
</bpmndi:BPMNShape>
|
||||
</bpmndi:BPMNPlane>
|
||||
</bpmndi:BPMNDiagram>
|
||||
</bpmn:definitions>
|
13
tests/workflow/test_workflow_enum_empty_list.py
Normal file
13
tests/workflow/test_workflow_enum_empty_list.py
Normal file
@ -0,0 +1,13 @@
|
||||
from tests.base_test import BaseTest
|
||||
import json
|
||||
|
||||
|
||||
class TestEmptyEnumList(BaseTest):
|
||||
|
||||
def test_empty_enum_list(self):
|
||||
|
||||
spec_model = self.load_test_spec('enum_empty_list')
|
||||
rv = self.app.get('/v1.0/workflow-specification/%s/validate' % spec_model.id, headers=self.logged_in_headers())
|
||||
json_data = json.loads(rv.get_data(as_text=True))
|
||||
|
||||
self.assertEqual(json_data[0]['code'], 'invalid enum')
|
Loading…
x
Reference in New Issue
Block a user