Skip to content

Commit f294314

Browse files
committed
search imms & post validator
1 parent 3ff146b commit f294314

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

backend/tests/test_immunization_post_validator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from copy import deepcopy
77
from pydantic import ValidationError
88
from jsonpath_ng.ext import parse
9+
from sample_data.mock_redis_cache import fake_hget
910

1011

1112
from src.models.fhir_immunization import ImmunizationValidator
@@ -41,6 +42,7 @@ def setUp(self):
4142
]
4243
self.redis_patcher = patch("models.utils.validation_utils.redis_client")
4344
self.mock_redis_client = self.redis_patcher.start()
45+
self.mock_redis_client.hget.side_effect = fake_hget
4446

4547
def test_collected_errors(self):
4648
"""Test that when passed multiple validation errors, it returns a list of all expected errors"""

backend/tests/test_search_imms.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import json
22
import unittest
3-
from unittest.mock import create_autospec
3+
from unittest.mock import create_autospec, patch
44

55
from fhir_controller import FhirController
66
from models.errors import Severity, Code, create_operation_outcome
@@ -14,6 +14,11 @@
1414
class TestSearchImmunizations(unittest.TestCase):
1515
def setUp(self):
1616
self.controller = create_autospec(FhirController)
17+
self.logger_exception_patcher = patch("logging.Logger.exception")
18+
self.mock_logger_exception = self.logger_exception_patcher.start()
19+
20+
def tearDown(self):
21+
patch.stopall()
1722

1823
def test_search_immunizations(self):
1924
"""it should return a list of Immunizations"""
@@ -153,7 +158,7 @@ def test_handle_exception(self):
153158

154159
# Then
155160
act_body = json.loads(act_res["body"])
156-
act_body["id"] = None
161+
# act_body["id"] = None
157162

158163
self.assertEqual(exp_error["issue"][0]["code"], act_body["issue"][0]["code"])
159164
self.assertEqual(exp_error["issue"][0]["severity"], act_body["issue"][0]["severity"])

0 commit comments

Comments
 (0)