@@ -19,6 +19,12 @@ class DeltaTestCase(unittest.TestCase):
1919 def setUp (self ):
2020 # Common setup if needed
2121 self .context = {}
22+ self .logger_exception_patch = patch ("delta.logger.exception" )
23+ self .mock_logger_exception = self .logger_exception_patch .start ()
24+
25+ def tearDown (self ):
26+ # Stop the patch after each test
27+ self .logger_exception_patch .stop ()
2228
2329 @staticmethod
2430 def setup_mock_sqs (mock_boto_client , return_value = {"ResponseMetadata" : {"HTTPStatusCode" : 200 }}):
@@ -202,6 +208,7 @@ def test_handler_success_remove(self, mock_boto_resource, mock_send_log):
202208 # Assert
203209 self .assertEqual (result ["statusCode" ], 200 )
204210
211+ # @TOD Check this
205212 @patch ("delta.FirehoseLogger.send_log" ) # Patch the method directly
206213 @patch ("boto3.resource" )
207214 @patch ("boto3.client" )
@@ -233,17 +240,21 @@ def test_handler_exception_intrusion(self, mock_boto_resource, mock_boto_client,
233240
234241 @patch ("delta.FirehoseLogger.send_log" )
235242 @patch ("boto3.resource" )
236- @patch ("delta.handler" )
237- def test_handler_exception_intrusion_check_false (self , mock_boto_resource , mock_boto_client , mock_send_log ):
243+ @patch ("boto3.client" )
244+ @patch ("delta.boto3.resource" )
245+ def test_handler_exception_intrusion_check_false (self , mock_dynamodb , mock_boto_resource , mock_boto_client , mock_send_log ):
238246 # Arrange
239- mock_send_log .return_value = None
240247 self .setUp_mock_resources (mock_boto_resource , mock_boto_client )
248+
249+ # set up the event
241250 event = self .get_event ()
242251 context = {}
243252
244253 # Act & Assert
245254 with self .assertRaises (Exception ):
246255 handler (event , context )
256+
257+ self .mock_logger_exception .assert_called ()
247258
248259 @patch ("delta.FirehoseLogger.send_log" ) # Patch the method directly
249260 @patch ("boto3.client" )
0 commit comments