@@ -104,10 +104,10 @@ def test_splunk_logging_successful_rows(self):
104104 """Tests a single object in the body of the event"""
105105
106106 for operation in ["CREATE" , "UPDATE" , "DELETE" ]:
107- with (
108- patch ("logging_decorators.send_log_to_firehose" ) as mock_send_log_to_firehose ,
109- patch ("logging_decorators.logger" ) as mock_logger ,
110- ):
107+ with ( # noqa: E999
108+ patch ("logging_decorators.send_log_to_firehose" ) as mock_send_log_to_firehose , # noqa: E999
109+ patch ("logging_decorators.logger" ) as mock_logger , # noqa: E999
110+ ): # noqa: E999
111111 result = lambda_handler (event = generate_event ([{"operation_requested" : operation }]), context = {})
112112
113113 self .assertEqual (result , {"statusCode" : 200 , "body" : json .dumps ("Lambda function executed successfully!" )})
@@ -132,17 +132,18 @@ def test_splunk_logging_successful_rows(self):
132132 def test_splunk_logging_missing_data (self ):
133133 """Tests missing key values in the body of the event"""
134134
135- with (
136- patch ("logging_decorators.send_log_to_firehose" ) as mock_send_log_to_firehose ,
137- patch ("logging_decorators.logger" ) as mock_logger ,
138- ):
135+ with ( # noqa: E999
136+ patch ("logging_decorators.send_log_to_firehose" ) as mock_send_log_to_firehose , # noqa: E999
137+ patch ("logging_decorators.logger" ) as mock_logger , # noqa: E999
138+ ): # noqa: E999
139139 with self .assertRaises (Exception ):
140140 lambda_handler (event = {"Records" : [{"body" : json .dumps ([{"" : "456" }])}]}, context = {})
141141
142142 expected_first_logger_info_data = {** InvalidValues .Logging_with_no_values }
143143
144144 expected_first_logger_error_data = self .expected_lambda_handler_logs (
145- success = False , number_of_rows = 1 , ingestion_complete = False , diagnostics = "'NoneType' object has no attribute 'replace'"
145+ success = False , number_of_rows = 1 , ingestion_complete = False ,
146+ diagnostics = "'NoneType' object has no attribute 'replace'"
146147 )
147148
148149 first_logger_info_call_args = json .loads (self .extract_all_call_args_for_logger_info (mock_logger )[0 ])
@@ -171,10 +172,10 @@ def test_splunk_logging_statuscode_diagnostics(
171172 ]
172173
173174 for test_case in test_cases :
174- with (
175- patch ("logging_decorators.send_log_to_firehose" ) as mock_send_log_to_firehose ,
176- patch ("logging_decorators.logger" ) as mock_logger ,
177- ):
175+ with ( # noqa: E999
176+ patch ("logging_decorators.send_log_to_firehose" ) as mock_send_log_to_firehose , # noqa: E999
177+ patch ("logging_decorators.logger" ) as mock_logger , # noqa: E999
178+ ): # noqa: E999
178179 result = lambda_handler (event = generate_event ([{"diagnostics" : test_case ["diagnostics" ]}]), context = {})
179180
180181 self .assertEqual (result , EXPECTED_ACK_LAMBDA_RESPONSE_FOR_SUCCESS )
@@ -202,10 +203,10 @@ def test_splunk_logging_multiple_rows(self):
202203 """Tests logging for multiple objects in the body of the event"""
203204 messages = [{"row_id" : "test1" }, {"row_id" : "test2" }]
204205
205- with (
206- patch ("logging_decorators.send_log_to_firehose" ) as mock_send_log_to_firehose ,
207- patch ("logging_decorators.logger" ) as mock_logger ,
208- ):
206+ with ( # noqa: E999
207+ patch ("logging_decorators.send_log_to_firehose" ) as mock_send_log_to_firehose , # noqa: E999
208+ patch ("logging_decorators.logger" ) as mock_logger , # noqa: E999
209+ ): # noqa: E999
209210 result = lambda_handler (generate_event (messages ), context = {})
210211
211212 self .assertEqual (result , EXPECTED_ACK_LAMBDA_RESPONSE_FOR_SUCCESS )
@@ -252,10 +253,10 @@ def test_splunk_logging_multiple_with_diagnostics(
252253 {"row_id" : "test3" , "operation_requested" : "DELETE" , "diagnostics" : DiagnosticsDictionaries .NO_PERMISSIONS },
253254 ]
254255
255- with (
256- patch ("logging_decorators.send_log_to_firehose" ) as mock_send_log_to_firehose ,
257- patch ("logging_decorators.logger" ) as mock_logger ,
258- ):
256+ with ( # noqa: E999
257+ patch ("logging_decorators.send_log_to_firehose" ) as mock_send_log_to_firehose , # noqa: E999
258+ patch ("logging_decorators.logger" ) as mock_logger , # noqa: E999
259+ ): # noqa: E999
259260 result = lambda_handler (generate_event (messages ), context = {})
260261
261262 self .assertEqual (result , EXPECTED_ACK_LAMBDA_RESPONSE_FOR_SUCCESS )
@@ -317,11 +318,12 @@ def test_splunk_update_ack_file_not_logged(self):
317318 message_value = "test" + str (i )
318319 messages .append ({"row_id" : message_value })
319320
320- with (
321- patch ("logging_decorators.send_log_to_firehose" ) as mock_send_log_to_firehose ,
322- patch ("logging_decorators.logger" ) as mock_logger ,
323- patch ("update_ack_file.change_audit_table_status_to_processed" ) as mock_change_audit_table_status_to_processed ,
324- ):
321+ with ( # noqa: E999
322+ patch ("logging_decorators.send_log_to_firehose" ) as mock_send_log_to_firehose , # noqa: E999
323+ patch ("logging_decorators.logger" ) as mock_logger , # noqa: E999
324+ patch ("update_ack_file.change_audit_table_status_to_processed" )
325+ as mock_change_audit_table_status_to_processed , # noqa: E999
326+ ): # noqa: E999
325327 result = lambda_handler (generate_event (messages ), context = {})
326328
327329 self .assertEqual (result , EXPECTED_ACK_LAMBDA_RESPONSE_FOR_SUCCESS )
@@ -347,7 +349,6 @@ def test_splunk_update_ack_file_not_logged(self):
347349 )
348350 mock_change_audit_table_status_to_processed .assert_not_called ()
349351
350-
351352 def test_splunk_update_ack_file_logged (self ):
352353 """Tests that update_ack_file is logged if we have sent acks for the whole file"""
353354 # send 99 messages
@@ -356,11 +357,12 @@ def test_splunk_update_ack_file_logged(self):
356357 message_value = "test" + str (i )
357358 messages .append ({"row_id" : message_value })
358359
359- with (
360- patch ("logging_decorators.send_log_to_firehose" ) as mock_send_log_to_firehose ,
361- patch ("logging_decorators.logger" ) as mock_logger ,
362- patch ("update_ack_file.change_audit_table_status_to_processed" ) as mock_change_audit_table_status_to_processed ,
363- ):
360+ with ( # noqa: E999
361+ patch ("logging_decorators.send_log_to_firehose" ) as mock_send_log_to_firehose , # noqa: E999
362+ patch ("logging_decorators.logger" ) as mock_logger , # noqa: E999
363+ patch ("update_ack_file.change_audit_table_status_to_processed" )
364+ as mock_change_audit_table_status_to_processed , # noqa: E999
365+ ): # noqa: E999
364366 result = lambda_handler (generate_event (messages ), context = {})
365367
366368 self .assertEqual (result , EXPECTED_ACK_LAMBDA_RESPONSE_FOR_SUCCESS )
@@ -374,7 +376,9 @@ def test_splunk_update_ack_file_logged(self):
374376 "message_id" : "test1" ,
375377 "time_taken" : "1.0s"
376378 }
377- expected_last_logger_info_data = self .expected_lambda_handler_logs (success = True , number_of_rows = 99 , ingestion_complete = True )
379+ expected_last_logger_info_data = self .expected_lambda_handler_logs (
380+ success = True , number_of_rows = 99 , ingestion_complete = True
381+ )
378382
379383 all_logger_info_call_args = self .extract_all_call_args_for_logger_info (mock_logger )
380384 thirdlast_logger_info_call_args = json .loads (all_logger_info_call_args [98 ])
0 commit comments