Skip to content

Commit 19dff69

Browse files
committed
Added tests for new repository method
1 parent 5969a9e commit 19dff69

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

backend/tests/repository/test_fhir_repository.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,43 @@ def test_immunization_not_found(self):
8989
self.assertIsNone(immunisation)
9090
self.assertIsNone(immunisation_type)
9191

92+
def test_check_immunization_identifier_exists_returns_true(self):
93+
"""it should return true when a record does exist with the given identifier"""
94+
imms_id = "https://system.com#id-123"
95+
self.table.query = MagicMock(
96+
return_value={
97+
"Items": [
98+
{
99+
"Resource": json.dumps({"item": "exists"}),
100+
"Version": 1,
101+
"PatientSK": "COVID19#2516525251",
102+
"IdentifierPK": "https://system.com#id-123",
103+
}
104+
]
105+
}
106+
)
107+
108+
result = self.repository.check_immunization_identifier_exists("https://system.com", "id-123")
109+
110+
self.table.query.assert_called_once_with(
111+
IndexName="IdentifierGSI",
112+
KeyConditionExpression=Key("IdentifierPK").eq(imms_id),
113+
)
114+
self.assertTrue(result)
115+
116+
def test_check_immunization_identifier_exists_returns_false_when_no_record_exists(self):
117+
"""it should return false when a record does not exist with the given identifier"""
118+
imms_id = "https://system.com#id-123"
119+
self.table.query = MagicMock(return_value={})
120+
121+
result = self.repository.check_immunization_identifier_exists("https://system.com", "id-123")
122+
123+
self.table.query.assert_called_once_with(
124+
IndexName="IdentifierGSI",
125+
KeyConditionExpression=Key("IdentifierPK").eq(imms_id),
126+
)
127+
self.assertFalse(result)
128+
92129

93130
class TestGetImmunization(unittest.TestCase):
94131
def setUp(self):

0 commit comments

Comments
 (0)