Skip to content

Commit be8cf07

Browse files
committed
test_lambda_handler_extended_attributes_failure
1 parent cbcb558 commit be8cf07

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

lambdas/filenameprocessor/tests/test_lambda_handler.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -315,9 +315,6 @@ def test_lambda_handler_extended_attributes_success(self):
315315
self.assert_no_sqs_message()
316316
self.assert_no_ack_file(test_cases[0])
317317

318-
# This test won't work until we rewrite it to mock a ClientError on copy.
319-
# This is because we removed the is_file_in_bucket check.
320-
'''
321318
def test_lambda_handler_extended_attributes_failure(self):
322319
"""
323320
Tests that for an extended attributes file (prefix starts with 'Vaccination_Extended_Attributes'):
@@ -342,21 +339,15 @@ def test_lambda_handler_extended_attributes_failure(self):
342339

343340
# TODO: rewrite the bucket patches to use moto
344341

345-
# Patch uuid4 (message id), and don't move the file
342+
# Patch uuid4 (message id), and raise an exception instead of moving the file.
346343
with (
347344
patch("file_name_processor.uuid4", return_value=test_cases[0].message_id),
348-
patch(
349-
"file_name_processor.copy_file_to_external_bucket",
350-
side_effect=lambda src_bucket, key, dst_bucket, dst_key, exp_owner, exp_src_owner: (
351-
# effectively do nothing
352-
None,
353-
),
354-
),
345+
patch("file_name_processor.copy_file_to_external_bucket", side_effect=Exception("Test ClientError")),
355346
):
356347
lambda_handler(self.make_event([self.make_record(test_cases[0].file_key)]), None)
357348

358349
# Assert audit table entry captured with Failed and queue_name set to the identifier.
359-
# Assert that the ClientError message is a 404 Not Found.
350+
# Assert that the ClientError message is as expected.
360351
table_items = self.get_audit_table_items()
361352
self.assertEqual(len(table_items), 1)
362353
item = table_items[0]
@@ -369,7 +360,7 @@ def test_lambda_handler_extended_attributes_failure(self):
369360
self.assertEqual(item[AuditTableKeys.STATUS]["S"], "Failed")
370361
self.assertEqual(
371362
item[AuditTableKeys.ERROR_DETAILS]["S"],
372-
"An error occurred (404) when calling the HeadObject operation: Not Found",
363+
"Test ClientError",
373364
)
374365
self.assertEqual(item[AuditTableKeys.EXPIRES_AT]["N"], str(test_cases[0].expires_at))
375366
# File should be moved to source under archive/
@@ -381,7 +372,6 @@ def test_lambda_handler_extended_attributes_failure(self):
381372
# No SQS and no ack file
382373
self.assert_no_sqs_message()
383374
self.assert_no_ack_file(test_cases[0])
384-
'''
385375

386376
def test_lambda_handler_extended_attributes_invalid_key(self):
387377
"""

0 commit comments

Comments
 (0)