|
1 | | -import unittest |
2 | | -from unittest.mock import patch, MagicMock, call |
| 1 | +from unittest.mock import patch |
3 | 2 | from io import StringIO |
4 | 3 |
|
5 | 4 | import update_ack_file |
6 | | -from update_ack_file import invoke_filename_lambda |
7 | 5 | import unittest |
8 | 6 | import boto3 |
9 | 7 |
|
@@ -42,22 +40,10 @@ def setUp(self): |
42 | 40 | self.change_audit_status_patcher = patch('update_ack_file.change_audit_table_status_to_processed') |
43 | 41 | self.mock_change_audit_status = self.change_audit_status_patcher.start() |
44 | 42 |
|
45 | | - self.get_next_queued_file_details_patcher = patch('update_ack_file.get_next_queued_file_details') |
46 | | - self.mock_get_next_queued_file_details = self.get_next_queued_file_details_patcher.start() |
47 | | - |
48 | | - self.invoke_filename_lambda_patcher = patch('update_ack_file.invoke_filename_lambda') |
49 | | - self.mock_invoke_filename_lambda = self.invoke_filename_lambda_patcher.start() |
50 | | - |
51 | | - self.lambda_client_patcher = patch('update_ack_file.lambda_client') |
52 | | - self.mock_lambda_client = self.lambda_client_patcher.start() |
53 | | - |
54 | 43 | def tearDown(self): |
55 | 44 | self.logger_patcher.stop() |
56 | 45 | self.get_row_count_patcher.stop() |
57 | 46 | self.change_audit_status_patcher.stop() |
58 | | - self.get_next_queued_file_details_patcher.stop() |
59 | | - self.invoke_filename_lambda_patcher.stop() |
60 | | - self.lambda_client_patcher.stop() |
61 | 47 |
|
62 | 48 | def test_audit_table_updated_correctly(self): |
63 | 49 | """ VED-167 - Test that the audit table has been updated correctly""" |
@@ -116,39 +102,3 @@ def test_move_file(self): |
116 | 102 |
|
117 | 103 | # Logger assertion (if logger is mocked) |
118 | 104 | self.mock_logger.info.assert_called_with("File moved from %s to %s", file_key, dest_key) |
119 | | - |
120 | | - def test_next_queued_file_triggers_lambda(self): |
121 | | - """ VED-167 Test that the next queued file details are used to re-invoke the lambda.""" |
122 | | - # Setup |
123 | | - self.mock_get_row_count.side_effect = [3, 3] |
124 | | - next_file = "next_for_lambda.csv" |
125 | | - next_message_id = "msg-next-lambda" |
126 | | - supplier = "lambda-trigger-supplier" |
127 | | - vaccine_type = "vaccine-type" |
128 | | - queue_name = f"{supplier}_{vaccine_type}" |
129 | | - self.mock_get_next_queued_file_details.return_value = {"filename": next_file, "message_id": next_message_id} |
130 | | - accumulated_csv_content = StringIO("header1|header2\n") |
131 | | - ack_data_rows = [ |
132 | | - {"a": 1, "b": 2, "row": "lambda1"}, |
133 | | - {"a": 3, "b": 4, "row": "lambda2"}, |
134 | | - {"a": 5, "b": 6, "row": "lambda3"} |
135 | | - ] |
136 | | - next_key="next_lambda_test.csv" |
137 | | - self.s3_client.put_object( |
138 | | - Bucket=self.source_bucket_name, |
139 | | - Key=f"processing/{next_key}", |
140 | | - Body="dummy content" |
141 | | - ) |
142 | | - # Act |
143 | | - update_ack_file.upload_ack_file( |
144 | | - temp_ack_file_key=f"TempAck/{next_key}", |
145 | | - message_id="msg-lambda-trigger", |
146 | | - supplier=supplier, |
147 | | - vaccine_type=vaccine_type, |
148 | | - accumulated_csv_content=accumulated_csv_content, |
149 | | - ack_data_rows=ack_data_rows, |
150 | | - archive_ack_file_key=f"forwardedFile/{next_key}", |
151 | | - file_key=next_key |
152 | | - ) |
153 | | - # Assert: Check that the next queued file was used to re-invoke the lambda |
154 | | - self.mock_get_next_queued_file_details.assert_called_once_with(queue_name) |
0 commit comments