Skip to content

Commit c0b4792

Browse files
committed
unrefactored
1 parent 93a647a commit c0b4792

File tree

2 files changed

+17
-31
lines changed

2 files changed

+17
-31
lines changed

ack_backend/src/update_ack_file.py

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -66,25 +66,6 @@ def obtain_current_ack_content(temp_ack_file_key: str) -> StringIO:
6666
return accumulated_csv_content
6767

6868

69-
def handle_ingestion_complete(
70-
temp_ack_file_key: str,
71-
message_id: str,
72-
supplier: str,
73-
vaccine_type: str,
74-
archive_ack_file_key: str,
75-
file_key: str,
76-
) -> None:
77-
"""Handles processing where the complete file has been ingested"""
78-
move_file(ACK_BUCKET_NAME, temp_ack_file_key, archive_ack_file_key)
79-
move_file(SOURCE_BUCKET_NAME, f"processing/{file_key}", f"archive/{file_key}")
80-
# Update the audit table and invoke the filename lambda with next file in the queue (if one exists)
81-
change_audit_table_status_to_processed(file_key, message_id)
82-
supplier_queue = f"{supplier}_{vaccine_type}"
83-
next_queued_file_details = get_next_queued_file_details(supplier_queue)
84-
if next_queued_file_details:
85-
invoke_filename_lambda(next_queued_file_details["filename"], next_queued_file_details["message_id"])
86-
87-
8869
@upload_ack_file_logging_decorator
8970
def upload_ack_file(
9071
temp_ack_file_key: str,
@@ -108,14 +89,14 @@ def upload_ack_file(
10889
row_count_destination = get_row_count(ACK_BUCKET_NAME, temp_ack_file_key)
10990
# TODO: Should we check for > and if so what handling is required
11091
if row_count_destination == row_count_source:
111-
handle_ingestion_complete(
112-
temp_ack_file_key,
113-
message_id,
114-
supplier,
115-
vaccine_type,
116-
archive_ack_file_key,
117-
file_key,
118-
)
92+
move_file(ACK_BUCKET_NAME, temp_ack_file_key, archive_ack_file_key)
93+
move_file(SOURCE_BUCKET_NAME, f"processing/{file_key}", f"archive/{file_key}")
94+
# Update the audit table and invoke the filename lambda with next file in the queue (if one exists)
95+
change_audit_table_status_to_processed(file_key, message_id)
96+
supplier_queue = f"{supplier}_{vaccine_type}"
97+
next_queued_file_details = get_next_queued_file_details(supplier_queue)
98+
if next_queued_file_details:
99+
invoke_filename_lambda(next_queued_file_details["filename"], next_queued_file_details["message_id"])
119100
# Ingestion of this file is complete
120101
result = {
121102
"message_id": message_id,

ack_backend/tests/test_splunk_logging.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,9 @@ def test_splunk_update_ack_file_not_logged(self):
325325
with (
326326
patch("logging_decorators.send_log_to_firehose") as mock_send_log_to_firehose,
327327
patch("logging_decorators.logger") as mock_logger,
328-
patch("update_ack_file.handle_ingestion_complete") as mock_handle_ingestion_complete, # noqa: E999
328+
patch("update_ack_file.change_audit_table_status_to_processed") as mock_change_audit_table_status_to_processed, # noqa: E999
329+
patch("update_ack_file.get_next_queued_file_details"), # noqa: E999
330+
patch("update_ack_file.invoke_filename_lambda"), # noqa: E999
329331
):
330332
result = lambda_handler(generate_event(messages), context={})
331333

@@ -350,7 +352,8 @@ def test_splunk_update_ack_file_not_logged(self):
350352
call(last_logger_info_call_args),
351353
]
352354
)
353-
mock_handle_ingestion_complete.assert_not_called()
355+
mock_change_audit_table_status_to_processed.assert_not_called()
356+
354357

355358
def test_splunk_update_ack_file_logged(self):
356359
"""Tests that update_ack_file is logged if we have sent acks for the whole file"""
@@ -363,7 +366,9 @@ def test_splunk_update_ack_file_logged(self):
363366
with (
364367
patch("logging_decorators.send_log_to_firehose") as mock_send_log_to_firehose,
365368
patch("logging_decorators.logger") as mock_logger,
366-
patch("update_ack_file.handle_ingestion_complete") as mock_handle_ingestion_complete, # noqa: E999
369+
patch("update_ack_file.change_audit_table_status_to_processed") as mock_change_audit_table_status_to_processed, # noqa: E999
370+
patch("update_ack_file.get_next_queued_file_details"), # noqa: E999
371+
patch("update_ack_file.invoke_filename_lambda"), # noqa: E999
367372
):
368373
result = lambda_handler(generate_event(messages), context={})
369374

@@ -395,7 +400,7 @@ def test_splunk_update_ack_file_logged(self):
395400
call(last_logger_info_call_args),
396401
]
397402
)
398-
mock_handle_ingestion_complete.assert_called()
403+
mock_change_audit_table_status_to_processed.assert_called()
399404

400405

401406
if __name__ == "__main__":

0 commit comments

Comments
 (0)