2222 InvalidPatientId ,
2323 CustomValidationError ,
2424 ParameterException ,
25- InconsistentIdError ,
2625 UnauthorizedVaxError ,
27- UnauthorizedError ,
2826 IdentifierDuplicationError ,
2927)
3028from tests .utils .immunization_utils import create_covid_19_immunization
3129from parameter_parser import patient_identifier_system , process_search_params
3230from tests .utils .generic_utils import load_json_data
33- from tests . utils . values_for_tests import ValidValues
31+ from sample_data . mock_redis_cache import fake_hkeys
3432
35- "test"
33+
34+ class TestFhirControllerBase (unittest .TestCase ):
35+ """Base class for all tests to set up common fixtures"""
36+
37+ def setUp (self ):
38+ super ().setUp ()
39+ self .redis_patcher = patch ("parameter_parser.redis_client" )
40+ self .mock_redis_client = self .redis_patcher .start ()
41+ self .mock_redis_client .hkeys .side_effect = fake_hkeys
42+ self .logger_info_patcher = patch ("logging.Logger.info" )
43+ self .mock_logger_info = self .logger_info_patcher .start ()
44+
45+ def tearDown (self ):
46+ self .redis_patcher .stop ()
47+ self .logger_info_patcher .stop ()
48+ super ().tearDown ()
3649
3750
3851class TestFhirController (unittest .TestCase ):
@@ -1561,8 +1574,9 @@ def test_immunization_unhandled_error(self, mock_get_supplier_permissions):
15611574 self .assertEqual (body ["resourceType" ], "OperationOutcome" )
15621575 self .assertEqual (body ["issue" ][0 ]["code" ], "exception" )
15631576
1564- class TestSearchImmunizations (unittest . TestCase ):
1577+ class TestSearchImmunizations (TestFhirControllerBase ):
15651578 def setUp (self ):
1579+ super ().setUp ()
15661580 self .service = create_autospec (FhirService )
15671581 self .authorizer = create_autospec (Authorization )
15681582 self .controller = FhirController (self .authorizer , self .service )
@@ -1573,6 +1587,9 @@ def setUp(self):
15731587 self .nhs_number_valid_value = "9000000009"
15741588 self .patient_identifier_valid_value = f"{ patient_identifier_system } |{ self .nhs_number_valid_value } "
15751589
1590+ def tearDown (self ):
1591+ return super ().tearDown ()
1592+
15761593 @patch ("fhir_controller.get_supplier_permissions" )
15771594 def test_get_search_immunizations (self , mock_get_supplier_permissions ):
15781595 """it should search based on patient_identifier and immunization_target"""
0 commit comments