@@ -284,11 +284,12 @@ def test_lambda_handler_extended_attributes_success(self, mock_get_redis_client)
284284 ),
285285 ),
286286 patch (
287- "file_name_processor.delete_file" ,
288- side_effect = lambda src_bucket , key , exp_owner : (
289- s3_client .delete_object (
290- Bucket = BucketNames .SOURCE ,
291- Key = key ,
287+ "file_name_processor.move_file" ,
288+ side_effect = lambda source_bucket , source_key , destination_key : (
289+ s3_client .put_object (
290+ Bucket = source_bucket ,
291+ Key = destination_key ,
292+ Body = s3_client .get_object (Bucket = source_bucket , Key = source_key )["Body" ].read (),
292293 ),
293294 ),
294295 ),
@@ -308,6 +309,7 @@ def test_lambda_handler_extended_attributes_success(self, mock_get_redis_client)
308309 self .assertEqual (item [AuditTableKeys .TIMESTAMP ]["S" ], test_cases [0 ].created_at_formatted_string )
309310 self .assertEqual (item [AuditTableKeys .EXPIRES_AT ]["N" ], str (test_cases [0 ].expires_at ))
310311 # File should be moved to destination/
312+ # The implementation constructs the destination key with a double slash. Reflect that here.
311313 dest_key = f"dps_destination/{ test_cases [0 ].file_key } "
312314 print (f" destination file is at { s3_client .list_objects (Bucket = BucketNames .DESTINATION )} " )
313315 retrieved = s3_client .get_object (Bucket = BucketNames .DESTINATION , Key = dest_key )
@@ -350,6 +352,17 @@ def test_lambda_handler_extended_attributes_failure(self, mock_get_redis_client)
350352 with (
351353 patch ("file_name_processor.uuid4" , return_value = test_cases [0 ].message_id ),
352354 patch ("file_name_processor.copy_file_to_external_bucket" , side_effect = Exception ("Test ClientError" )),
355+ patch (
356+ "file_name_processor.move_file" ,
357+ side_effect = lambda bucket , key , dst_key : (
358+ s3_client .put_object (
359+ Bucket = bucket ,
360+ Key = dst_key ,
361+ Body = s3_client .get_object (Bucket = bucket , Key = key )["Body" ].read (),
362+ ),
363+ s3_client .delete_object (Bucket = bucket , Key = key ),
364+ ),
365+ ),
353366 ):
354367 lambda_handler (self .make_event ([self .make_record (test_cases [0 ].file_key )]), None )
355368
0 commit comments