55import unittest
66import uuid
77
8- from unittest .mock import patch
98from fhir .resources .R4B .bundle import Bundle
109from fhir .resources .R4B .immunization import Immunization
1110from unittest .mock import create_autospec , ANY , patch , Mock
1211from urllib .parse import urlencode
1312import urllib .parse
14- from moto import mock_aws
1513from authorization import Authorization
1614from fhir_controller import FhirController
1715from fhir_repository import ImmunizationRepository
2220 InvalidPatientId ,
2321 CustomValidationError ,
2422 ParameterException ,
25- InconsistentIdError ,
2623 UnauthorizedVaxError ,
27- UnauthorizedError ,
2824 IdentifierDuplicationError ,
2925)
3026from tests .utils .immunization_utils import create_covid_19_immunization
3127from parameter_parser import patient_identifier_system , process_search_params
3228from tests .utils .generic_utils import load_json_data
33- from tests .utils .values_for_tests import ValidValues
3429
3530class TestFhirControllerBase (unittest .TestCase ):
3631 """Base class for all tests to set up common fixtures"""
@@ -211,7 +206,7 @@ def test_get_imms_by_identifer_patient_identifier_and_element_present(self, mock
211206 # When
212207 response = self .controller .get_immunization_by_identifier (lambda_event )
213208 # Then
214- self .service .get_immunization_by_identifier .assert_not_called
209+ self .service .get_immunization_by_identifier .assert_not_called ()
215210
216211 self .assertEqual (response ["statusCode" ], 400 )
217212 body = json .loads (response ["body" ])
@@ -234,7 +229,7 @@ def test_get_imms_by_identifer_both_body_and_query_params_present(self, mock_get
234229 # When
235230 response = self .controller .get_immunization_by_identifier (lambda_event )
236231 # Then
237- self .service .get_immunization_by_identifier .assert_not_called
232+ self .service .get_immunization_by_identifier .assert_not_called ()
238233
239234 self .assertEqual (response ["statusCode" ], 400 )
240235 body = json .loads (response ["body" ])
@@ -257,7 +252,7 @@ def test_get_imms_by_identifer_imms_identifier_and_element_not_present(self, moc
257252 # When
258253 response = self .controller .get_immunization_by_identifier (lambda_event )
259254 # Then
260- self .service .get_immunization_by_identifier .assert_not_called
255+ self .service .get_immunization_by_identifier .assert_not_called ()
261256
262257 self .assertEqual (response ["statusCode" ], 400 )
263258 body = json .loads (response ["body" ])
@@ -281,7 +276,7 @@ def test_get_imms_by_identifer_both_identifier_present(self, mock_get_supplier_p
281276 # When
282277 response = self .controller .get_immunization_by_identifier (lambda_event )
283278 # Then
284- self .service .get_immunization_by_identifier .assert_not_called
279+ self .service .get_immunization_by_identifier .assert_not_called ()
285280
286281 self .assertEqual (response ["statusCode" ], 400 )
287282 body = json .loads (response ["body" ])
@@ -565,7 +560,7 @@ def test_get_imms_by_identifer_patient_identifier_and_element_present(self, mock
565560 # When
566561 response = self .controller .get_immunization_by_identifier (lambda_event )
567562 # Then
568- self .service .get_immunization_by_identifier .assert_not_called
563+ self .service .get_immunization_by_identifier .assert_not_called ()
569564
570565 self .assertEqual (response ["statusCode" ], 400 )
571566 body = json .loads (response ["body" ])
@@ -585,7 +580,7 @@ def test_get_imms_by_identifer_imms_identifier_and_element_not_present(self,mock
585580 # When
586581 response = self .controller .get_immunization_by_identifier (lambda_event )
587582 # Then
588- self .service .get_immunization_by_identifier .assert_not_called
583+ self .service .get_immunization_by_identifier .assert_not_called ()
589584
590585 self .assertEqual (response ["statusCode" ], 400 )
591586 body = json .loads (response ["body" ])
@@ -669,7 +664,7 @@ def test_get_imms_by_identifer_both_identifier_present(self, mock_get_supplier_p
669664 # When
670665 response = self .controller .get_immunization_by_identifier (lambda_event )
671666 # Then
672- self .service .get_immunization_by_identifier .assert_not_called
667+ self .service .get_immunization_by_identifier .assert_not_called ()
673668
674669 self .assertEqual (response ["statusCode" ], 400 )
675670 body = json .loads (response ["body" ])
@@ -810,7 +805,7 @@ def test_get_imms_by_id(self, mock_permissions):
810805 response = self .controller .get_immunization_by_id (lambda_event )
811806 # Then
812807 mock_permissions .assert_called_once_with ("test" )
813- self .service .get_immunization_by_id .assert_called_once_with (imms_id , [ "COVID19.CRUDS" ] )
808+ self .service .get_immunization_by_id .assert_called_once_with (imms_id , "test" )
814809
815810 self .assertEqual (response ["statusCode" ], 200 )
816811 body = json .loads (response ["body" ])
@@ -833,6 +828,7 @@ def test_get_imms_by_id_unauthorised_vax_error(self,mock_permissions):
833828 # Then
834829 mock_permissions .assert_called_once_with ("test" )
835830 self .assertEqual (response ["statusCode" ], 403 )
831+
836832 @patch ("fhir_controller.get_supplier_permissions" )
837833 def test_get_imms_by_id_no_vax_permission (self , mock_permissions ):
838834 """it should return Immunization Id if it exists"""
@@ -867,7 +863,7 @@ def test_not_found(self,mock_permissions):
867863
868864 # Then
869865 mock_permissions .assert_called_once_with ("test" )
870- self .service .get_immunization_by_id .assert_called_once_with (imms_id , [ "COVID19.CRUDS" ] )
866+ self .service .get_immunization_by_id .assert_called_once_with (imms_id , "test" )
871867
872868 self .assertEqual (response ["statusCode" ], 404 )
873869 body = json .loads (response ["body" ])
@@ -913,7 +909,7 @@ def test_create_immunization(self,mock_get_permissions):
913909
914910 imms_obj = json .loads (aws_event ["body" ])
915911 mock_get_permissions .assert_called_once_with ("Test" )
916- self .service .create_immunization .assert_called_once_with (imms_obj , [ "COVID19.CRUDS" , "FLU.CRUDS" ], "Test" )
912+ self .service .create_immunization .assert_called_once_with (imms_obj , "Test" )
917913 self .assertEqual (response ["statusCode" ], 201 )
918914 self .assertTrue ("body" not in response )
919915 self .assertTrue (response ["headers" ]["Location" ].endswith (f"Immunization/{ imms_id } " ))
@@ -1324,7 +1320,7 @@ def test_update_record_exists(self, mock_get_supplier_permissions):
13241320 response = self .controller .get_immunization_by_id (lambda_event )
13251321
13261322 # Then
1327- self .service .get_immunization_by_id .assert_called_once_with (imms_id , [ "COVID19.CRUDS" ] )
1323+ self .service .get_immunization_by_id .assert_called_once_with (imms_id , "Test" )
13281324
13291325 self .assertEqual (response ["statusCode" ], 404 )
13301326 body = json .loads (response ["body" ])
0 commit comments