@@ -433,6 +433,63 @@ def test_complete_batch_file_process_json_ack_file(self):
433433 )
434434 self .assertEqual (result , ValidValues .json_ack_complete_content )
435435
436+ def test_complete_batch_file_process_with_dat_extension (self ):
437+ """Test that complete_batch_file_process correctly handles files with .dat extension."""
438+ file_key_with_dat = "flu_Vaccinations_v5_YGA_20210730T12000000.dat"
439+ created_at_formatted_string = "20211120T12000000"
440+ expected_csv_ack_file_key = (
441+ f"forwardedFile/flu_Vaccinations_v5_YGA_20210730T12000000_BusAck_{ created_at_formatted_string } .csv"
442+ )
443+ expected_json_ack_file_key = (
444+ f"forwardedFile/flu_Vaccinations_v5_YGA_20210730T12000000_BusAck_{ created_at_formatted_string } .json"
445+ )
446+
447+ generate_sample_existing_json_ack_content ()
448+ self .s3_client .put_object (
449+ Bucket = BucketNames .SOURCE ,
450+ Key = f"processing/{ file_key_with_dat } " ,
451+ Body = "dummy content" ,
452+ )
453+
454+ update_csv_ack_file (
455+ file_key = file_key_with_dat ,
456+ created_at_formatted_string = created_at_formatted_string ,
457+ ack_data_rows = [ValidValues .ack_data_failure_dict ],
458+ )
459+ update_json_ack_file (
460+ message_id = MOCK_MESSAGE_DETAILS .message_id ,
461+ supplier = MOCK_MESSAGE_DETAILS .supplier ,
462+ file_key = file_key_with_dat ,
463+ created_at_formatted_string = created_at_formatted_string ,
464+ ack_data_rows = [ValidValues .ack_data_failure_dict ],
465+ )
466+
467+ self .mock_get_record_and_failure_count .return_value = 10 , 1
468+
469+ complete_batch_file_process (
470+ message_id = MOCK_MESSAGE_DETAILS .message_id ,
471+ supplier = MOCK_MESSAGE_DETAILS .supplier ,
472+ vaccine_type = MOCK_MESSAGE_DETAILS .vaccine_type ,
473+ created_at_formatted_string = created_at_formatted_string ,
474+ file_key = file_key_with_dat ,
475+ )
476+
477+ # Verify CSV ACK file was created with .csv extension
478+ try :
479+ self .s3_client .head_object (Bucket = BucketNames .DESTINATION , Key = expected_csv_ack_file_key )
480+ csv_ack_exists = True
481+ except Exception :
482+ csv_ack_exists = False
483+ self .assertTrue (csv_ack_exists , f"Expected CSV ACK file at { expected_csv_ack_file_key } " )
484+
485+ # Verify JSON ACK file was created with .json extension (not .dat.json)
486+ try :
487+ self .s3_client .head_object (Bucket = BucketNames .DESTINATION , Key = expected_json_ack_file_key )
488+ json_ack_exists = True
489+ except Exception :
490+ json_ack_exists = False
491+ self .assertTrue (json_ack_exists , f"Expected JSON ACK file at { expected_json_ack_file_key } " )
492+
436493 def test_update_json_ack_file_with_empty_ack_data_rows (self ):
437494 """Test that update_json_ack_file correctly updates the ack file when given an empty list"""
438495 # Mock existing content in the ack file
0 commit comments