From 1bcf4ea02e487b6a96f887e7d6ae34acbfb4e347 Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Sat, 1 May 2021 15:23:07 -0400 Subject: [PATCH] Test and mock data for new `get_irb_info` service in ProtocolBuilderService --- tests/data/pb_responses/irb_info.json | 38 +++++++++++++++++++++++++++ tests/test_protocol_builder.py | 14 ++++++++++ 2 files changed, 52 insertions(+) create mode 100644 tests/data/pb_responses/irb_info.json diff --git a/tests/data/pb_responses/irb_info.json b/tests/data/pb_responses/irb_info.json new file mode 100644 index 00000000..6ad3b5f2 --- /dev/null +++ b/tests/data/pb_responses/irb_info.json @@ -0,0 +1,38 @@ +[ + { + "AGENDA_DATE": "2021-04-15T00:00:00+00:00", + "DATE_MODIFIED": "2021-04-15T00:00:00+00:00", + "IRBEVENT": "IRB Event 1", + "IRB_ADMINISTRATIVE_REVIEWER": "IRB Admin Reviewer 1", + "IRB_OF_RECORD": "IRB of Record 1", + "IRB_REVIEW_TYPE": "IRB Review Type 1", + "IRB_STATUS": "IRB Status 1", + "STUDYIRBREVIEWERADMIN": "Study IRB Review Admin 1", + "UVA_IRB_HSR_IS_IRB_OF_RECORD_FOR_ALL_SITES": 1, + "UVA_STUDY_TRACKING": "UVA Study Tracking 1" + }, + { + "AGENDA_DATE": "2021-04-15T00:00:00+00:00", + "DATE_MODIFIED": "2021-04-15T00:00:00+00:00", + "IRBEVENT": "IRB Event 2", + "IRB_ADMINISTRATIVE_REVIEWER": "IRB Admin Reviewer 2", + "IRB_OF_RECORD": "IRB of Record 2", + "IRB_REVIEW_TYPE": "IRB Review Type 2", + "IRB_STATUS": "IRB Status 2", + "STUDYIRBREVIEWERADMIN": "Study IRB Review Admin 2", + "UVA_IRB_HSR_IS_IRB_OF_RECORD_FOR_ALL_SITES": 2, + "UVA_STUDY_TRACKING": "UVA Study Tracking 2" + }, + { + "AGENDA_DATE": "2021-04-15T00:00:00+00:00", + "DATE_MODIFIED": "2021-04-15T00:00:00+00:00", + "IRBEVENT": "IRB Event 3", + "IRB_ADMINISTRATIVE_REVIEWER": "IRB Admin Reviewer 3", + "IRB_OF_RECORD": "IRB of Record 3", + "IRB_REVIEW_TYPE": "IRB Review Type 3", + "IRB_STATUS": "IRB Status 3", + "STUDYIRBREVIEWERADMIN": "Study IRB Review Admin 3", + "UVA_IRB_HSR_IS_IRB_OF_RECORD_FOR_ALL_SITES": 3, + "UVA_STUDY_TRACKING": "UVA Study Tracking 3" + } +] \ No newline at end of file diff --git a/tests/test_protocol_builder.py b/tests/test_protocol_builder.py index b76f248e..1a90e51e 100644 --- a/tests/test_protocol_builder.py +++ b/tests/test_protocol_builder.py @@ -60,3 +60,17 @@ class TestProtocolBuilder(BaseTest): self.assertEqual(2, response[0]["SS_STUDY"]) self.assertEqual(2453, response[0]["SPONSOR_ID"]) self.assertEqual("Abbott Ltd", response[0]["SP_NAME"]) + + @patch('crc.services.protocol_builder.requests.get') + def test_get_irb_info(self, mock_get): + app.config['PB_ENABLED'] = True + mock_get.return_value.ok = True + mock_get.return_value.text = self.protocol_builder_response('irb_info.json') + response = ProtocolBuilderService.get_irb_info(self.test_study_id) + self.assertIsNotNone(response) + self.assertEqual(3, len(response)) + self.assertEqual('IRB Event 1', response[0]["IRBEVENT"]) + self.assertEqual('IRB Event 2', response[1]["IRBEVENT"]) + self.assertEqual('IRB Event 3', response[2]["IRBEVENT"]) + + print('test_get_irb_info') \ No newline at end of file