@@ -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
93130class TestGetImmunization (unittest .TestCase ):
94131 def setUp (self ):
0 commit comments