Skip to content

Commit b309292

Browse files
committed
Fix delete endpoint
1 parent 33cb049 commit b309292

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

backend/src/service/fhir_service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,12 @@ def delete_immunization(self, imms_id: str, supplier_system: str) -> Immunizatio
230230
Exception will be raised if resource does not exist. Multiple calls to this method won't change
231231
the record in the database.
232232
"""
233-
existing_immunisation = self.immunization_repo.get_immunization_by_id(imms_id)
233+
existing_immunisation, _ = self.immunization_repo.get_immunization_by_id(imms_id)
234234

235235
if not existing_immunisation:
236236
raise ResourceNotFoundError(resource_type="Immunization", resource_id=imms_id)
237237

238-
vaccination_type = get_vaccine_type(existing_immunisation.get("Resource", {}))
238+
vaccination_type = get_vaccine_type(existing_immunisation)
239239

240240
if not self.authoriser.authorise(supplier_system, ApiOperationCode.DELETE, {vaccination_type}):
241241
raise UnauthorizedVaxError()

backend/tests/service/test_fhir_service.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ def test_delete_immunization(self):
729729
imms = json.loads(create_covid_19_immunization(self.TEST_IMMUNISATION_ID).json())
730730
self.mock_redis_client.hget.return_value = "COVID19"
731731
self.authoriser.authorise.return_value = True
732-
self.imms_repo.get_immunization_by_id.return_value = {"Resource": imms}
732+
self.imms_repo.get_immunization_by_id.return_value = (imms, "1")
733733
self.imms_repo.delete_immunization.return_value = imms
734734

735735
# When
@@ -744,7 +744,7 @@ def test_delete_immunization(self):
744744

745745
def test_delete_immunization_throws_not_found_exception_if_does_not_exist(self):
746746
"""it should raise a ResourceNotFound exception if the immunisation does not exist"""
747-
self.imms_repo.get_immunization_by_id.return_value = None
747+
self.imms_repo.get_immunization_by_id.return_value = (None, None)
748748

749749
# When
750750
with self.assertRaises(ResourceNotFoundError):
@@ -758,7 +758,7 @@ def test_delete_immunization_throws_authorisation_exception_if_does_not_have_req
758758
imms = json.loads(create_covid_19_immunization(self.TEST_IMMUNISATION_ID).json())
759759
self.mock_redis_client.hget.return_value = "FLU"
760760
self.authoriser.authorise.return_value = False
761-
self.imms_repo.get_immunization_by_id.return_value = {"Resource": imms}
761+
self.imms_repo.get_immunization_by_id.return_value = (imms, "1")
762762

763763
# When
764764
with self.assertRaises(UnauthorizedVaxError):

0 commit comments

Comments
 (0)