Skip to content

Commit e0c77c8

Browse files
committed
test_unexpected_bucket_name_with_extended_attributes_file
1 parent e263c64 commit e0c77c8

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

lambdas/filenameprocessor/tests/test_lambda_handler.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,30 @@ def test_unexpected_bucket_name(self, mock_get_redis_client):
559559
self.assertIn(ravs_record.file_key, args)
560560
self.assertIn("unknown-bucket", args)
561561

562+
def test_unexpected_bucket_name_with_extended_attributes_file(self):
563+
"""Tests if extended attributes file is handled when bucket name is incorrect"""
564+
valid_file_key = "Vaccination_Extended_Attributes_V1_5_X8E5B_20000101T00000001.csv"
565+
record = {
566+
"s3": {
567+
"bucket": {"name": "unknown-bucket"},
568+
"object": {"key": valid_file_key},
569+
}
570+
}
571+
572+
with patch("file_name_processor.logger") as mock_logger:
573+
result = handle_record(record)
574+
575+
self.assertEqual(result["statusCode"], 500)
576+
self.assertIn("unexpected bucket name", result["message"])
577+
self.assertEqual(result["file_key"], valid_file_key)
578+
self.assertEqual(result["vaccine_supplier_info"], f"X8E5B_{EXTENDED_ATTRIBUTES_VACC_TYPE}")
579+
580+
mock_logger.error.assert_called_once()
581+
args = mock_logger.error.call_args[0]
582+
self.assertIn("Unable to process file", args[0])
583+
self.assertIn(valid_file_key, args)
584+
self.assertIn("unknown-bucket", args)
585+
562586
def test_unexpected_bucket_name_and_filename_validation_fails(self):
563587
"""Tests if filename validation error is handled when bucket name is incorrect"""
564588
invalid_file_key = "InvalidVaccineType_Vaccinations_v5_YGM41_20240708T12130100.csv"

0 commit comments

Comments
 (0)