Skip to content

Commit 066df5b

Browse files
authored
VED-1084: Allow additional extended attributes file versions. (#1243)
* VED-1084: Allow additional extended attributes file version. * VED-1084: Allow major version 1 and any numeric minor version.
1 parent 951a67c commit 066df5b

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

lambdas/filenameprocessor/src/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
DPS_DESTINATION_PREFIX = "generic/EXTENDED_ATTRIBUTES_DAILY_1"
2525
EXTENDED_ATTRIBUTES_ARCHIVE_PREFIX = "extended-attributes-archive"
26-
VALID_EA_VERSIONS = ["V1_5"]
26+
VALID_EA_MAJOR_VERSIONS = ["V1"]
2727
ERROR_TYPE_TO_STATUS_CODE_MAP = {
2828
VaccineTypePermissionsError: 403,
2929
InvalidFileKeyError: 400, # Includes invalid ODS code, therefore unable to identify supplier

lambdas/filenameprocessor/src/file_validation.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from constants import (
77
EXTENDED_ATTRIBUTES_FILE_PREFIX,
88
EXTENDED_ATTRIBUTES_VACC_TYPE,
9-
VALID_EA_VERSIONS,
9+
VALID_EA_MAJOR_VERSIONS,
1010
VALID_TIMESTAMP_LENGTH,
1111
VALID_TIMEZONE_OFFSETS,
1212
VALID_VERSIONS,
@@ -66,7 +66,8 @@ def validate_extended_attributes_file_key(file_key: str) -> tuple[str, str]:
6666

6767
file_key_parts_without_extension, extension = split_file_key(file_key)
6868
file_type = "_".join(file_key_parts_without_extension[:3])
69-
version = "_".join(file_key_parts_without_extension[3:5])
69+
major_version = file_key_parts_without_extension[3]
70+
minor_version = file_key_parts_without_extension[4]
7071
organization_code = file_key_parts_without_extension[5]
7172
timestamp = file_key_parts_without_extension[6]
7273
supplier = get_supplier_system_from_cache(organization_code)
@@ -76,7 +77,8 @@ def validate_extended_attributes_file_key(file_key: str) -> tuple[str, str]:
7677
if not (
7778
vaccine_type in valid_vaccine_types
7879
and file_type == EXTENDED_ATTRIBUTES_FILE_PREFIX.upper()
79-
and version in VALID_EA_VERSIONS
80+
and major_version in VALID_EA_MAJOR_VERSIONS
81+
and minor_version.isdigit()
8082
and supplier # Note that if supplier could be identified, this also implies that ODS code is valid
8183
and is_valid_datetime(timestamp)
8284
and (

lambdas/filenameprocessor/tests/test_file_key_validation.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ def test_validate_extended_attributes_file_key(self, mock_get_redis_client):
129129
"Vaccination_Extended_Attributes_v1_5_YGM41_20221231T23595900.csv",
130130
"YGM41",
131131
),
132+
# Valid extended attributes file key with version v1_4
133+
(
134+
"Vaccination_Extended_Attributes_v1_4_X8E5B_20000101T00000001.csv",
135+
"X8E5B",
136+
),
132137
]
133138

134139
for file_key, expected_result in test_cases_for_success_scenarios:

0 commit comments

Comments
 (0)