@@ -25,7 +25,7 @@ def setUp(self):
2525 def tearDown (self ):
2626 patch .stopall ()
2727
28- def test_send_log_to_firehose_success (self , mock_firehose_client ):
28+ def test_send_log_to_firehose_success (self ):
2929 """Test send_log_to_firehose with successful firehose response"""
3030 # Arrange
3131 test_log_data = {"function_name" : "test_func" , "result" : "success" }
@@ -42,16 +42,6 @@ def test_send_log_to_firehose_success(self, mock_firehose_client):
4242 Record = expected_record
4343 )
4444
45- # Act
46- send_log_to_firehose (self .test_stream , test_log_data )
47-
48- # Assert
49- expected_record = {"Data" : json .dumps ({"event" : test_log_data }).encode ("utf-8" )}
50- mock_firehose_client .put_record .assert_called_once_with (
51- DeliveryStreamName = self .test_stream ,
52- Record = expected_record
53- )
54-
5545 def test_send_log_to_firehose_exception (self ):
5646 """Test send_log_to_firehose with firehose exception"""
5747 # Arrange
@@ -69,7 +59,8 @@ def test_send_log_to_firehose_exception(self):
6959 )
7060
7161 @patch ("time.time" )
72- def test_generate_and_send_logs_success (self , mock_time ):
62+ @patch ("common.log_decorator.send_log_to_firehose" )
63+ def test_generate_and_send_logs_success (self , mock_send_log , mock_time ):
7364 """Test generate_and_send_logs with successful log generation"""
7465 # Arrange
7566 mock_time .return_value = 1000.5
@@ -89,10 +80,11 @@ def test_generate_and_send_logs_success(self, mock_time):
8980 "result" : "success"
9081 }
9182 self .mock_logger_error .assert_not_called ()
92- self . mock_send_log .assert_called_once_with (self .test_stream , expected_log_data )
83+ mock_send_log .assert_called_once_with (self .test_stream , expected_log_data )
9384
9485 @patch ("time.time" )
95- def test_generate_and_send_logs_error (self , mock_time ):
86+ @patch ("common.log_decorator.send_log_to_firehose" )
87+ def test_generate_and_send_logs_error (self , mock_send_log , mock_time ):
9688 """Test generate_and_send_logs with error log generation"""
9789 # Arrange
9890 mock_time .return_value = 1000.75
@@ -112,7 +104,7 @@ def test_generate_and_send_logs_error(self, mock_time):
112104 "error" : "Test error"
113105 }
114106 self .mock_logger_error .assert_called_once_with (json .dumps (expected_log_data ))
115- self . mock_send_log .assert_called_once_with (self .test_stream , expected_log_data )
107+ mock_send_log .assert_called_once_with (self .test_stream , expected_log_data )
116108
117109 @patch ("common.log_decorator.time" )
118110 @patch ("common.log_decorator.datetime" )
@@ -208,4 +200,3 @@ def test_send_log_to_firehose_exception_logging(self):
208200 "Error sending log to Firehose: %s" ,
209201 test_error
210202 )
211-
0 commit comments