@@ -65,8 +65,8 @@ def test_set_records_succeeded_count(self):
6565 self .mock_dynamodb_client .update_item .assert_called_once_with (
6666 TableName = AUDIT_TABLE_NAME ,
6767 Key = {AuditTableKeys .MESSAGE_ID : {"S" : test_message_id }},
68- UpdateExpression = "SET #counter = :value" ,
69- ExpressionAttributeNames = {"#counter " : AuditTableKeys .RECORDS_SUCCEEDED },
68+ UpdateExpression = "SET #attribute = :value" ,
69+ ExpressionAttributeNames = {"#attribute " : AuditTableKeys .RECORDS_SUCCEEDED },
7070 ExpressionAttributeValues = {":value" : {"N" : "958" }},
7171 ConditionExpression = "attribute_exists(message_id)" ,
7272 ReturnValues = "UPDATED_NEW" ,
@@ -83,8 +83,8 @@ def test_set_records_succeeded_count_no_failures(self):
8383 self .mock_dynamodb_client .update_item .assert_called_once_with (
8484 TableName = AUDIT_TABLE_NAME ,
8585 Key = {AuditTableKeys .MESSAGE_ID : {"S" : test_message_id }},
86- UpdateExpression = "SET #counter = :value" ,
87- ExpressionAttributeNames = {"#counter " : AuditTableKeys .RECORDS_SUCCEEDED },
86+ UpdateExpression = "SET #attribute = :value" ,
87+ ExpressionAttributeNames = {"#attribute " : AuditTableKeys .RECORDS_SUCCEEDED },
8888 ExpressionAttributeValues = {":value" : {"N" : "1000" }},
8989 ConditionExpression = "attribute_exists(message_id)" ,
9090 ReturnValues = "UPDATED_NEW" ,
@@ -99,8 +99,8 @@ def test_set_records_succeeded_count_no_records(self):
9999 self .mock_dynamodb_client .update_item .assert_called_once_with (
100100 TableName = AUDIT_TABLE_NAME ,
101101 Key = {AuditTableKeys .MESSAGE_ID : {"S" : test_message_id }},
102- UpdateExpression = "SET #counter = :value" ,
103- ExpressionAttributeNames = {"#counter " : AuditTableKeys .RECORDS_SUCCEEDED },
102+ UpdateExpression = "SET #attribute = :value" ,
103+ ExpressionAttributeNames = {"#attribute " : AuditTableKeys .RECORDS_SUCCEEDED },
104104 ExpressionAttributeValues = {":value" : {"N" : "0" }},
105105 ConditionExpression = "attribute_exists(message_id)" ,
106106 ReturnValues = "UPDATED_NEW" ,
@@ -121,13 +121,12 @@ def test_increment_records_failed_count(self):
121121 self .mock_dynamodb_client .update_item .assert_called_once_with (
122122 TableName = AUDIT_TABLE_NAME ,
123123 Key = {AuditTableKeys .MESSAGE_ID : {"S" : test_message_id }},
124- UpdateExpression = "SET #counter = if_not_exists(#counter , :initial) + :increment" ,
125- ExpressionAttributeNames = {"#counter " : AuditTableKeys .RECORDS_FAILED },
124+ UpdateExpression = "SET #attribute = if_not_exists(#attribute , :initial) + :increment" ,
125+ ExpressionAttributeNames = {"#attribute " : AuditTableKeys .RECORDS_FAILED },
126126 ExpressionAttributeValues = {":increment" : {"N" : "1" }, ":initial" : {"N" : "0" }},
127127 ConditionExpression = "attribute_exists(message_id)" ,
128128 ReturnValues = "UPDATED_NEW" ,
129129 )
130- self .mock_logger .info .assert_called_once ()
131130
132131 def test_increment_records_failed_count_raises (self ):
133132 self .mock_dynamodb_client .update_item .side_effect = Exception ("fail!" )
@@ -136,29 +135,29 @@ def test_increment_records_failed_count_raises(self):
136135 self .assertIn ("fail!" , str (ctx .exception ))
137136 self .mock_logger .error .assert_called_once ()
138137
139- def test_set_audit_table_ingestion_complete (self ):
140- """Checks audit table correctly sets ingestion_complete to the requested value"""
138+ def test_set_audit_table_ingestion_end_time (self ):
139+ """Checks audit table correctly sets ingestion_end_time to the requested value"""
141140 test_file_key = "RSV_Vaccinations_v5_X26_20210730T12000000.csv"
142141 test_message_id = "1234"
143- test_start_time = 1627647000
144- audit_table .set_audit_table_ingestion_complete (test_file_key , test_message_id , test_start_time )
142+ test_end_time = 1627647000
143+ audit_table .set_audit_table_ingestion_end_time (test_file_key , test_message_id , test_end_time )
145144 self .mock_dynamodb_client .update_item .assert_called_once_with (
146145 TableName = AUDIT_TABLE_NAME ,
147146 Key = {AuditTableKeys .MESSAGE_ID : {"S" : test_message_id }},
148- UpdateExpression = f"SET #{ AuditTableKeys .INGESTION_COMPLETE } = :{ AuditTableKeys .INGESTION_COMPLETE } " ,
149- ExpressionAttributeNames = {f"#{ AuditTableKeys .INGESTION_COMPLETE } " : AuditTableKeys .INGESTION_COMPLETE },
150- ExpressionAttributeValues = {f":{ AuditTableKeys .INGESTION_COMPLETE } " : {"S" : "20210730T12100000" }},
147+ UpdateExpression = f"SET #{ AuditTableKeys .INGESTION_END_TIME } = :{ AuditTableKeys .INGESTION_END_TIME } " ,
148+ ExpressionAttributeNames = {f"#{ AuditTableKeys .INGESTION_END_TIME } " : AuditTableKeys .INGESTION_END_TIME },
149+ ExpressionAttributeValues = {f":{ AuditTableKeys .INGESTION_END_TIME } " : {"S" : "20210730T12100000" }},
151150 ConditionExpression = "attribute_exists(message_id)" ,
152151 ReturnValues = "UPDATED_NEW" ,
153152 )
154153 self .mock_logger .info .assert_called_once ()
155154
156- def test_set_audit_table_ingestion_complete_throws_exception_with_invalid_id (self ):
155+ def test_set_audit_table_ingestion_end_time_throws_exception_with_invalid_id (self ):
157156 test_file_key = "RSV_Vaccinations_v5_X26_20210730T12000000.csv"
158157 test_message_id = "1234"
159- test_start_time = 1627647000
158+ test_end_time = 1627647000
160159 self .mock_dynamodb_client .update_item .side_effect = Exception ("fail!" )
161160 with self .assertRaises (UnhandledAuditTableError ) as ctx :
162- audit_table .set_audit_table_ingestion_complete (test_file_key , test_message_id , test_start_time )
161+ audit_table .set_audit_table_ingestion_end_time (test_file_key , test_message_id , test_end_time )
163162 self .assertIn ("fail!" , str (ctx .exception ))
164163 self .mock_logger .error .assert_called_once ()
0 commit comments