|
7 | 7 |
|
8 | 8 | from tests.utils_for_recordprocessor_tests.mock_environment_variables import MOCK_ENVIRONMENT_DICT |
9 | 9 | from tests.utils_for_recordprocessor_tests.generic_setup_and_teardown import GenericSetUp, GenericTearDown |
10 | | -from tests.utils_for_recordprocessor_tests.values_for_recordprocessor_tests import MockFileDetails, FileDetails |
| 10 | +from tests.utils_for_recordprocessor_tests.values_for_recordprocessor_tests import MockFileDetails |
11 | 11 | from tests.utils_for_recordprocessor_tests.utils_for_recordprocessor_tests import ( |
12 | 12 | deserialize_dynamodb_types, |
13 | 13 | add_entry_to_table, |
14 | | - assert_audit_table_entry, |
15 | 14 | ) |
16 | 15 |
|
17 | 16 | # Ensure environment variables are mocked before importing from src files |
18 | 17 | with patch.dict("os.environ", MOCK_ENVIRONMENT_DICT): |
19 | 18 | from constants import ( |
20 | 19 | AUDIT_TABLE_NAME, |
21 | | - AuditTableKeys, |
22 | 20 | FileStatus, |
23 | 21 | ) |
24 | 22 |
|
25 | 23 | from audit_table import get_next_queued_file_details, change_audit_table_status_to_processed |
26 | | - from errors import UnhandledAuditTableError |
27 | 24 | from clients import REGION_NAME |
28 | 25 |
|
29 | 26 | dynamodb_client = boto3_client("dynamodb", region_name=REGION_NAME) |
@@ -77,35 +74,18 @@ def test_get_next_queued_file_details(self): |
77 | 74 | self.assertEqual(get_next_queued_file_details(queue_to_check), deserialize_dynamodb_types(expected_table_entry)) |
78 | 75 |
|
79 | 76 | def test_change_audit_table_status_to_processed(self): |
80 | | - # Checks audit table is updated correctly |
81 | | - queue_to_check = "RAVS_RSV" |
| 77 | + """Checks audit table correctly updates a record as processed""" |
82 | 78 |
|
83 | 79 | add_entry_to_table(MockFileDetails.rsv_ravs, file_status=FileStatus.QUEUED) |
| 80 | + add_entry_to_table(MockFileDetails.flu_emis, file_status=FileStatus.QUEUED) |
84 | 81 | table_items = dynamodb_client.scan(TableName=AUDIT_TABLE_NAME).get("Items", []) |
85 | | - # print(f"started off queued:{table_items}") |
86 | 82 |
|
87 | 83 | expected_table_entry = {**MockFileDetails.rsv_ravs.audit_table_entry, "status": {"S": FileStatus.PROCESSED}} |
| 84 | + |
88 | 85 | file_key = "RSV_Vaccinations_v5_X26_20210730T12000000.csv" |
89 | 86 | message_id = "rsv_ravs_test_id_1" |
90 | | - # print(f"file_key_checker: {file_key}") |
91 | | - # print(f"message_id: {message_id}") |
92 | | - result = change_audit_table_status_to_processed(file_key, message_id) |
93 | | - print(result) |
| 87 | + |
| 88 | + change_audit_table_status_to_processed(file_key, message_id) |
94 | 89 | table_items = dynamodb_client.scan(TableName=AUDIT_TABLE_NAME).get("Items", []) |
95 | | - # print(f"change to processed :{table_items}") |
96 | | - |
97 | | - Actual_result = [ |
98 | | - { |
99 | | - "message_id": {"S": "rsv_ravs_test_id_1"}, |
100 | | - "filename": {"S": "RSV_Vaccinations_v5_X26_20210730T12000000.csv"}, |
101 | | - "queue_name": {"S": "RAVS_RSV"}, |
102 | | - "timestamp": {"S": "20211120T12000000"}, |
103 | | - "status": {"S": "Processed"}, |
104 | | - } |
105 | | - ] |
106 | | - Actual_logger = "The status of RSV_Vaccinations_v5_X26_20210730T12000000.csv file, with message id rsv_ravs_test_id_1, was successfully updated to Processed in the audit table" |
107 | | - # self.assertEqual(result, deserialize_dynamodb_types(expected_table_entry)) |
108 | | - |
109 | | - # Check items in the dynamo table |
110 | | - # table_items = dynamodb_client.scan(TableName=AUDIT_TABLE_NAME).get("Items", []) |
111 | | - # print(f"table items 4 :{table_items}") |
| 90 | + |
| 91 | + self.assertIn(expected_table_entry, table_items) |
0 commit comments