From daef419993318589cbef9382362006e2e7498c7f Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Fri, 10 Dec 2021 16:18:05 -0500 Subject: [PATCH] Tests and workflow for the changes --- .../get_study_progress_status.bpmn | 47 +++++++++++++++++++ .../set_study_progress_status.bpmn | 9 ++-- .../scripts/test_get_study_progress_status.py | 16 +++++++ .../scripts/test_set_study_progress_status.py | 19 ++++---- 4 files changed, 77 insertions(+), 14 deletions(-) create mode 100644 tests/data/get_study_progress_status/get_study_progress_status.bpmn create mode 100644 tests/scripts/test_get_study_progress_status.py diff --git a/tests/data/get_study_progress_status/get_study_progress_status.bpmn b/tests/data/get_study_progress_status/get_study_progress_status.bpmn new file mode 100644 index 00000000..a3d67fb8 --- /dev/null +++ b/tests/data/get_study_progress_status/get_study_progress_status.bpmn @@ -0,0 +1,47 @@ + + + + + Flow_1iqprcz + + + + Flow_1iqprcz + Flow_0npc38l + study_progress_status = get_study_progress_status() + + + # Study Progress Status +{{ study_progress_status }} + Flow_0npc38l + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/data/set_study_progress_status/set_study_progress_status.bpmn b/tests/data/set_study_progress_status/set_study_progress_status.bpmn index bc0714ef..65dd3c53 100644 --- a/tests/data/set_study_progress_status/set_study_progress_status.bpmn +++ b/tests/data/set_study_progress_status/set_study_progress_status.bpmn @@ -9,9 +9,6 @@ - - - @@ -25,7 +22,7 @@ Flow_0q0rtvj Flow_0ana8xt - returned_status = set_study_status(selected_status) + returned_status = set_study_progress_status(selected_status) @@ -55,13 +52,13 @@ Flow_0c77bdh Flow_1e9oiuw - original_status = get_study_status() + original_status = get_study_progress_status() Flow_0ana8xt Flow_0nckhhn - new_status = get_study_status() + new_status = get_study_progress_status() diff --git a/tests/scripts/test_get_study_progress_status.py b/tests/scripts/test_get_study_progress_status.py new file mode 100644 index 00000000..4fb2e333 --- /dev/null +++ b/tests/scripts/test_get_study_progress_status.py @@ -0,0 +1,16 @@ +from tests.base_test import BaseTest + +from crc import session +from crc.models.study import StudyModel, ProgressStatus + + +class TestGetStudyProgressStatus(BaseTest): + + def test_get_study_progress_status(self): + workflow = self.create_workflow('get_study_progress_status') + study_model = session.query(StudyModel).filter(StudyModel.id == workflow.study_id).first() + study_model.progress_status = ProgressStatus.approved + workflow_api = self.get_workflow_api(workflow) + task = workflow_api.next_task + + self.assertEqual(task.data['study_progress_status'], workflow.study.progress_status.value) diff --git a/tests/scripts/test_set_study_progress_status.py b/tests/scripts/test_set_study_progress_status.py index d3b61f42..0b05b54e 100644 --- a/tests/scripts/test_set_study_progress_status.py +++ b/tests/scripts/test_set_study_progress_status.py @@ -1,14 +1,16 @@ from tests.base_test import BaseTest +from crc.models.study import ProgressStatus -class TestSetStudyStatus(BaseTest): - def test_set_study_status_validation(self): +class TestSetStudyProgressStatus(BaseTest): + + def test_set_study_progress_status_validation(self): self.load_example_data() - spec_model = self.load_test_spec('set_study_status') + spec_model = self.load_test_spec('set_study_progress_status') rv = self.app.get('/v1.0/workflow-specification/%s/validate' % spec_model.id, headers=self.logged_in_headers()) # The workflow has an enum option that causes an exception. - # We take advantage of this in test_set_study_status_fail below. + # We take advantage of this in test_set_study_progress_status_fail below. # Sometimes, the validation process chooses the failing path, # so we have to check for that here. try: @@ -17,8 +19,9 @@ class TestSetStudyStatus(BaseTest): # 'asdf' is the failing enum option self.assertEqual('asdf', rv.json[0]['task_data']['selected_status']) - def test_set_study_status(self): - workflow = self.create_workflow('set_study_status') + def test_set_study_progress_status(self): + workflow = self.create_workflow('set_study_progress_status') + workflow.study.progress_status = ProgressStatus.in_progress workflow_api = self.get_workflow_api(workflow) task = workflow_api.next_task @@ -32,10 +35,10 @@ class TestSetStudyStatus(BaseTest): self.assertEqual('disapproved', task.data['selected_status']) self.assertEqual('disapproved', task.data['new_status']) - def test_set_study_status_fail(self): + def test_set_study_progress_status_fail(self): self.load_example_data() - workflow = self.create_workflow('set_study_status') + workflow = self.create_workflow('set_study_progress_status') workflow_api = self.get_workflow_api(workflow) task = workflow_api.next_task