2222 FILE_NAME_VAL_ERROR ,
2323 HEADER_RESPONSE_CODE_COLUMN ,
2424 RAVS_URI ,
25+ ActionFlag ,
2526)
2627
2728
@@ -59,7 +60,7 @@ def delete_file_from_s3(bucket, key):
5960 if status_code != 204 :
6061 raise Exception (f"Delete failed with status code: { status_code } " )
6162
62- print (f"Deleted { key } from bucket { bucket } " )
63+ print (f"Deleted { key } " )
6364 return True
6465
6566 except ClientError as e :
@@ -136,23 +137,23 @@ def check_ack_file_content(desc, content, response_code, operation_outcome, oper
136137
137138 if operation_outcome and DUPLICATE in operation_outcome :
138139 # Handle DUPLICATE scenario:
139- assert len (rows ) == 2 , f"Expected 2 rows for DUPLICATE scenario, got { len (rows )} "
140+ assert len (rows ) == 2 , f"{ desc } . Expected 2 rows for DUPLICATE scenario, got { len (rows )} "
140141
141142 first_row = rows [0 ]
142- validate_header_response_code (first_row , 0 , "OK" )
143+ validate_header_response_code (desc , first_row , 0 , "OK" )
143144 validate_ok_response (first_row , 0 , operation_requested )
144145
145146 second_row = rows [1 ]
146- validate_header_response_code (second_row , 1 , "Fatal Error" )
147- validate_fatal_error (second_row , 1 , DUPLICATE )
147+ validate_header_response_code (desc , second_row , 1 , "Fatal Error" )
148+ validate_fatal_error (desc , second_row , 1 , DUPLICATE )
148149 else :
149150 # Handle normal scenarios:
150151 for i , row in enumerate (rows ):
151152 if response_code and "HEADER_RESPONSE_CODE" in row :
152- assert row ["HEADER_RESPONSE_CODE" ].strip () == response_code , (
153- f"Row { i } expected HEADER_RESPONSE_CODE ' { response_code } ', "
154- f"but got ' { row [ ' HEADER_RESPONSE_CODE' ]. strip () } ' "
155- )
153+ row_HEADER_RESPONSE_CODE = row ["HEADER_RESPONSE_CODE" ].strip ()
154+ assert row_HEADER_RESPONSE_CODE == response_code , (
155+ f"{ desc } .Row { i } expected HEADER_RESPONSE_CODE ' { response_code } ', "
156+ f"but got ' { row_HEADER_RESPONSE_CODE } '" )
156157 if operation_outcome and "OPERATION_OUTCOME" in row :
157158 assert row ["OPERATION_OUTCOME" ].strip () == operation_outcome , (
158159 f"Row { i } expected OPERATION_OUTCOME '{ operation_outcome } ', "
@@ -164,7 +165,7 @@ def check_ack_file_content(desc, content, response_code, operation_outcome, oper
164165 validate_fatal_error (row , i , operation_outcome )
165166
166167
167- def validate_header_response_code (row , index , expected_code ):
168+ def validate_header_response_code (desc , row , index , expected_code ):
168169 """Ensure HEADER_RESPONSE_CODE exists and matches expected response code."""
169170
170171 if "HEADER_RESPONSE_CODE" not in row :
@@ -277,12 +278,13 @@ def fetch_pk_and_operation_from_dynamodb(identifier_pk):
277278 KeyConditionExpression = "IdentifierPK = :identifier_pk" ,
278279 ExpressionAttributeValues = {":identifier_pk" : identifier_pk },
279280 )
280- if "Items" in response and response ["Items" ] and "DeletedAt" in response ["Items" ][0 ]:
281- return (response ["Items" ][0 ]["PK" ], response ["Items" ][0 ]["Operation" ], response ["Items" ][0 ]["DeletedAt" ])
282- if "Items" in response and response ["Items" ]:
283- return (response ["Items" ][0 ]["PK" ], response ["Items" ][0 ]["Operation" ], None )
284- else :
285- return "NOT_FOUND"
281+ if "Items" in response :
282+ items = response ["Items" ]
283+ if items :
284+ if "DeletedAt" in items [0 ]:
285+ return (items [0 ]["PK" ], items [0 ]["Operation" ], items [0 ]["DeletedAt" ])
286+ return (items [0 ]["PK" ], items [0 ]["Operation" ], None )
287+ return (identifier_pk , ActionFlag .NONE , None )
286288
287289 except Exception as e :
288290 logger .error (f"Error fetching from DynamoDB: { e } " )
0 commit comments