@@ -1149,6 +1149,7 @@ def test_update_immunization_UnauthorizedVaxError(self, mock_get_supplier_permis
11491149 response = self .controller .update_immunization (aws_event )
11501150 mock_get_supplier_permissions .assert_called_once_with ("Test" )
11511151 self .assertEqual (response ["statusCode" ], 403 )
1152+
11521153 @patch ("fhir_controller.get_supplier_permissions" )
11531154 def test_update_immunization_UnauthorizedVaxError_check_for_non_batch (self , mock_get_supplier_permissions ):
11541155 """it should not update the Immunization record"""
@@ -1479,6 +1480,44 @@ def test_update_immunization_for_batch_with_invalid_json(self, mock_get_supplier
14791480 self .assertEqual (response ["statusCode" ], 400 )
14801481 outcome = json .loads (response ["body" ])
14811482 self .assertEqual (outcome ["resourceType" ], "OperationOutcome" )
1483+
1484+ @patch ("fhir_controller.get_supplier_permissions" )
1485+ def test_update_immunization_when_reinstated_true (self , mock_get_permissions ):
1486+ """it should update reinstated Immunization"""
1487+ mock_get_permissions .return_value = ["COVID19.CRUD" ]
1488+ imms_id = "valid-id"
1489+ imms = '{"id": "valid-id"}'
1490+ aws_event = {
1491+ "headers" : {"E-Tag" : 1 , "SupplierSystem" : "Test" },
1492+ "body" : imms ,
1493+ "pathParameters" : {"id" : imms_id },
1494+ }
1495+ self .service .update_reinstated_immunization .return_value = UpdateOutcome .UPDATE , {}, 3
1496+ self .service .get_immunization_by_id_all .return_value = {
1497+ "resource" : "existing" ,
1498+ "Version" : 1 ,
1499+ "DeletedAt" : False ,
1500+ "Reinstated" : True ,
1501+ "VaccineType" : "COVID19" ,
1502+ }
1503+
1504+ response = self .controller .update_immunization (aws_event )
1505+
1506+ self .service .update_reinstated_immunization .assert_called_once_with (
1507+ imms_id , json .loads (imms ), 1 , ["COVID19.CRUD" ], "Test"
1508+ )
1509+ self .assertEqual (response ["statusCode" ], 200 )
1510+ self .assertEqual (json .loads (response ["body" ]), {"E-Tag" : 3 })
1511+
1512+ def test_update_immunization_missing_id (self ):
1513+ """it should raise KeyError if pathParameters['id'] is missing"""
1514+ aws_event = {
1515+ "headers" : {"E-Tag" : 1 , "SupplierSystem" : "Test" },
1516+ "body" : '{"id": "valid-id"}' ,
1517+ "pathParameters" : {}, # 'id' is missing
1518+ }
1519+ with self .assertRaises (KeyError ):
1520+ self .controller .update_immunization (aws_event )
14821521
14831522
14841523class TestDeleteImmunization (unittest .TestCase ):
0 commit comments