@@ -21,59 +21,22 @@ def setUp(self):
2121
2222 self .logger_patcher = patch ('id_sync.logger' )
2323 self .mock_logger = self .logger_patcher .start ()
24-
25- # Patch the logging decorator to pass through
26- # self.log_decorator_patcher = patch('id_sync.logging_decorator')
27- # self.mock_log_decorator = self.log_decorator_patcher.start()
28- # self.mock_log_decorator.return_value = lambda f: f # Pass-through decorator
29-
3024 # Set up test data
3125 self .single_sqs_event = {
3226 'Records' : [
3327 {
34- 'messageId' : '12345-abcde-67890' ,
35- 'receiptHandle' : 'AQEBwJnKyrHigUMZj6rYigCgxlaS3SLy0a...' ,
36- 'body' :
37- ('{"Records":[{"eventSource":"aws:s3","s3":{"bucket":{"name":"test-bucket"},'
38- '"object":{"key":"test-file.txt"}}}]}' ),
39- 'attributes' : {
40- 'ApproximateReceiveCount' : '1' ,
41- 'SentTimestamp' : '1545082649183'
42- },
43- 'messageAttributes' : {},
44- 'md5OfBody' : 'e4e68fb7bd0e697a0ae8f1bb342846b3' ,
45- 'eventSource' : 'aws:sqs' ,
46- 'eventSourceARN' : 'arn:aws:sqs:us-east-1:123456789012:my-queue' ,
47- 'awsRegion' : 'us-east-1'
28+ 'body' : '{"Records":[{"source":"aws:sqs","data":"test-data"}]}'
4829 }
4930 ]
5031 }
5132
5233 self .multi_sqs_event = {
5334 'Records' : [
5435 {
55- 'messageId' : 'message-1' ,
56- 'receiptHandle' : 'receipt-1' ,
57- 'body' : ('{"Records":[{"eventSource":"aws:s3","s3":{"bucket":{"name":"test-bucket"},'
58- '"object":{"key":"file1.txt"}}}]}' ),
59- 'attributes' : {},
60- 'messageAttributes' : {},
61- 'md5OfBody' : 'md5-1' ,
62- 'eventSource' : 'aws:sqs' ,
63- 'eventSourceARN' : 'arn:aws:sqs:us-east-1:123456789012:my-queue' ,
64- 'awsRegion' : 'us-east-1'
36+ 'body' : ('{"Records":[{"source":"aws:sqs"],"data":"a"}' ),
6537 },
6638 {
67- 'messageId' : 'message-2' ,
68- 'receiptHandle' : 'receipt-2' ,
69- 'body' : ('{"Records":[{"eventSource":"aws:s3","s3":{"bucket":{"name":"test-bucket"},'
70- '"object":{"key":"file2.txt"}}}]}' ),
71- 'attributes' : {},
72- 'messageAttributes' : {},
73- 'md5OfBody' : 'md5-2' ,
74- 'eventSource' : 'aws:sqs' ,
75- 'eventSourceARN' : 'arn:aws:sqs:us-east-1:123456789012:my-queue' ,
76- 'awsRegion' : 'us-east-1'
39+ 'body' : ('{"Records":[{"source":"aws:sqs"],"data":"b"}' ),
7740 }
7841 ]
7942 }
@@ -102,7 +65,7 @@ def test_handler_success_single_record(self):
10265
10366 # Assertions
10467 self .mock_aws_lambda_event .assert_called_once_with (self .single_sqs_event )
105- self .mock_process_record .assert_called_once_with (mock_event .records [0 ], None )
68+ self .mock_process_record .assert_called_once_with (mock_event .records [0 ])
10669
10770 self .assertEqual (result ["status" ], "success" )
10871 self .assertEqual (result ["message" ], "Successfully processed 1 records" )
@@ -147,7 +110,7 @@ def test_handler_error_single_record(self):
147110
148111 exception = exception_context .exception
149112 # Assertions
150- self .mock_process_record .assert_called_once_with (mock_event .records [0 ], None )
113+ self .mock_process_record .assert_called_once_with (mock_event .records [0 ])
151114 self .mock_logger .info .assert_any_call ("id_sync processing event with %d records" , 1 )
152115
153116 self .assertEqual (exception .message , "Processed 1 records with 1 errors" )
@@ -267,7 +230,7 @@ def test_handler_process_record_exception(self):
267230 handler (self .single_sqs_event , None )
268231 exception = exception_context .exception
269232 # Assertions
270- self .mock_process_record .assert_called_once_with (mock_event .records [0 ], None )
233+ self .mock_process_record .assert_called_once_with (mock_event .records [0 ])
271234 self .mock_logger .exception .assert_called_once_with ("Error processing id_sync event" )
272235
273236 self .assertEqual (exception .nhs_numbers , None )
0 commit comments