Skip to content

Commit 8c1b480

Browse files
committed
direct mock
1 parent c8085ae commit 8c1b480

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

backend/tests/test_parameter_parser.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ def setUp(self):
2828
self.mock_logger_info = self.logger_info_patcher.start()
2929
self.redis_patcher = patch("parameter_parser.redis_client")
3030
self.mock_redis_client = self.redis_patcher.start()
31-
self.mock_redis_client.hkeys.side_effect = mock_redis_hkeys
3231

3332
def tearDown(self):
3433
patch.stopall()
@@ -103,7 +102,7 @@ def test_process_search_params_checks_patient_identifier_format(self):
103102
'"https://fhir.nhs.uk/Id/nhs-number|{NHS number}" '
104103
'e.g. "https://fhir.nhs.uk/Id/nhs-number|9000000009"',
105104
)
106-
105+
self.mock_redis_client.hkeys.return_value = ["RSV"]
107106
params = process_search_params(
108107
{
109108
self.patient_identifier_key: ["https://fhir.nhs.uk/Id/nhs-number|9000000009"],
@@ -113,6 +112,7 @@ def test_process_search_params_checks_patient_identifier_format(self):
113112
self.assertIsNotNone(params)
114113

115114
def test_process_search_params_whitelists_immunization_target(self):
115+
self.mock_redis_client.hkeys.return_value = ["RSV"]
116116
with self.assertRaises(ParameterException) as e:
117117
process_search_params(
118118
{
@@ -135,6 +135,7 @@ def test_process_search_params_whitelists_immunization_target(self):
135135
self.assertIsNotNone(params)
136136

137137
def test_search_params_date_from_must_be_before_date_to(self):
138+
self.mock_redis_client.hkeys.return_value = ["RSV"]
138139
params = process_search_params(
139140
{
140141
self.patient_identifier_key: ["https://fhir.nhs.uk/Id/nhs-number|9000000009"],
@@ -170,6 +171,7 @@ def test_search_params_date_from_must_be_before_date_to(self):
170171
self.assertEqual(str(e.exception), f"Search parameter {date_from_key} must be before {date_to_key}")
171172

172173
def test_process_search_params_immunization_target_is_mandatory(self):
174+
self.mock_redis_client.hkeys.return_value = ["RSV"]
173175
with self.assertRaises(ParameterException) as e:
174176
_ = process_search_params(
175177
{

0 commit comments

Comments
 (0)