From 69974e89fd414d6f9d97aaccd522791964ce35ca Mon Sep 17 00:00:00 2001 From: mike cullerton Date: Fri, 9 Jul 2021 11:39:30 -0400 Subject: [PATCH] Added 2 simple tests for filtering by REVIEW_TYPE --- tests/study/test_study_service.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/study/test_study_service.py b/tests/study/test_study_service.py index 8d625d1f..ff33b52c 100644 --- a/tests/study/test_study_service.py +++ b/tests/study/test_study_service.py @@ -233,3 +233,23 @@ class TestStudyService(BaseTest): # Both Alex and Aaron are SI, and both should be returned. self.assertEqual("ajl2j", investigators['SI']['user_id']) self.assertEqual("cah3us", investigators['SI_2']['user_id']) + + @patch('crc.services.protocol_builder.ProtocolBuilderService.get_study_details') # mock_details + def test_get_user_studies(self, mock_details): + details_response = self.protocol_builder_response('study_details.json') + mock_details.return_value = json.loads(details_response) + + user = self.create_user_with_study_and_workflow() + studies = StudyService().get_studies_for_user(user) + # study_details has a valid REVIEW_TYPE, so we should get 1 study back + self.assertEqual(1, len(studies)) + + @patch('crc.services.protocol_builder.ProtocolBuilderService.get_study_details') # mock_details + def test_get_user_studies_bad_review_type(self, mock_details): + details_response = self.protocol_builder_response('study_details_bad_review_type.json') + mock_details.return_value = json.loads(details_response) + + user = self.create_user_with_study_and_workflow() + studies = StudyService().get_studies_for_user(user) + # study_details has an invalid REVIEW_TYPE, so we should get 0 studies back + self.assertEqual(0, len(studies))