88sys .path .append (f"{ os .path .dirname (os .path .abspath (__file__ ))} /../src" )
99
1010from dynamodb import EventTable
11- from get_imms_handler import get_imms , create_response
11+ from get_imms_handler import get_imms , create_operation_outcome
1212
1313
1414class TestGetImms (unittest .TestCase ):
@@ -18,16 +18,16 @@ def setUp(self):
1818 def test_get_imms_happy_path (self ):
1919 # Arrange
2020 self .dynamodb_service .get_event_by_id = MagicMock (return_value = {"message" : "Mocked event data" })
21- formatted_event = {"pathParameters" : {"id" : "sampleid " }}
21+ lambda_event = {"pathParameters" : {"id" : "sample-id " }}
2222
2323 # Act
24- result = get_imms (formatted_event , self .dynamodb_service )
24+ result = get_imms (lambda_event , self .dynamodb_service )
2525
2626 # Assert
27- self .dynamodb_service .get_event_by_id .assert_called_once_with (formatted_event ["pathParameters" ]["id" ])
28- assert result ['statusCode' ] == 200
27+ self .dynamodb_service .get_event_by_id .assert_called_once_with (lambda_event ["pathParameters" ]["id" ])
28+ self . assertEqual ( result ['statusCode' ], 200 )
2929 self .assertEqual (result ['headers' ]['Content-Type' ], "application/fhir+json" )
30- assert json .loads (result ['body' ]) == {"message" : "Mocked event data" }
30+ self . assertDictEqual ( json .loads (result ['body' ]), {"message" : "Mocked event data" })
3131
3232 def test_get_imms_handler_sad_path_400 (self ):
3333 unformatted_event = {"pathParameters" : {"id" : "unexpected_id" }}
@@ -39,9 +39,9 @@ def test_get_imms_handler_sad_path_400(self):
3939 assert result ['statusCode' ] == 400
4040 self .assertEqual (result ['headers' ]['Content-Type' ], "application/fhir+json" )
4141 act_body = json .loads (result ['body' ])
42- exp_body = create_response (str (uuid .uuid4 ()),
43- "he provided event ID is either missing or not in the expected format." ,
44- "invalid" )
42+ exp_body = create_operation_outcome (str (uuid .uuid4 ()),
43+ "he provided event ID is either missing or not in the expected format." ,
44+ "invalid" )
4545 act_body ["id" ] = None
4646 exp_body ["id" ] = None
4747 self .assertDictEqual (act_body , exp_body )
@@ -58,7 +58,7 @@ def test_get_imms_handler_sad_path_404(self):
5858 assert result ['statusCode' ] == 404
5959 self .assertEqual (result ['headers' ]['Content-Type' ], "application/fhir+json" )
6060 act_body = json .loads (result ['body' ])
61- exp_body = create_response (str (uuid .uuid4 ()), "The requested resource was not found." , "not-found" )
61+ exp_body = create_operation_outcome (str (uuid .uuid4 ()), "The requested resource was not found." , "not-found" )
6262 act_body ["id" ] = None
6363 exp_body ["id" ] = None
6464 self .assertDictEqual (act_body , exp_body )
0 commit comments