2929 validate_json_bus_ack_file_failure_records ,
3030 validate_json_bus_ack_file_structure_and_metadata ,
3131)
32- from utilities .batch_S3_buckets import upload_file_to_S3 , wait_and_read_ack_file , wait_for_file_to_move_archive
32+ from utilities .batch_S3_buckets import (
33+ upload_file_to_S3 ,
34+ wait_and_read_ack_file ,
35+ wait_for_file_to_move_archive ,
36+ )
3337from utilities .enums import ActionFlag , ActionMap , Operation
3438
3539
@@ -86,6 +90,13 @@ def valid_batch_file_is_created_with_details(datatable, context):
8690 create_batch_file (context )
8791
8892
93+ @given ("batch file is created for below data as full dataset with file extension dat" )
94+ @ignore_if_local_run
95+ def valid_batch_file_is_created_with_details_and_dat_extension (datatable , context ):
96+ build_dataFrame_using_datatable (datatable , context )
97+ create_batch_file (context , file_ext = "dat" )
98+
99+
89100@when ("same batch file is uploaded again in s3 bucket" )
90101@when ("batch file is uploaded in s3 bucket" )
91102@ignore_local_run_set_test_data
@@ -140,7 +151,9 @@ def json_bus_ack_will_only_contain_file_metadata_and_no_record_entries(context):
140151
141152
142153@then ("Json bus ack will only contain file metadata and correct failure record entries" )
143- def json_bus_ack_will_only_contain_file_metadata_and_correct_failure_record_entries (context ):
154+ def json_bus_ack_will_only_contain_file_metadata_and_correct_failure_record_entries (
155+ context ,
156+ ):
144157 json_content = context .fileContentJson
145158 assert json_content is not None , "BUS Ack JSON content is None"
146159 validate_json_bus_ack_file_structure_and_metadata (context )
@@ -225,7 +238,11 @@ def validate_imms_event_table_for_all_records_in_batch_file(context, operation:
225238 ("Operation" , Operation [operation ].value , item .get ("Operation" )),
226239 ("SupplierSystem" , context .supplier_name , item .get ("SupplierSystem" )),
227240 ("PatientPK" , f"Patient#{ nhs_number } " , item .get ("PatientPK" )),
228- ("PatientSK" , f"{ context .vaccine_type .upper ()} #{ context .ImmsID } " , item .get ("PatientSK" )),
241+ (
242+ "PatientSK" ,
243+ f"{ context .vaccine_type .upper ()} #{ context .ImmsID } " ,
244+ item .get ("PatientSK" ),
245+ ),
229246 ("Version" , int (context .expected_version ), int (item .get ("Version" ))),
230247 ]
231248
@@ -269,7 +286,13 @@ def build_dataFrame_using_datatable(datatable, context):
269286 headers = datatable [0 ]
270287 rows = datatable [1 :]
271288
272- table_list = [(row [headers .index ("patient_id" )], f"{ row [headers .index ('unique_id' )]} -{ timestamp } " ) for row in rows ]
289+ table_list = [
290+ (
291+ row [headers .index ("patient_id" )],
292+ f"{ row [headers .index ('unique_id' )]} -{ timestamp } " ,
293+ )
294+ for row in rows
295+ ]
273296 records = []
274297 for patient_id , unique_id in table_list :
275298 context .patient_id = patient_id
@@ -315,7 +338,8 @@ def validate_imms_delta_table_for_newly_created_records_in_batch_file(context):
315338 create_items = [i for i in delta_items if i .get ("Operation" ) == "CREATE" ]
316339
317340 check .is_true (
318- len (create_items ) == 1 , f"Expected exactly 1 CREATE record for IMMS_ID { clean_id } , found { len (create_items )} "
341+ len (create_items ) == 1 ,
342+ f"Expected exactly 1 CREATE record for IMMS_ID { clean_id } , found { len (create_items )} " ,
319343 )
320344
321345 create_item = create_items [0 ]
@@ -324,7 +348,11 @@ def validate_imms_delta_table_for_newly_created_records_in_batch_file(context):
324348 batch_record = {k : normalize (v ) for k , v in row .to_dict ().items ()}
325349
326350 validate_imms_delta_record_with_batch_record (
327- context , batch_record , create_item , Operation .created .value , ActionFlag .created .value
351+ context ,
352+ batch_record ,
353+ create_item ,
354+ Operation .created .value ,
355+ ActionFlag .created .value ,
328356 )
329357
330358
@@ -341,7 +369,11 @@ def validate_imms_delta_table_for_updated_records_in_batch_file(context):
341369 item = update_items .pop (updated_index )
342370
343371 validate_imms_delta_record_with_batch_record (
344- context , batch_record , item , Operation .updated .value , ActionFlag .updated .value
372+ context ,
373+ batch_record ,
374+ item ,
375+ Operation .updated .value ,
376+ ActionFlag .updated .value ,
345377 )
346378
347379
@@ -365,5 +397,9 @@ def validate_imms_delta_table_for_deleted_records_in_batch_file(context):
365397 batch_record = {k : normalize (v ) for k , v in row .to_dict ().items ()}
366398
367399 validate_imms_delta_record_with_batch_record (
368- context , batch_record , delete_item , Operation .deleted .value , ActionFlag .deleted .value
400+ context ,
401+ batch_record ,
402+ delete_item ,
403+ Operation .deleted .value ,
404+ ActionFlag .deleted .value ,
369405 )
0 commit comments