File tree Expand file tree Collapse file tree 7 files changed +21
-5
lines changed
Expand file tree Collapse file tree 7 files changed +21
-5
lines changed Original file line number Diff line number Diff line change 88from models .errors import Severity , Code , create_operation_outcome
99from log_structure import function_info
1010from constants import GENERIC_SERVER_ERROR_DIAGNOSTICS_MESSAGE
11+ from clients import logger
1112
1213logging .basicConfig (level = "INFO" )
1314logger = logging .getLogger ()
1415
16+
1517@function_info
1618def get_imms_handler (event , _context ):
1719 return get_immunization_by_id (event , make_controller ())
Original file line number Diff line number Diff line change 22import time
33
44from functools import wraps
5+ from clients import logger
6+
57
68logging .basicConfig ()
79logger = logging .getLogger ()
Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ def setUp(self):
1313 self .controller = create_autospec (FhirController )
1414 self .logger_info_patcher = patch ("logging.Logger.info" )
1515 self .mock_logger_info = self .logger_info_patcher .start ()
16+ self .logger_exception_patcher = patch ("logging.Logger.exception" )
17+ self .mock_logger_exception = self .logger_exception_patcher .start ()
18+
1619
1720 def tearDown (self ):
1821 patch .stopall ()
@@ -31,7 +34,7 @@ def test_create_immunization(self):
3134 self .controller .create_immunization .assert_called_once_with (lambda_event )
3235 self .assertDictEqual (exp_res , act_res )
3336
34- def test_handle_exception (self ):
37+ def test_create_handle_exception (self ):
3538 """unhandled exceptions should result in 500"""
3639 lambda_event = {"aws" : "event" }
3740 error_msg = "an unhandled error"
Original file line number Diff line number Diff line change 11import json
22import unittest
3- from unittest .mock import create_autospec
3+ from unittest .mock import create_autospec , patch
44
55from delete_imms_handler import delete_immunization
66from fhir_controller import FhirController
1111class TestDeleteImmunizationById (unittest .TestCase ):
1212 def setUp (self ):
1313 self .controller = create_autospec (FhirController )
14+ self .logger_exception_patcher = patch ("logging.Logger.exception" )
15+ self .mock_logger_exception = self .logger_exception_patcher .start ()
16+
17+ def tearDown (self ):
18+ patch .stopall ()
1419
1520 def test_delete_immunization (self ):
1621 """it should delete Immunization"""
@@ -26,7 +31,7 @@ def test_delete_immunization(self):
2631 self .controller .delete_immunization .assert_called_once_with (lambda_event )
2732 self .assertDictEqual (exp_res , act_res )
2833
29- def test_handle_exception (self ):
34+ def test_delete_handle_exception (self ):
3035 """unhandled exceptions should result in 500"""
3136 lambda_event = {"pathParameters" : {"id" : "an-id" }}
3237 error_msg = "an unhandled error"
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ def test_get_immunization_by_id(self):
2727 self .controller .get_immunization_by_id .assert_called_once_with (lambda_event )
2828 self .assertDictEqual (exp_res , act_res )
2929
30- def test_handle_exception (self ):
30+ def test_get_handle_exception (self ):
3131 """unhandled exceptions should result in 500"""
3232 lambda_event = {"headers" : {"id" : "an-id" }, "pathParameters" : {"id" : "an-id" }}
3333 error_msg = "an unhandled error"
Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ def setUp(self):
1818 self .mock_logger_exception = self .logger_exception_patcher .start ()
1919 self .logger_info_patcher = patch ("logging.Logger.info" )
2020 self .mock_logger_info = self .logger_info_patcher .start ()
21+ self .logger_exception_patcher = patch ("logging.Logger.exception" )
22+ self .mock_logger_exception = self .logger_exception_patcher .start ()
2123
2224 def tearDown (self ):
2325 patch .stopall ()
@@ -142,7 +144,7 @@ def test_search_immunizations_lambda_size_limit(self):
142144 self .controller .search_immunizations .assert_called_once_with (lambda_event )
143145 self .assertEqual (act_res ["statusCode" ], 400 )
144146
145- def test_handle_exception (self ):
147+ def test_search_handle_exception (self ):
146148 """unhandled exceptions should result in 500"""
147149 lambda_event = {"pathParameters" : {"id" : "an-id" }}
148150 error_msg = "an unhandled error"
Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ def setUp(self):
1515 self .mock_logger_exception = self .logger_exception_patcher .start ()
1616 self .logger_info_patcher = patch ("logging.Logger.info" )
1717 self .mock_logger_info = self .logger_info_patcher .start ()
18+ self .logger_exception_patcher = patch ("logging.Logger.exception" )
19+ self .mock_logger_exception = self .logger_exception_patcher .start ()
1820
1921 def tearDown (self ):
2022 patch .stopall ()
You can’t perform that action at this time.
0 commit comments