@@ -205,29 +205,29 @@ def test_get_immunization_by_id(self):
205205 imms_id = "an-id"
206206 self .mock_redis_client .hget .return_value = "COVID-19"
207207 self .authoriser .authorise .return_value = True
208- self .imms_repo .get_immunization_by_id .return_value = (create_covid_19_immunization (imms_id ).dict (), "" )
208+ self .imms_repo .get_immunization_and_version_by_id .return_value = (create_covid_19_immunization (imms_id ).dict (), "" )
209209
210210 # When
211- immunisation , version = self .fhir_service .get_immunization_by_id (imms_id , "Test Supplier" )
211+ immunisation , version = self .fhir_service .get_immunization_and_version_by_id (imms_id , "Test Supplier" )
212212
213213 # Then
214214 self .authoriser .authorise .assert_called_once_with ("Test Supplier" , ApiOperationCode .READ , {"COVID-19" })
215- self .imms_repo .get_immunization_by_id .assert_called_once_with (imms_id )
215+ self .imms_repo .get_immunization_and_version_by_id .assert_called_once_with (imms_id )
216216
217217 self .assertEqual (immunisation .id , imms_id )
218218 self .assertEqual (version , "" )
219219
220220 def test_immunization_not_found (self ):
221221 """it should return None if Immunization doesn't exist"""
222222 imms_id = "non-existent-id"
223- self .imms_repo .get_immunization_by_id .return_value = None , None
223+ self .imms_repo .get_immunization_and_version_by_id .return_value = None , None
224224
225225 # When
226226 with self .assertRaises (ResourceNotFoundError ) as error :
227- self .fhir_service .get_immunization_by_id (imms_id , "Test Supplier" )
227+ self .fhir_service .get_immunization_and_version_by_id (imms_id , "Test Supplier" )
228228
229229 # Then
230- self .imms_repo .get_immunization_by_id .assert_called_once_with (imms_id )
230+ self .imms_repo .get_immunization_and_version_by_id .assert_called_once_with (imms_id )
231231 self .assertEqual ("Immunization resource does not exist. ID: non-existent-id" , str (error .exception ))
232232
233233 def test_get_immunization_by_id_patient_not_restricted (self ):
@@ -240,17 +240,17 @@ def test_get_immunization_by_id_patient_not_restricted(self):
240240 immunization_data = load_json_data ("completed_covid19_immunization_event.json" )
241241 self .mock_redis_client .hget .return_value = "COVID-19"
242242 self .authoriser .authorise .return_value = True
243- self .imms_repo .get_immunization_by_id .return_value = (immunization_data , "2" )
243+ self .imms_repo .get_immunization_and_version_by_id .return_value = (immunization_data , "2" )
244244
245245 expected_imms = load_json_data ("completed_covid19_immunization_event_for_read.json" )
246246 expected_output = Immunization .parse_obj (expected_imms )
247247
248248 # When
249- actual_output , version = self .fhir_service .get_immunization_by_id (imms_id , "Test Supplier" )
249+ actual_output , version = self .fhir_service .get_immunization_and_version_by_id (imms_id , "Test Supplier" )
250250
251251 # Then
252252 self .authoriser .authorise .assert_called_once_with ("Test Supplier" , ApiOperationCode .READ , {"COVID-19" })
253- self .imms_repo .get_immunization_by_id .assert_called_once_with (imms_id )
253+ self .imms_repo .get_immunization_and_version_by_id .assert_called_once_with (imms_id )
254254 self .assertEqual (actual_output , expected_output )
255255 self .assertEqual (version , "2" )
256256
@@ -284,15 +284,15 @@ def test_unauthorised_error_raised_when_user_lacks_permissions(self):
284284 imms_id = "an-id"
285285 self .mock_redis_client .hget .return_value = "COVID-19"
286286 self .authoriser .authorise .return_value = False
287- self .imms_repo .get_immunization_by_id .return_value = (create_covid_19_immunization (imms_id ).dict (), 1 )
287+ self .imms_repo .get_immunization_and_version_by_id .return_value = (create_covid_19_immunization (imms_id ).dict (), 1 )
288288
289289 with self .assertRaises (UnauthorizedVaxError ):
290290 # When
291- self .fhir_service .get_immunization_by_id (imms_id , "Test Supplier" )
291+ self .fhir_service .get_immunization_and_version_by_id (imms_id , "Test Supplier" )
292292
293293 # Then
294294 self .authoriser .authorise .assert_called_once_with ("Test Supplier" , ApiOperationCode .READ , {"COVID-19" })
295- self .imms_repo .get_immunization_by_id .assert_called_once_with (imms_id )
295+ self .imms_repo .get_immunization_and_version_by_id .assert_called_once_with (imms_id )
296296
297297
298298def test_post_validation_failed_get_invalid_target_disease (self ):
@@ -729,43 +729,43 @@ def test_delete_immunization(self):
729729 imms = json .loads (create_covid_19_immunization (self .TEST_IMMUNISATION_ID ).json ())
730730 self .mock_redis_client .hget .return_value = "COVID19"
731731 self .authoriser .authorise .return_value = True
732- self .imms_repo .get_immunization_by_id .return_value = (imms , "1" )
732+ self .imms_repo .get_immunization_and_version_by_id .return_value = (imms , "1" )
733733 self .imms_repo .delete_immunization .return_value = imms
734734
735735 # When
736736 act_imms = self .fhir_service .delete_immunization (self .TEST_IMMUNISATION_ID , "Test" )
737737
738738 # Then
739- self .imms_repo .get_immunization_by_id .assert_called_once_with (self .TEST_IMMUNISATION_ID )
739+ self .imms_repo .get_immunization_and_version_by_id .assert_called_once_with (self .TEST_IMMUNISATION_ID )
740740 self .imms_repo .delete_immunization .assert_called_once_with (self .TEST_IMMUNISATION_ID , "Test" )
741741 self .authoriser .authorise .assert_called_once_with ("Test" , ApiOperationCode .DELETE , {"COVID19" })
742742 self .assertIsInstance (act_imms , Immunization )
743743 self .assertEqual (act_imms .id , self .TEST_IMMUNISATION_ID )
744744
745745 def test_delete_immunization_throws_not_found_exception_if_does_not_exist (self ):
746746 """it should raise a ResourceNotFound exception if the immunisation does not exist"""
747- self .imms_repo .get_immunization_by_id .return_value = (None , None )
747+ self .imms_repo .get_immunization_and_version_by_id .return_value = (None , None )
748748
749749 # When
750750 with self .assertRaises (ResourceNotFoundError ):
751751 self .fhir_service .delete_immunization (self .TEST_IMMUNISATION_ID , "Test" )
752752
753753 # Then
754- self .imms_repo .get_immunization_by_id .assert_called_once_with (self .TEST_IMMUNISATION_ID )
754+ self .imms_repo .get_immunization_and_version_by_id .assert_called_once_with (self .TEST_IMMUNISATION_ID )
755755 self .imms_repo .delete_immunization .assert_not_called ()
756756
757757 def test_delete_immunization_throws_authorisation_exception_if_does_not_have_required_permissions (self ):
758758 imms = json .loads (create_covid_19_immunization (self .TEST_IMMUNISATION_ID ).json ())
759759 self .mock_redis_client .hget .return_value = "FLU"
760760 self .authoriser .authorise .return_value = False
761- self .imms_repo .get_immunization_by_id .return_value = (imms , "1" )
761+ self .imms_repo .get_immunization_and_version_by_id .return_value = (imms , "1" )
762762
763763 # When
764764 with self .assertRaises (UnauthorizedVaxError ):
765765 self .fhir_service .delete_immunization (self .TEST_IMMUNISATION_ID , "Test" )
766766
767767 # Then
768- self .imms_repo .get_immunization_by_id .assert_called_once_with (self .TEST_IMMUNISATION_ID )
768+ self .imms_repo .get_immunization_and_version_by_id .assert_called_once_with (self .TEST_IMMUNISATION_ID )
769769 self .imms_repo .delete_immunization .assert_not_called ()
770770 self .authoriser .authorise .assert_called_once_with ("Test" , ApiOperationCode .DELETE , {"FLU" })
771771
0 commit comments