From 7938ac8eedef4dfcb114ea7b853985e3fa1fbfdc Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Mon, 28 Dec 2020 18:02:16 -0500 Subject: [PATCH 1/4] We now assure each form field has a field type. Modified populate_form_with_random_data, added check at beginning of form field loop. --- crc/services/workflow_service.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crc/services/workflow_service.py b/crc/services/workflow_service.py index 06c48ff9..4319e10d 100644 --- a/crc/services/workflow_service.py +++ b/crc/services/workflow_service.py @@ -126,6 +126,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) From 06318c87b1d25e9084fe9f3b1e5a2a264d21e674 Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Mon, 28 Dec 2020 18:03:59 -0500 Subject: [PATCH 2/4] Test and workflow for changes to workflow_service. The workflow does not have a field type. We look for evidence of raised exception in data of response. --- .../workflow_form_field_type.bpmn | 72 +++++++++++++++++++ .../workflow/test_workflow_form_field_type.py | 14 ++++ 2 files changed, 86 insertions(+) create mode 100644 tests/data/workflow_form_field_type/workflow_form_field_type.bpmn create mode 100644 tests/workflow/test_workflow_form_field_type.py diff --git a/tests/data/workflow_form_field_type/workflow_form_field_type.bpmn b/tests/data/workflow_form_field_type/workflow_form_field_type.bpmn new file mode 100644 index 00000000..aa4b010f --- /dev/null +++ b/tests/data/workflow_form_field_type/workflow_form_field_type.bpmn @@ -0,0 +1,72 @@ + + + + + Flow_1wfzn0v + + + + + + Flow_1yrn6kp + + + + + + + + + Flow_1wfzn0v + Flow_0e9yohi + + + Flow_0e9yohi + Flow_1nt2lx5 + print('Hello', name) + + + Flow_1nt2lx5 + Flow_1yrn6kp + print('Thank You') + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/workflow/test_workflow_form_field_type.py b/tests/workflow/test_workflow_form_field_type.py new file mode 100644 index 00000000..406d2669 --- /dev/null +++ b/tests/workflow/test_workflow_form_field_type.py @@ -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') From 052ee40238bd143805cff9810dc01e27ae55f5ea Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Mon, 28 Dec 2020 18:05:47 -0500 Subject: [PATCH 3/4] Cleanup from test email script changes. Removed commented piece of code containing my private email address. --- tests/test_email_script.py | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/tests/test_email_script.py b/tests/test_email_script.py index 42257d4b..ee3d7219 100644 --- a/tests/test_email_script.py +++ b/tests/test_email_script.py @@ -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') From 96739d99c4f90a518f9f9ca3396ad1c4a3fee903 Mon Sep 17 00:00:00 2001 From: Dan Date: Tue, 29 Dec 2020 11:14:40 -0500 Subject: [PATCH 4/4] Fixing a failing test because new logic was catching a different error. --- tests/data/invalid_roles/invalid_roles.bpmn | 70 +++++++++------------ 1 file changed, 29 insertions(+), 41 deletions(-) diff --git a/tests/data/invalid_roles/invalid_roles.bpmn b/tests/data/invalid_roles/invalid_roles.bpmn index de10f712..b68d186a 100644 --- a/tests/data/invalid_roles/invalid_roles.bpmn +++ b/tests/data/invalid_roles/invalid_roles.bpmn @@ -25,7 +25,7 @@ - + Flow_0a7090c @@ -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. - - - - - - +You are all done! WARNING: If you go back and reanswer the questions it will create a new approval request. Flow_1g38q6b @@ -68,13 +62,7 @@ Your Supervisor provided the following feedback: {{feedback}} -Please press save to re-try the questions, and submit your responses again. - - - - - - +Please press save to re-try the questions, and submit your responses again. Flow_0vnghsi Flow_070gq5r @@ -108,29 +96,21 @@ Please press save to re-try the questions, and submit your responses again. - - - - - + + - - - + + + + + - - - - - - - - - - + + + @@ -140,15 +120,20 @@ Please press save to re-try the questions, and submit your responses again. - - - + + + + + + - - - - - + + + + + + + @@ -168,6 +153,9 @@ Please press save to re-try the questions, and submit your responses again. + + +