Skip to content

Commit ea691fd

Browse files
committed
fix extended attribute test
1 parent a4278b4 commit ea691fd

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

lambdas/filenameprocessor/src/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
EXTENDED_ATTRIBUTES_FILE_PREFIX = "Vaccination_Extended_Attributes"
2525
EXTENDED_ATTRIBUTES_VACC_TYPE = "COVID"
2626
DPS_DESTINATION_PREFIX = "dps_destination"
27+
EA_ARCHIVE_PREFIX = "extended-attributes-archive"
2728
VALID_EA_VERSIONS = "V1_5"
2829
ERROR_TYPE_TO_STATUS_CODE_MAP = {
2930
VaccineTypePermissionsError: 403,

lambdas/filenameprocessor/src/file_name_processor.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from constants import (
2121
DPS_DESTINATION_BUCKET_NAME,
2222
DPS_DESTINATION_PREFIX,
23+
EA_ARCHIVE_PREFIX,
2324
ERROR_TYPE_TO_STATUS_CODE_MAP,
2425
EXPECTED_BUCKET_OWNER_ACCOUNT,
2526
EXTENDED_ATTRIBUTES_FILE_PREFIX,
@@ -272,7 +273,7 @@ def handle_extended_attributes_file(
272273
EXPECTED_BUCKET_OWNER_ACCOUNT,
273274
)
274275

275-
move_file(bucket_name, file_key, f"extended-attributes-archive/{file_key}")
276+
move_file(bucket_name, file_key, f"{EA_ARCHIVE_PREFIX}/{file_key}")
276277

277278
upsert_audit_table(
278279
message_id,

lambdas/filenameprocessor/tests/test_lambda_handler.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,6 @@ def test_lambda_handler_extended_attributes_success(self, mock_get_redis_client)
308308
self.assertEqual(item[AuditTableKeys.TIMESTAMP]["S"], test_cases[0].created_at_formatted_string)
309309
self.assertEqual(item[AuditTableKeys.EXPIRES_AT]["N"], str(test_cases[0].expires_at))
310310
# File should be moved to destination/
311-
# The implementation constructs the destination key with a double slash. Reflect that here.
312311
dest_key = f"dps_destination/{test_cases[0].file_key}"
313312
print(f" destination file is at {s3_client.list_objects(Bucket=BucketNames.DESTINATION)}")
314313
retrieved = s3_client.get_object(Bucket=BucketNames.DESTINATION, Key=dest_key)
@@ -341,7 +340,7 @@ def test_lambda_handler_extended_attributes_failure(self, mock_get_redis_client)
341340
Body=MOCK_EXTENDED_ATTRIBUTES_FILE_CONTENT,
342341
)
343342

344-
# Mock Redis so EA validation passes: supplier present and COVID valid
343+
# Mock Redis so Extended Attributes validation passes: supplier present and COVID valid
345344
mock_redis = fakeredis.FakeStrictRedis()
346345
mock_redis.hget = Mock(side_effect=create_mock_hget({"X8E5B": "RAVS"}, {}))
347346
mock_redis.hkeys = Mock(return_value=["COVID", *all_vaccine_types_in_this_test_file])
@@ -414,7 +413,7 @@ def raise_connection_error(*args, **kwargs):
414413
with patch("file_name_processor.uuid4", return_value=test_case.message_id):
415414
lambda_handler(self.make_event([self.make_record(test_case.file_key)]), None)
416415

417-
# Audit should be Failed with unknown queue_name, file moved to archive
416+
# Audit status should be Failed with unknown queue_name, file moved to archive
418417
item = self.get_audit_table_items()[0]
419418
self.assertEqual(item[AuditTableKeys.MESSAGE_ID]["S"], test_case.message_id)
420419
self.assertEqual(item[AuditTableKeys.FILENAME]["S"], test_case.file_key)
@@ -439,7 +438,7 @@ def test_lambda_handler_extended_attributes_invalid_timestamp(self, mock_get_red
439438
s3_client.put_object(
440439
Bucket=BucketNames.SOURCE, Key=invalid_timestamp_key, Body=MOCK_EXTENDED_ATTRIBUTES_FILE_CONTENT
441440
)
442-
with patch("file_name_processor.uuid4", return_value="EA_bad_ts_id"):
441+
with patch("file_name_processor.uuid4", return_value="invalid_timestamp_id"):
443442
lambda_handler(self.make_event([self.make_record(invalid_timestamp_key)]), None)
444443
# Failed audit and archive
445444
item1 = self.get_audit_table_items()[0]
@@ -451,7 +450,7 @@ def test_lambda_handler_extended_attributes_invalid_timestamp(self, mock_get_red
451450
s3_client.put_object(
452451
Bucket=BucketNames.SOURCE, Key=invalid_timestamp_key2, Body=MOCK_EXTENDED_ATTRIBUTES_FILE_CONTENT
453452
)
454-
with patch("file_name_processor.uuid4", return_value="EA_bad_ts_id2"):
453+
with patch("file_name_processor.uuid4", return_value="invalid_timestamp_id2"):
455454
lambda_handler(self.make_event([self.make_record(invalid_timestamp_key2)]), None)
456455
# Failed audit and archive
457456
item2 = self.get_audit_table_items()[-1]

0 commit comments

Comments
 (0)