|
34 | 34 | class TestE2EBatch(unittest.TestCase): |
35 | 35 |
|
36 | 36 | def setUp(self): |
37 | | - self.seed_datas = [ |
38 | | - TestData("V0V8L", ActionSet.CREATE), |
39 | | - # TestData("8HK48", ActionSet.UPDATE), |
40 | | - # TestData("8HA94", ActionSet.DELETE), |
41 | | - # TestData("Reinstate", "X26", [NEW, DELETE, UPDATE]), |
42 | | - # TestData("Update no Create", "YGM41", [UPDATE], expected=BusRowResult.FATAL_ERROR, |
43 | | - # operation_outcome=OpMsgs.IMM_NOT_EXIST), |
44 | | - # TestData("Delete no Create", "YGJ", [DELETE], expected=BusRowResult.FATAL_ERROR, |
45 | | - # operation_outcome=OpMsgs.IMM_NOT_EXIST), |
46 | | - # TestData("YGA", ActionSet.CREATE, inject_char=True, name="Create with 1252 char"), |
47 | | - ] |
| 37 | + self.seed_datas = create_seed_data() |
48 | 38 |
|
49 | 39 | def tearDown(self): |
50 | 40 | # loop through all files and delete them from s3 |
@@ -99,31 +89,49 @@ def validate_responses(tests: list[TestData]): |
99 | 89 | start_time = time.time() |
100 | 90 | count = 0 |
101 | 91 | expected_count = len(tests) * 2 |
102 | | - for test in tests: |
103 | | - logger.info(f"Validation for Test: {test.name} ") |
104 | | - # Validate the ACK file |
105 | | - if test.ack_keys[DestinationType.INF]: |
106 | | - count += 1 |
107 | | - inf_ack_content = get_file_content_from_s3(ACK_BUCKET, test.ack_keys[DestinationType.INF]) |
108 | | - else: |
109 | | - logger.error(f"INF ACK file not found for test: {test.name}") |
110 | | - |
111 | | - check_ack_file_content(test.name, inf_ack_content, "Success", None, test.actions) |
112 | | - if test.ack_keys[DestinationType.BUS]: |
113 | | - count += 1 |
114 | | - validate_row_count(f"{test.name} - inf", test.file_name, test.ack_keys[DestinationType.BUS]) |
115 | | - # check row after header |
116 | | - bus_ack_content = get_file_content_from_s3(ACK_BUCKET, test.ack_keys[DestinationType.BUS]) |
117 | | - # loop through each line in the bus ack content |
118 | | - |
119 | | - # sometimes OK and sometimes CREATE |
120 | | - check_inf_file_content(f"{test.name} - bus", bus_ack_content, "OK", test.operation_outcome, |
121 | | - test.getOperations()) |
| 92 | + try: |
| 93 | + for test in tests: |
| 94 | + logger.info(f"Validation for Test: {test.name} ") |
| 95 | + # Validate the ACK file |
| 96 | + if test.ack_keys[DestinationType.INF]: |
| 97 | + count += 1 |
| 98 | + inf_ack_content = get_file_content_from_s3(ACK_BUCKET, test.ack_keys[DestinationType.INF]) |
| 99 | + check_ack_file_content(test.name, inf_ack_content, "Success", None, test.action_sequence.actions) |
| 100 | + else: |
| 101 | + logger.error(f"INF ACK file not found for test: {test.name}") |
| 102 | + |
| 103 | + if test.ack_keys[DestinationType.BUS]: |
| 104 | + count += 1 |
| 105 | + validate_row_count(f"{test.name} - inf", test.file_name, test.ack_keys[DestinationType.BUS]) |
| 106 | + # check row after header |
| 107 | + bus_ack_content = get_file_content_from_s3(ACK_BUCKET, test.ack_keys[DestinationType.BUS]) |
| 108 | + # loop through each line in the bus ack content |
| 109 | + |
| 110 | + # sometimes OK and sometimes CREATE |
| 111 | + check_inf_file_content(f"{test.name} - bus", bus_ack_content, "OK", test.operation_outcome, |
| 112 | + test.getOperations()) |
| 113 | + else: |
| 114 | + logger.error(f"BUS ACK file not found for test: {test.name}") |
| 115 | + except Exception as e: |
| 116 | + logger.error(f"Error during validation: {e}") |
| 117 | + finally: |
| 118 | + if count == expected_count: |
| 119 | + logger.info("All responses subject to validation.") |
122 | 120 | else: |
123 | | - logger.error(f"BUS ACK file not found for test: {test.name}") |
| 121 | + logger.error(f"{count} of {expected_count} responses subject to validation.") |
| 122 | + logger.info(f"Time: {time.time() - start_time:.1f} seconds") |
| 123 | + assert count == expected_count, f"Only {count} of {expected_count} responses subject to validation." |
| 124 | + |
124 | 125 |
|
125 | | - if count == expected_count: |
126 | | - logger.info("All responses subject to validation.") |
127 | | - else: |
128 | | - logger.error(f"{count} of {expected_count} responses subject to validation.") |
129 | | - logger.info(f"Time: {time.time() - start_time:.1f} seconds") |
| 126 | +def create_seed_data() -> list[TestData]: |
| 127 | + return [ |
| 128 | + # TestData("V0V8L", ActionSet.CREATE), |
| 129 | + # TestData("8HK48", ActionSet.UPDATE), |
| 130 | + TestData("8HA94", ActionSet.DELETE), |
| 131 | + # TestData("Reinstate", "X26", [NEW, DELETE, UPDATE]), |
| 132 | + # TestData("Update no Create", "YGM41", [UPDATE], expected=BusRowResult.FATAL_ERROR, |
| 133 | + # operation_outcome=OpMsgs.IMM_NOT_EXIST), |
| 134 | + # TestData("Delete no Create", "YGJ", [DELETE], expected=BusRowResult.FATAL_ERROR, |
| 135 | + # operation_outcome=OpMsgs.IMM_NOT_EXIST), |
| 136 | + # TestData("YGA", ActionSet.CREATE, inject_char=True, name="Create with 1252 char"), |
| 137 | + ] |
0 commit comments