Skip to content

Commit 287fc57

Browse files
author
ASubaran
committed
added changes
1 parent 5788b50 commit 287fc57

File tree

3 files changed

+22
-7
lines changed

3 files changed

+22
-7
lines changed

e2e_batch/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@
66
ACK_BUCKET = "immunisation-batch-internal-dev-data-destinations"
77
FORWARDEDFILE_PREFIX = "forwardedFile/"
88
ACK_PREFIX = "ack/"
9+
PRE_VALIDATION_ERROR = "Validation errors: doseQuantity.value must be a number"
10+
POST_VALIDATION_ERROR = "Validation errors: contained[?(@.resourceType=='Patient')].name[0].given is a mandatory field"

e2e_batch/test_e2e_batch.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
wait_for_ack_file,
77
check_ack_file_content,
88
)
9-
from constants import INPUT_BUCKET, INPUT_PREFIX, ACK_BUCKET
9+
from constants import INPUT_BUCKET, INPUT_PREFIX, ACK_BUCKET, PRE_VALIDATION_ERROR, POST_VALIDATION_ERROR
1010
from clients import logger
1111

1212

@@ -17,7 +17,7 @@ def e2e_test_create_success():
1717
os.remove(input_file)
1818
ack_key = wait_for_ack_file(None, input_file)
1919
ack_content = get_file_content_from_s3(ACK_BUCKET, ack_key)
20-
check_ack_file_content(ack_content, "OK")
20+
check_ack_file_content(ack_content, "OK", None)
2121
logger.info("Test e2e_test_create_success successfully passed")
2222

2323

@@ -28,7 +28,7 @@ def e2e_test_update_success():
2828
os.remove(input_file)
2929
ack_key = wait_for_ack_file(None, input_file)
3030
ack_content = get_file_content_from_s3(ACK_BUCKET, ack_key)
31-
check_ack_file_content(ack_content, "OK")
31+
check_ack_file_content(ack_content, "OK", None)
3232
logger.info("Test e2e_test_update_success successfully passed")
3333

3434

@@ -39,7 +39,7 @@ def e2e_test_delete_success():
3939
os.remove(input_file)
4040
ack_key = wait_for_ack_file(None, input_file)
4141
ack_content = get_file_content_from_s3(ACK_BUCKET, ack_key)
42-
check_ack_file_content(ack_content, "OK")
42+
check_ack_file_content(ack_content, "OK", None)
4343
logger.info("Test e2e_test_delete_success successfully passed")
4444

4545

@@ -50,7 +50,11 @@ def e2e_test_pre_validation_error():
5050
os.remove(input_file)
5151
ack_key = wait_for_ack_file(None, input_file)
5252
ack_content = get_file_content_from_s3(ACK_BUCKET, ack_key)
53-
check_ack_file_content(ack_content, "Fatal Error")
53+
check_ack_file_content(
54+
ack_content,
55+
"Fatal Error",
56+
PRE_VALIDATION_ERROR,
57+
)
5458
logger.info("Test e2e_test_pre_validation_error successfully passed")
5559

5660

@@ -61,7 +65,11 @@ def e2e_test_post_validation_error():
6165
os.remove(input_file)
6266
ack_key = wait_for_ack_file(None, input_file)
6367
ack_content = get_file_content_from_s3(ACK_BUCKET, ack_key)
64-
check_ack_file_content(ack_content, "Fatal Error")
68+
check_ack_file_content(
69+
ack_content,
70+
"Fatal Error",
71+
POST_VALIDATION_ERROR,
72+
)
6573
logger.info("Test e2e_test_post_validation_error successfully passed")
6674

6775

e2e_batch/utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def get_file_content_from_s3(bucket, key):
118118
return content
119119

120120

121-
def check_ack_file_content(content, response_code):
121+
def check_ack_file_content(content, response_code, operation_outcome):
122122
"""Parse the ack CSV file and verify each row's 'HEADER_RESPONSE_CODE' column matches the response code."""
123123
reader = csv.DictReader(content.splitlines(), delimiter="|")
124124
rows = list(reader)
@@ -129,4 +129,9 @@ def check_ack_file_content(content, response_code):
129129
raise AssertionError(
130130
f"Row {i + 1}: Expected RESPONSE '{response_code}', but found '{row['HEADER_RESPONSE_CODE']}'"
131131
)
132+
if row["HEADER_RESPONSE_CODE"].strip() == "Fatal Error":
133+
if row["OPERATION_OUTCOME"].strip() != operation_outcome:
134+
raise AssertionError(
135+
f"Row {i + 1}: Expected RESPONSE '{operation_outcome}', but found '{row['OPERATION_OUTCOME']}'"
136+
)
132137
# logger.info("All rows in the ack file have been verified successfully.")

0 commit comments

Comments
 (0)