Skip to content

Commit 5105331

Browse files
committed
unit tests
1 parent b7ad3c7 commit 5105331

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

ack_backend/tests/utils/values_for_ack_backend_tests.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,18 @@
77
class DefaultValues:
88
"""Class to hold default values for tests"""
99

10+
fixed_datetime = datetime(2024, 10, 29, 12, 0, 0)
11+
fixed_datetime_str = fixed_datetime.strftime("%Y-%m-%d %H:%M:%S")
12+
1013
message_id = "test_file_id"
1114
row_id = "test_file_id#1"
1215
local_id = "test_system_uri^testabc"
1316
imms_id = "test_imms_id"
1417
operation_requested = "CREATE"
1518
created_at_formatted_string = "20211120T12000000"
19+
batch_start_time = fixed_datetime_str
20+
operation_start_time = fixed_datetime_str
21+
operation_end_time = fixed_datetime_str
1622

1723

1824
class DiagnosticsDictionaries:
@@ -90,6 +96,9 @@ def __init__(
9096
local_id: str = DefaultValues.local_id,
9197
imms_id: str = DefaultValues.imms_id,
9298
created_at_formatted_string: str = DefaultValues.created_at_formatted_string,
99+
batch_start_time: str = DefaultValues.batch_start_time,
100+
operation_start_time: str = DefaultValues.operation_start_time,
101+
operation_end_time: str = DefaultValues.operation_end_time,
93102
):
94103
self.name = f"{vaccine_type.upper()}/ {supplier.upper()} {operation_requested} message"
95104
self.file_key = f"{vaccine_type}_Vaccinations_v5_{ods_code}_20210730T12000000.csv"
@@ -108,6 +117,9 @@ def __init__(
108117
self.local_id = local_id
109118
self.imms_id = imms_id
110119
self.created_at_formatted_string = created_at_formatted_string
120+
self.batch_start_time= batch_start_time
121+
self.operation_start_time = operation_start_time
122+
self.operation_end_time = operation_end_time
111123

112124
self.queue_name = f"{supplier}_{vaccine_type}"
113125

@@ -116,6 +128,9 @@ def __init__(
116128
"supplier": self.supplier,
117129
"vaccine_type": self.vaccine_type,
118130
"created_at_formatted_string": self.created_at_formatted_string,
131+
"batch_start_time": self.batch_start_time,
132+
"operation_start_time": self.operation_start_time,
133+
"operation_end_time": self.operation_end_time,
119134
"row_id": self.row_id,
120135
"local_id": self.local_id,
121136
"operation_requested": self.operation_requested,
@@ -151,6 +166,9 @@ class ValidValues:
151166
mock_message_expected_log_value = {
152167
"function_name": "ack_processor_convert_message_to_ack_row",
153168
"date_time": fixed_datetime.strftime("%Y-%m-%d %H:%M:%S"),
169+
"batch_start_time": MOCK_MESSAGE_DETAILS.batch_start_time,
170+
"operation_start_time": MOCK_MESSAGE_DETAILS.operation_start_time,
171+
"operation_end_time": MOCK_MESSAGE_DETAILS.operation_end_time,
154172
"status": "success",
155173
"supplier": MOCK_MESSAGE_DETAILS.supplier,
156174
"file_key": MOCK_MESSAGE_DETAILS.file_key,
@@ -242,6 +260,9 @@ class InvalidValues:
242260
Logging_with_no_values = {
243261
"function_name": "ack_processor_convert_message_to_ack_row",
244262
"date_time": fixed_datetime.strftime("%Y-%m-%d %H:%M:%S"),
263+
"batch_start_time": "unknown",
264+
"operation_start_time": "unknown",
265+
"operation_end_time": "unknown",
245266
"status": "fail",
246267
"supplier": "unknown",
247268
"file_key": "file_key_missing",

backend/tests/test_forwarding_batch_lambda.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,9 @@ def test_forward_lambda_handler_groups_and_sends_events_by_filename(self, mock_s
455455
self.assertDictEqual(json.loads(first_call_kwargs["MessageBody"])[0], {
456456
"created_at_formatted_string": "2025-01-24T12:00:00Z",
457457
"file_key": "supplier_1_rsv_test_file",
458+
"batch_start_time": ANY,
459+
"operation_start_time": ANY,
460+
"operation_end_time": ANY,
458461
"imms_id": ANY,
459462
"local_id": "local-1",
460463
"operation_requested": "CREATE",
@@ -465,6 +468,9 @@ def test_forward_lambda_handler_groups_and_sends_events_by_filename(self, mock_s
465468
self.assertDictEqual(json.loads(second_call_kwargs["MessageBody"])[0], {
466469
"created_at_formatted_string": "2025-01-24T12:00:00Z",
467470
"file_key": "supplier_2_rsv_test_file",
471+
"batch_start_time": ANY,
472+
"operation_start_time": ANY,
473+
"operation_end_time": ANY,
468474
"imms_id": ANY,
469475
"local_id": "local-2",
470476
"operation_requested": "CREATE",

0 commit comments

Comments
 (0)