|
7 | 7 | wait_for_ack_file, |
8 | 8 | check_ack_file_content, |
9 | 9 | validate_row_count, |
10 | | - upload_config_file |
| 10 | + upload_config_file, |
| 11 | + generate_csv_with_ordered_100000_rows, |
| 12 | + verify_final_ack_file, |
11 | 13 | ) |
12 | 14 | from constants import ( |
13 | 15 | SOURCE_BUCKET, |
|
17 | 19 | POST_VALIDATION_ERROR, |
18 | 20 | DUPLICATE, |
19 | 21 | FILE_NAME_VAL_ERROR, |
| 22 | + env_value, |
20 | 23 | ) |
21 | 24 |
|
22 | 25 |
|
23 | 26 | class TestE2EBatch(unittest.TestCase): |
| 27 | + if env_value != "ref": |
24 | 28 |
|
25 | | - def test_create_success(self): |
26 | | - """Test CREATE scenario.""" |
27 | | - input_file = generate_csv("PHYLIS", "0.3", action_flag="CREATE") |
28 | | - upload_file_to_s3(input_file, SOURCE_BUCKET, INPUT_PREFIX) |
29 | | - ack_key = wait_for_ack_file(None, input_file) |
30 | | - validate_row_count(input_file, ack_key) |
31 | | - ack_content = get_file_content_from_s3(ACK_BUCKET, ack_key) |
32 | | - check_ack_file_content(ack_content, "OK", None, "CREATE") |
33 | | - |
34 | | - def test_duplicate_create(self): |
35 | | - """Test DUPLICATE scenario.""" |
36 | | - input_file = generate_csv("PHYLIS", "0.3", action_flag="CREATE", same_id=True) |
37 | | - upload_file_to_s3(input_file, SOURCE_BUCKET, INPUT_PREFIX) |
38 | | - ack_key = wait_for_ack_file(None, input_file) |
39 | | - validate_row_count(input_file, ack_key) |
40 | | - ack_content = get_file_content_from_s3(ACK_BUCKET, ack_key) |
41 | | - check_ack_file_content(ack_content, "Fatal Error", DUPLICATE, "CREATE") |
42 | | - |
43 | | - def test_update_success(self): |
44 | | - """Test UPDATE scenario.""" |
45 | | - input_file = generate_csv("PHYLIS", "0.5", action_flag="UPDATE") |
46 | | - upload_file_to_s3(input_file, SOURCE_BUCKET, INPUT_PREFIX) |
47 | | - ack_key = wait_for_ack_file(None, input_file) |
48 | | - validate_row_count(input_file, ack_key) |
49 | | - ack_content = get_file_content_from_s3(ACK_BUCKET, ack_key) |
50 | | - check_ack_file_content(ack_content, "OK", None, "UPDATE") |
51 | | - |
52 | | - def test_reinstated_success(self): |
53 | | - """Test REINSTATED scenario.""" |
54 | | - input_file = generate_csv("PHYLIS", "0.5", action_flag="REINSTATED") |
55 | | - upload_file_to_s3(input_file, SOURCE_BUCKET, INPUT_PREFIX) |
56 | | - ack_key = wait_for_ack_file(None, input_file) |
57 | | - validate_row_count(input_file, ack_key) |
58 | | - ack_content = get_file_content_from_s3(ACK_BUCKET, ack_key) |
59 | | - check_ack_file_content(ack_content, "OK", None, "reinstated") |
60 | | - |
61 | | - def test_update_reinstated_success(self): |
62 | | - """Test UPDATE-REINSTATED scenario.""" |
63 | | - input_file = generate_csv("PHYLIS", "0.5", action_flag="UPDATE-REINSTATED") |
64 | | - upload_file_to_s3(input_file, SOURCE_BUCKET, INPUT_PREFIX) |
65 | | - ack_key = wait_for_ack_file(None, input_file) |
66 | | - validate_row_count(input_file, ack_key) |
67 | | - ack_content = get_file_content_from_s3(ACK_BUCKET, ack_key) |
68 | | - check_ack_file_content(ack_content, "OK", None, "update-reinstated") |
69 | | - |
70 | | - def test_delete_success(self): |
71 | | - """Test DELETE scenario.""" |
72 | | - input_file = generate_csv("PHYLIS", "0.8", action_flag="DELETE") |
73 | | - upload_file_to_s3(input_file, SOURCE_BUCKET, INPUT_PREFIX) |
74 | | - ack_key = wait_for_ack_file(None, input_file) |
75 | | - validate_row_count(input_file, ack_key) |
76 | | - ack_content = get_file_content_from_s3(ACK_BUCKET, ack_key) |
77 | | - check_ack_file_content(ack_content, "OK", None, "DELETE") |
78 | | - |
79 | | - def test_pre_validation_error(self): |
80 | | - """Test PRE-VALIDATION error scenario.""" |
81 | | - input_file = generate_csv("PHYLIS", "TRUE", action_flag="CREATE") |
82 | | - upload_file_to_s3(input_file, SOURCE_BUCKET, INPUT_PREFIX) |
83 | | - ack_key = wait_for_ack_file(None, input_file) |
84 | | - validate_row_count(input_file, ack_key) |
85 | | - ack_content = get_file_content_from_s3(ACK_BUCKET, ack_key) |
86 | | - check_ack_file_content(ack_content, "Fatal Error", PRE_VALIDATION_ERROR, None) |
87 | | - |
88 | | - def test_post_validation_error(self): |
89 | | - """Test POST-VALIDATION error scenario.""" |
90 | | - input_file = generate_csv("", "0.3", action_flag="CREATE") |
91 | | - upload_file_to_s3(input_file, SOURCE_BUCKET, INPUT_PREFIX) |
92 | | - ack_key = wait_for_ack_file(None, input_file) |
93 | | - ack_content = get_file_content_from_s3(ACK_BUCKET, ack_key) |
94 | | - check_ack_file_content(ack_content, "Fatal Error", POST_VALIDATION_ERROR, None) |
95 | | - |
96 | | - def test_file_name_validation_error(self): |
97 | | - """Test FILE-NAME-VALIDATION error scenario.""" |
98 | | - input_file = generate_csv("PHYLIS", "0.3", action_flag="CREATE", file_key=True) |
99 | | - upload_file_to_s3(input_file, SOURCE_BUCKET, INPUT_PREFIX) |
100 | | - ack_key = wait_for_ack_file(True, input_file) |
101 | | - ack_content = get_file_content_from_s3(ACK_BUCKET, ack_key) |
102 | | - check_ack_file_content(ack_content, "Failure", FILE_NAME_VAL_ERROR, None) |
103 | | - |
104 | | - def test_header_name_validation_error(self): |
105 | | - """Test HEADER-NAME-VALIDATION error scenario.""" |
106 | | - input_file = generate_csv("PHYLIS", "0.3", action_flag="CREATE", headers="NH_NUMBER") |
107 | | - upload_file_to_s3(input_file, SOURCE_BUCKET, INPUT_PREFIX) |
108 | | - ack_key = wait_for_ack_file(True, input_file) |
109 | | - ack_content = get_file_content_from_s3(ACK_BUCKET, ack_key) |
110 | | - check_ack_file_content(ack_content, "Failure", FILE_NAME_VAL_ERROR, None) |
111 | | - |
112 | | - def test_invalid_permission(self): |
113 | | - """Test INVALID-PERMISSION error scenario.""" |
114 | | - upload_config_file("MMR_FULL") |
115 | | - time.sleep(20) |
116 | | - input_file = generate_csv("PHYLIS", "0.3", action_flag="CREATE") |
117 | | - upload_file_to_s3(input_file, SOURCE_BUCKET, INPUT_PREFIX) |
118 | | - ack_key = wait_for_ack_file(True, input_file) |
119 | | - ack_content = get_file_content_from_s3(ACK_BUCKET, ack_key) |
120 | | - check_ack_file_content(ack_content, "Failure", FILE_NAME_VAL_ERROR, None) |
121 | | - upload_config_file("COVID19_FULL") |
122 | | - time.sleep(20) |
| 29 | + def test_create_success(self): |
| 30 | + """Test CREATE scenario.""" |
| 31 | + input_file = generate_csv("PHYLIS", "0.3", action_flag="CREATE") |
| 32 | + upload_file_to_s3(input_file, SOURCE_BUCKET, INPUT_PREFIX) |
| 33 | + ack_key = wait_for_ack_file(None, input_file) |
| 34 | + validate_row_count(input_file, ack_key) |
| 35 | + ack_content = get_file_content_from_s3(ACK_BUCKET, ack_key) |
| 36 | + check_ack_file_content(ack_content, "OK", None, "CREATE") |
| 37 | + |
| 38 | + def test_duplicate_create(self): |
| 39 | + """Test DUPLICATE scenario.""" |
| 40 | + input_file = generate_csv("PHYLIS", "0.3", action_flag="CREATE", same_id=True) |
| 41 | + upload_file_to_s3(input_file, SOURCE_BUCKET, INPUT_PREFIX) |
| 42 | + ack_key = wait_for_ack_file(None, input_file) |
| 43 | + validate_row_count(input_file, ack_key) |
| 44 | + ack_content = get_file_content_from_s3(ACK_BUCKET, ack_key) |
| 45 | + check_ack_file_content(ack_content, "Fatal Error", DUPLICATE, "CREATE") |
| 46 | + |
| 47 | + def test_update_success(self): |
| 48 | + """Test UPDATE scenario.""" |
| 49 | + input_file = generate_csv("PHYLIS", "0.5", action_flag="UPDATE") |
| 50 | + upload_file_to_s3(input_file, SOURCE_BUCKET, INPUT_PREFIX) |
| 51 | + ack_key = wait_for_ack_file(None, input_file) |
| 52 | + validate_row_count(input_file, ack_key) |
| 53 | + ack_content = get_file_content_from_s3(ACK_BUCKET, ack_key) |
| 54 | + check_ack_file_content(ack_content, "OK", None, "UPDATE") |
| 55 | + |
| 56 | + def test_reinstated_success(self): |
| 57 | + """Test REINSTATED scenario.""" |
| 58 | + input_file = generate_csv("PHYLIS", "0.5", action_flag="REINSTATED") |
| 59 | + upload_file_to_s3(input_file, SOURCE_BUCKET, INPUT_PREFIX) |
| 60 | + ack_key = wait_for_ack_file(None, input_file) |
| 61 | + validate_row_count(input_file, ack_key) |
| 62 | + ack_content = get_file_content_from_s3(ACK_BUCKET, ack_key) |
| 63 | + check_ack_file_content(ack_content, "OK", None, "reinstated") |
| 64 | + |
| 65 | + def test_update_reinstated_success(self): |
| 66 | + """Test UPDATE-REINSTATED scenario.""" |
| 67 | + input_file = generate_csv("PHYLIS", "0.5", action_flag="UPDATE-REINSTATED") |
| 68 | + upload_file_to_s3(input_file, SOURCE_BUCKET, INPUT_PREFIX) |
| 69 | + ack_key = wait_for_ack_file(None, input_file) |
| 70 | + validate_row_count(input_file, ack_key) |
| 71 | + ack_content = get_file_content_from_s3(ACK_BUCKET, ack_key) |
| 72 | + check_ack_file_content(ack_content, "OK", None, "update-reinstated") |
| 73 | + |
| 74 | + def test_delete_success(self): |
| 75 | + """Test DELETE scenario.""" |
| 76 | + input_file = generate_csv("PHYLIS", "0.8", action_flag="DELETE") |
| 77 | + upload_file_to_s3(input_file, SOURCE_BUCKET, INPUT_PREFIX) |
| 78 | + ack_key = wait_for_ack_file(None, input_file) |
| 79 | + validate_row_count(input_file, ack_key) |
| 80 | + ack_content = get_file_content_from_s3(ACK_BUCKET, ack_key) |
| 81 | + check_ack_file_content(ack_content, "OK", None, "DELETE") |
| 82 | + |
| 83 | + def test_pre_validation_error(self): |
| 84 | + """Test PRE-VALIDATION error scenario.""" |
| 85 | + input_file = generate_csv("PHYLIS", "TRUE", action_flag="CREATE") |
| 86 | + upload_file_to_s3(input_file, SOURCE_BUCKET, INPUT_PREFIX) |
| 87 | + ack_key = wait_for_ack_file(None, input_file) |
| 88 | + validate_row_count(input_file, ack_key) |
| 89 | + ack_content = get_file_content_from_s3(ACK_BUCKET, ack_key) |
| 90 | + check_ack_file_content(ack_content, "Fatal Error", PRE_VALIDATION_ERROR, None) |
| 91 | + |
| 92 | + def test_post_validation_error(self): |
| 93 | + """Test POST-VALIDATION error scenario.""" |
| 94 | + input_file = generate_csv("", "0.3", action_flag="CREATE") |
| 95 | + upload_file_to_s3(input_file, SOURCE_BUCKET, INPUT_PREFIX) |
| 96 | + ack_key = wait_for_ack_file(None, input_file) |
| 97 | + ack_content = get_file_content_from_s3(ACK_BUCKET, ack_key) |
| 98 | + check_ack_file_content(ack_content, "Fatal Error", POST_VALIDATION_ERROR, None) |
| 99 | + |
| 100 | + def test_file_name_validation_error(self): |
| 101 | + """Test FILE-NAME-VALIDATION error scenario.""" |
| 102 | + input_file = generate_csv("PHYLIS", "0.3", action_flag="CREATE", file_key=True) |
| 103 | + upload_file_to_s3(input_file, SOURCE_BUCKET, INPUT_PREFIX) |
| 104 | + ack_key = wait_for_ack_file(True, input_file) |
| 105 | + ack_content = get_file_content_from_s3(ACK_BUCKET, ack_key) |
| 106 | + check_ack_file_content(ack_content, "Failure", FILE_NAME_VAL_ERROR, None) |
| 107 | + |
| 108 | + def test_header_name_validation_error(self): |
| 109 | + """Test HEADER-NAME-VALIDATION error scenario.""" |
| 110 | + input_file = generate_csv("PHYLIS", "0.3", action_flag="CREATE", headers="NH_NUMBER") |
| 111 | + upload_file_to_s3(input_file, SOURCE_BUCKET, INPUT_PREFIX) |
| 112 | + ack_key = wait_for_ack_file(True, input_file) |
| 113 | + ack_content = get_file_content_from_s3(ACK_BUCKET, ack_key) |
| 114 | + check_ack_file_content(ack_content, "Failure", FILE_NAME_VAL_ERROR, None) |
| 115 | + |
| 116 | + def test_invalid_permission(self): |
| 117 | + """Test INVALID-PERMISSION error scenario.""" |
| 118 | + upload_config_file("MMR_FULL") |
| 119 | + time.sleep(20) |
| 120 | + input_file = generate_csv("PHYLIS", "0.3", action_flag="CREATE") |
| 121 | + upload_file_to_s3(input_file, SOURCE_BUCKET, INPUT_PREFIX) |
| 122 | + ack_key = wait_for_ack_file(True, input_file) |
| 123 | + ack_content = get_file_content_from_s3(ACK_BUCKET, ack_key) |
| 124 | + check_ack_file_content(ack_content, "Failure", FILE_NAME_VAL_ERROR, None) |
| 125 | + upload_config_file("COVID19_FULL") |
| 126 | + time.sleep(20) |
| 127 | + |
| 128 | + else: |
| 129 | + |
| 130 | + def test_end_to_end_speed_test_with_100000_rows(self): |
| 131 | + """Test end_to_end_speed_test_with_100000_rows scenario with full integration""" |
| 132 | + input_file = generate_csv_with_ordered_100000_rows(None) |
| 133 | + upload_file_to_s3(input_file, SOURCE_BUCKET, INPUT_PREFIX) |
| 134 | + final_ack_key = wait_for_ack_file(None, input_file, timeout=1800) |
| 135 | + response = verify_final_ack_file(final_ack_key) |
| 136 | + assert response is True |
123 | 137 |
|
124 | 138 |
|
125 | 139 | if __name__ == "__main__": |
|
0 commit comments