Merge pull request #212 from sartography/dev

Assert field types are set in the validation code.
This commit is contained in:
Dan Funk 2020-12-29 14:35:51 -05:00 committed by GitHub
commit e1eee2bbd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 119 additions and 56 deletions

View File

@ -127,6 +127,10 @@ class WorkflowService(object):
form_data = task.data # Just like with the front end, we start with what was already there, and modify it.
hide_groups = []
for field in task_api.form.fields:
# Assure we have a field type
if field.type is None:
raise ApiError(code='invalid_form_data',
message='Field type is None. A field type must be provided.')
# Assure field has valid properties
WorkflowService.check_field_properties(field, task)

View File

@ -25,7 +25,7 @@
<camunda:formData>
<camunda:formField id="favorite_color" label="What is your favorite color?" type="string" defaultValue="Yellow" />
<camunda:formField id="quest" label="What is your quest?" type="string" defaultValue="To seek the holly Grail!" />
<camunda:formField id="swallow_speed" label="What is the air speed velocity of an unladen swallow?" defaultValue="About 24 miles per hour" />
<camunda:formField id="swallow_speed" label="What is the air speed velocity of an unladen swallow?" type="string" defaultValue="About 24 miles per hour" />
</camunda:formData>
</bpmn:extensionElements>
<bpmn:incoming>Flow_0a7090c</bpmn:incoming>
@ -48,13 +48,7 @@ Your supervisor provided the following feedback:
{{feedback}}
You are all done! WARNING: If you go back and reanswer the questions it will create a new approval request.
</bpmn:documentation>
You are all done! WARNING: If you go back and reanswer the questions it will create a new approval request.</bpmn:documentation>
<bpmn:incoming>Flow_1g38q6b</bpmn:incoming>
</bpmn:endEvent>
<bpmn:manualTask id="Activity_19ccxoj" name="Review Feedback">
@ -68,13 +62,7 @@ Your Supervisor provided the following feedback:
{{feedback}}
Please press save to re-try the questions, and submit your responses again.
</bpmn:documentation>
Please press save to re-try the questions, and submit your responses again.</bpmn:documentation>
<bpmn:incoming>Flow_0vnghsi</bpmn:incoming>
<bpmn:outgoing>Flow_070gq5r</bpmn:outgoing>
</bpmn:manualTask>
@ -108,29 +96,21 @@ Please press save to re-try the questions, and submit your responses again.
<bpmndi:BPMNShape id="Participant_0ozb2sp_di" bpmnElement="Participant_0ozb2sp" isHorizontal="true">
<dc:Bounds x="190" y="80" width="550" height="370" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Lane_1s1s7a1_di" bpmnElement="Lane_1s1s7a1" isHorizontal="true">
<dc:Bounds x="220" y="80" width="520" height="245" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Lane_1m47545_di" bpmnElement="Lane_1m47545" isHorizontal="true">
<dc:Bounds x="220" y="325" width="520" height="125" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="TextAnnotation_1ys83yq_di" bpmnElement="TextAnnotation_1ys83yq">
<dc:Bounds x="250" y="100" width="130.6238034460753" height="68.28334396936822" />
<bpmndi:BPMNShape id="Lane_1s1s7a1_di" bpmnElement="Lane_1s1s7a1" isHorizontal="true">
<dc:Bounds x="220" y="80" width="520" height="245" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_0a7090c_di" bpmnElement="Flow_0a7090c">
<di:waypoint x="276" y="260" />
<di:waypoint x="330" y="260" />
<bpmndi:BPMNEdge id="Flow_070gq5r_di" bpmnElement="Flow_070gq5r">
<di:waypoint x="510" y="220" />
<di:waypoint x="510" y="160" />
<di:waypoint x="380" y="160" />
<di:waypoint x="380" y="220" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1gp4zfd_di" bpmnElement="Flow_1gp4zfd">
<di:waypoint x="430" y="390" />
<di:waypoint x="485" y="390" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0vnghsi_di" bpmnElement="Flow_0vnghsi">
<di:waypoint x="510" y="365" />
<di:waypoint x="510" y="300" />
<bpmndi:BPMNLabel>
<dc:Bounds x="520" y="334" width="40" height="14" />
</bpmndi:BPMNLabel>
<bpmndi:BPMNEdge id="Flow_1hcpt7c_di" bpmnElement="Flow_1hcpt7c">
<di:waypoint x="380" y="300" />
<di:waypoint x="380" y="350" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1g38q6b_di" bpmnElement="Flow_1g38q6b">
<di:waypoint x="535" y="390" />
@ -140,15 +120,20 @@ Please press save to re-try the questions, and submit your responses again.
<dc:Bounds x="585" y="372" width="46" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1hcpt7c_di" bpmnElement="Flow_1hcpt7c">
<di:waypoint x="380" y="300" />
<di:waypoint x="380" y="350" />
<bpmndi:BPMNEdge id="Flow_0vnghsi_di" bpmnElement="Flow_0vnghsi">
<di:waypoint x="510" y="365" />
<di:waypoint x="510" y="300" />
<bpmndi:BPMNLabel>
<dc:Bounds x="520" y="334" width="40" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_070gq5r_di" bpmnElement="Flow_070gq5r">
<di:waypoint x="510" y="220" />
<di:waypoint x="510" y="160" />
<di:waypoint x="380" y="160" />
<di:waypoint x="380" y="220" />
<bpmndi:BPMNEdge id="Flow_1gp4zfd_di" bpmnElement="Flow_1gp4zfd">
<di:waypoint x="430" y="390" />
<di:waypoint x="485" y="390" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0a7090c_di" bpmnElement="Flow_0a7090c">
<di:waypoint x="276" y="260" />
<di:waypoint x="330" y="260" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="240" y="242" width="36" height="36" />
@ -168,6 +153,9 @@ Please press save to re-try the questions, and submit your responses again.
<bpmndi:BPMNShape id="Activity_0zc7cgy_di" bpmnElement="Activity_14eor1x">
<dc:Bounds x="330" y="350" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="TextAnnotation_1ys83yq_di" bpmnElement="TextAnnotation_1ys83yq">
<dc:Bounds x="250" y="100" width="130.6238034460753" height="68.28334396936822" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Association_1kcb9ou_di" bpmnElement="Association_1kcb9ou">
<di:waypoint x="359" y="220" />
<di:waypoint x="333" y="168" />

View File

@ -0,0 +1,72 @@
<?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_a699b4a" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="3.0.0-dev">
<bpmn:process id="Process_PrintName" name="PrintName" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>Flow_1wfzn0v</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="Flow_1wfzn0v" sourceRef="StartEvent_1" targetRef="Activity_GetName" />
<bpmn:sequenceFlow id="Flow_0e9yohi" sourceRef="Activity_GetName" targetRef="Activity_PrintHello" />
<bpmn:sequenceFlow id="Flow_1nt2lx5" sourceRef="Activity_PrintHello" targetRef="Activity_ThankYou" />
<bpmn:endEvent id="Event_EndEvent" name="End Event">
<bpmn:incoming>Flow_1yrn6kp</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="Flow_1yrn6kp" sourceRef="Activity_ThankYou" targetRef="Event_EndEvent" />
<bpmn:userTask id="Activity_GetName" name="Get Name" camunda:formKey="GetNameForm">
<bpmn:extensionElements>
<camunda:formData>
<camunda:formField id="name" label="Name: " defaultValue="World" />
</camunda:formData>
</bpmn:extensionElements>
<bpmn:incoming>Flow_1wfzn0v</bpmn:incoming>
<bpmn:outgoing>Flow_0e9yohi</bpmn:outgoing>
</bpmn:userTask>
<bpmn:scriptTask id="Activity_PrintHello" name="Print Hello">
<bpmn:incoming>Flow_0e9yohi</bpmn:incoming>
<bpmn:outgoing>Flow_1nt2lx5</bpmn:outgoing>
<bpmn:script>print('Hello', name)</bpmn:script>
</bpmn:scriptTask>
<bpmn:scriptTask id="Activity_ThankYou" name="Thank You">
<bpmn:incoming>Flow_1nt2lx5</bpmn:incoming>
<bpmn:outgoing>Flow_1yrn6kp</bpmn:outgoing>
<bpmn:script>print('Thank You')</bpmn:script>
</bpmn:scriptTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_PrintName">
<bpmndi:BPMNEdge id="Flow_1yrn6kp_di" bpmnElement="Flow_1yrn6kp">
<di:waypoint x="690" y="177" />
<di:waypoint x="752" y="177" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1nt2lx5_di" bpmnElement="Flow_1nt2lx5">
<di:waypoint x="530" y="177" />
<di:waypoint x="590" y="177" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0e9yohi_di" bpmnElement="Flow_0e9yohi">
<di:waypoint x="370" y="177" />
<di:waypoint x="430" y="177" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1wfzn0v_di" bpmnElement="Flow_1wfzn0v">
<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="Event_04bt6qi_di" bpmnElement="Event_EndEvent">
<dc:Bounds x="752" y="159" width="36" height="36" />
<bpmndi:BPMNLabel>
<dc:Bounds x="745" y="202" width="51" height="14" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_170ilqg_di" bpmnElement="Activity_GetName">
<dc:Bounds x="270" y="137" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_09hu4va_di" bpmnElement="Activity_PrintHello">
<dc:Bounds x="430" y="137" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0mtp7p7_di" bpmnElement="Activity_ThankYou">
<dc:Bounds x="590" y="137" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>

View File

@ -2,20 +2,6 @@ from tests.base_test import BaseTest
from crc import mail
# class TestEmailDirectly(BaseTest):
#
# def test_email_directly(self):
# recipients = ['michaelc@cullerton.com']
# sender = 'michaelc@cullerton.com'
# with mail.record_messages() as outbox:
# mail.send_message(subject='testing',
# body='test',
# recipients=recipients,
# sender=sender)
# assert len(outbox) == 1
# assert outbox[0].subject == "testing"
class TestEmailScript(BaseTest):
def test_email_script(self):
@ -57,7 +43,6 @@ class TestEmailScript(BaseTest):
with self.assertRaises(AssertionError):
self.complete_form(workflow, first_task, {'email_address': 'test@example'})
def test_bad_email_address_2(self):
workflow = self.create_workflow('email_script')

View File

@ -0,0 +1,14 @@
import json
from tests.base_test import BaseTest
class TestFormFieldType(BaseTest):
def test_form_field_type(self):
spec_model = self.load_test_spec('workflow_form_field_type')
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]['message'],
'When populating all fields ... Field type is None. A field type must be provided.')
# print('TestFormFieldType: Good Form')