2525 PERMISSIONS_CONFIG_FILE_KEY ,
2626 INPUT_PREFIX ,
2727 HEADER_RESPONSE_CODE_COLUMN ,
28+ ActionFlag ,
29+ Operation ,
30+ get_operation ,
31+ ActionSequence ,
2832)
2933
3034ods_vaccines = {
@@ -59,17 +63,19 @@ class OpMsgs:
5963
6064class TestData :
6165
62- def __init__ (self , name ,
66+ def __init__ (self ,
6367 vax_ods ,
64- actions : list , header = "NHS_NUMBER" ,
68+ action_sequence : ActionSequence , header = "NHS_NUMBER" ,
6569 expected : BusRowResult = BusRowResult .SUCCESS ,
6670 dose_amount = 0.5 ,
6771 inject_char = False ,
6872 version = 5 ,
73+ name = None ,
6974 operation_outcome : OpMsgs = None ):
70- self .name = name # name of the test
75+ suffix = f" - { name } " if name else ""
76+ self .name = f"{ action_sequence .description } { suffix } " # description of the test
77+ self .action_sequence = action_sequence # ActionSequence object containing description and list of actions
7178 self .dose_amount = dose_amount # dose amount to use in the csv rows
72- self .actions = actions # list of actions to include in the csv rows
7379 self .vax = ods_vaccines [vax_ods ][0 ] # Use the first vaccine for the ods
7480 self .ods = vax_ods # ods code to use in the csv rows
7581 self .expected = expected # expected result for each row in the bus ack file
@@ -80,6 +86,12 @@ def __init__(self, name,
8086 self .ack_keys = {DestinationType .INF : None , DestinationType .BUS : None } # s3 key prefixes of the ack files
8187 self .operation_outcome = operation_outcome # expected operation outcome message in the bus ack file
8288
89+ def getOperations (self ) -> list [Operation ]:
90+ operations = []
91+ for action in self .actions :
92+ operations .append (get_operation (action ))
93+ return operations
94+
8395 def poll_destination (self , pending : bool ) -> bool :
8496 # loop through keys in test (inf and bus)
8597 for ack_key in self .ack_keys .keys ():
@@ -92,7 +104,7 @@ def poll_destination(self, pending: bool) -> bool:
92104 return pending
93105
94106
95- def generate_csv (dose_amount , action_flag , headers = "NHS_NUMBER" , same_id = False , version = "4" ,
107+ def generate_csv (dose_amount , action_flag : ActionFlag , headers = "NHS_NUMBER" , same_id = False , version = "4" ,
96108 vax_type = "RSV" , ods = "YGM41" ):
97109 """
98110 Generate a CSV file with 2 or 3 rows depending on the action_flag.
@@ -116,7 +128,7 @@ def generate_csv(dose_amount, action_flag, headers="NHS_NUMBER", same_id=False,
116128
117129 data = []
118130
119- if action_flag == " CREATE" :
131+ if action_flag == ActionFlag . CREATE :
120132 if same_id :
121133
122134 unique_id = str (uuid .uuid4 ())
@@ -349,7 +361,7 @@ def validate_fatal_error(desc, row, index, expected_outcome):
349361 )
350362
351363
352- def validate_ok_response (desc , row , index , operation_requested ):
364+ def validate_ok_response (desc , row , index , operation_requested : Operation ):
353365 """
354366 Validate the LOCAL_ID format and verify that the DynamoDB primary key (PK)
355367 and operation match the expected values for OK responses.
@@ -519,7 +531,7 @@ def generate_csv_with_ordered_100000_rows(vax_type, ods):
519531 # Generate remaining 99,700 rows as CREATE operations
520532 create_data = [
521533 create_row (
522- unique_id = str (uuid .uuid4 ()), action_flag = "NEW" , dose_amount = "0.3" , header = "NHS_NUMBER"
534+ unique_id = str (uuid .uuid4 ()), action_flag = ActionFlag . CREATE , dose_amount = "0.3" , header = "NHS_NUMBER"
523535 )
524536 for _ in range (total_rows - special_row_count )
525537 ]
@@ -567,12 +579,12 @@ def get_file_name(vax_type, ods, version="5"):
567579def generate_csv_files (seed_data_list : list [TestData ]) -> list [TestData ]:
568580 """Generate CSV files based on a list of TestData instances."""
569581 for seed_data in seed_data_list :
570- file_name = (generate_csv_file (seed_data , actions = seed_data .actions ))
582+ file_name = (generate_csv_file (seed_data , actions = seed_data .action_sequence . actions ))
571583 seed_data .file_name = file_name
572584 return seed_data_list
573585
574586
575- def generate_csv_file (seed : TestData , actions : str ) -> str :
587+ def generate_csv_file (seed : TestData , actions : list [ ActionFlag ] ) -> str :
576588
577589 data = []
578590 for action in actions :
@@ -618,7 +630,8 @@ def cleanup(data_list: list[TestData]):
618630 logger .warning (f"s3 delete fail { ACK_BUCKET } : { ack_key } " )
619631
620632
621- def check_inf_file_content (desc , content , response_code , operation_outcome , operation_requested ):
633+ def check_inf_file_content (desc , content , response_code , operation_outcome ,
634+ operations_requested : list [Operation ]):
622635
623636 reader = csv .DictReader (content .splitlines (), delimiter = "|" )
624637 rows = list (reader )
@@ -629,7 +642,7 @@ def check_inf_file_content(desc, content, response_code, operation_outcome, oper
629642
630643 first_row = rows [0 ]
631644 validate_header_response_code (desc , first_row , 0 , "OK" )
632- validate_ok_response (desc , first_row , 0 , operation_requested )
645+ validate_ok_response (desc , first_row , 0 , operations_requested [ 0 ] )
633646
634647 second_row = rows [1 ]
635648 validate_header_response_code (desc , second_row , 1 , "Fatal Error" )
@@ -650,6 +663,6 @@ def check_inf_file_content(desc, content, response_code, operation_outcome, oper
650663 f"but got '{ row_OPERATION_OUTCOME } '"
651664 )
652665 if row_HEADER_RESPONSE_CODE == "OK" :
653- validate_ok_response (desc , row , i , operation_requested [i ])
666+ validate_ok_response (desc , row , i , operations_requested [i ])
654667 elif row_HEADER_RESPONSE_CODE == "Fatal Error" :
655668 validate_fatal_error (desc , row , i , operation_outcome )
0 commit comments