From fa61aa0354fec76b11e152aa347a28da0d27fe97 Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Fri, 3 Dec 2021 11:45:39 -0500 Subject: [PATCH] Tests for set_study_status --- .../set_study_status/set_study_status.bpmn | 114 ++++++++++++++++++ tests/scripts/test_set_study_status.py | 37 ++++++ 2 files changed, 151 insertions(+) create mode 100644 tests/data/set_study_status/set_study_status.bpmn create mode 100644 tests/scripts/test_set_study_status.py diff --git a/tests/data/set_study_status/set_study_status.bpmn b/tests/data/set_study_status/set_study_status.bpmn new file mode 100644 index 00000000..af1027d3 --- /dev/null +++ b/tests/data/set_study_status/set_study_status.bpmn @@ -0,0 +1,114 @@ + + + + + Flow_0c77bdh + + + + + + + + + + + + + + Flow_1e9oiuw + Flow_0q0rtvj + + + + Flow_0q0rtvj + Flow_0ana8xt + returned_status = set_study_status(selected_status) + + + + # Study Status + +## Original Status +{{ original_status }} + +## Selected Status +{{ selected_status }} + +## Returned Status +{{ returned_status }} + + +## New Status +{{ new_status }} + Flow_0nckhhn + Flow_14s6jnt + + + Flow_14s6jnt + + + + + + Flow_0c77bdh + Flow_1e9oiuw + original_status = get_study_status() + + + + Flow_0ana8xt + Flow_0nckhhn + new_status = get_study_status() + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/scripts/test_set_study_status.py b/tests/scripts/test_set_study_status.py new file mode 100644 index 00000000..b0404035 --- /dev/null +++ b/tests/scripts/test_set_study_status.py @@ -0,0 +1,37 @@ +from tests.base_test import BaseTest + + +class TestSetStudyStatus(BaseTest): + + def test_set_study_status_validation(self): + self.load_example_data() + spec_model = self.load_test_spec('set_study_status') + rv = self.app.get('/v1.0/workflow-specification/%s/validate' % spec_model.id, headers=self.logged_in_headers()) + self.assertEqual([], rv.json) + + def test_set_study_status(self): + workflow = self.create_workflow('set_study_status') + workflow_api = self.get_workflow_api(workflow) + task = workflow_api.next_task + + original_status = task.data['original_status'] + self.assertEqual('in_progress', original_status) + + workflow_api = self.complete_form(workflow, task, {'selected_status': 'hold'}) + task = workflow_api.next_task + + self.assertEqual('Activity_DisplayStatus', task.name) + self.assertEqual('hold', task.data['selected_status']) + self.assertEqual('hold', task.data['new_status']) + + def test_set_study_status_fail(self): + + self.load_example_data() + workflow = self.create_workflow('set_study_status') + workflow_api = self.get_workflow_api(workflow) + task = workflow_api.next_task + + with self.assertRaises(AssertionError): + self.complete_form(workflow, task, {'selected_status': 'asdf'}) + + print('test_set_study_status_fail')