Skip to content

Commit 2897833

Browse files
committed
Add unit test for duplicate site SNOMED validation in immunization batch service
- Implemented a new test to ensure that duplicate site SNOMED codings are rejected during batch validation. - The test verifies that the appropriate validation error message is raised and that the create_immunization method is not called when duplicates are present.
1 parent 3f5ee89 commit 2897833

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

lambdas/recordforwarder/tests/service/test_fhir_batch_service.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,25 @@ def test_create_immunization_invalid_patient_identifier_system(self):
120120
)
121121
self.mock_repo.create_immunization.assert_not_called()
122122

123+
def test_create_immunization_duplicate_site_snomed_still_rejected_for_batch(self):
124+
"""it should keep batch validation unchanged for duplicate site SNOMED codings"""
125+
126+
imms = create_covid_immunization_dict_no_id()
127+
imms["site"]["coding"].append(deepcopy(imms["site"]["coding"][0]))
128+
expected_msg = "Validation errors: site.coding[?(@.system=='http://snomed.info/sct')] must be unique"
129+
130+
with self.assertRaises(CustomValidationError) as error:
131+
self.pre_validate_fhir_service.create_immunization(
132+
immunization=imms,
133+
supplier_system="test_supplier",
134+
vax_type="test_vax",
135+
table=self.mock_table,
136+
imms_pk=None,
137+
)
138+
139+
self.assertEqual(expected_msg, error.exception.message)
140+
self.mock_repo.create_immunization.assert_not_called()
141+
123142

124143
class TestUpdateImmunizationBatchService(TestFhirBatchServiceBase):
125144
def setUp(self):

0 commit comments

Comments
 (0)