Skip to content

Commit 222af3d

Browse files
FimranNHSfimran08
andauthored
Ved 826 (#40)
* initial commit * final changes * fix dict error * fixed error_map dic issue * fix Error_Map issues * push changes to merge --------- Co-authored-by: fimran08 <[email protected]>
1 parent 2f04c81 commit 222af3d

File tree

11 files changed

+444
-159
lines changed

11 files changed

+444
-159
lines changed

features/APITests/create.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ Scenario Outline: Verify that the POST Create API will fail if nhs number is inv
166166
And The Response JSONs should contain correct error message for '<error_type>'
167167
Examples:
168168
|invalid_NhsNumber |error_type |
169-
|1234567890 |invalid_Mod11_NhsNumber |
170-
|12345678 |invalid_NHSNumber_length |
169+
|1234567890 |invalid_mod11_nhsnumber |
170+
|12345678 |invalid_nhsnumber_length |
171171

172172
@supplier_name_Postman_Auth @vaccine_type_RSV @patient_id_Random
173173
Scenario Outline: Verify that the POST Create API will fail if patient forename is invalid

features/APITests/steps/common_steps.py

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from src.objectModels.patient_loader import load_patient_by_id
88
from src.objectModels.api_immunization_builder import *
99
from utilities.api_fhir_immunization_helper import *
10-
from utilities.enums import ErrorName, Operation
10+
from utilities.enums import Operation
1111
from utilities.api_gen_token import get_tokens
1212
from utilities.api_get_header import *
1313
import pytest_check as check
@@ -111,46 +111,27 @@ def operationOutcomeInvalidParams(context):
111111

112112
match (nhs_invalid, disease_invalid, date_from_invalid, date_to_invalid, include_invalid):
113113
case (True, _, _, _, _):
114-
expected_error = ErrorName.invalid_NHSNumber.value
114+
expected_error = "invalid_NHSNumber"
115115
case (False, True, _, _, _):
116-
expected_error = ErrorName.invalid_DiseaseType.value
116+
expected_error = "invalid_DiseaseType"
117117
case (False, False, True, True, False):
118-
expected_error = ErrorName.invalid_DateFrom_To.value
118+
expected_error = "invalid_DateFrom_To"
119119
case (False, False, True, True, True):
120-
expected_error = ErrorName.invalid_DateFrom_DateTo_Include.value
120+
expected_error = "invalid_DateFrom_DateTo_Include"
121121
case (False, False, True, _, True):
122-
expected_error = ErrorName.invalid_DateFrom_Include.value
122+
expected_error = "invalid_DateFrom_Include"
123123
case (False, False, True, _, _):
124-
expected_error = ErrorName.invalid_DateFrom.value
124+
expected_error = "invalid_DateFrom"
125125
case (False, False, _, True, _):
126-
expected_error = ErrorName.invalid_DateTo.value
126+
expected_error = "invalid_DateTo"
127127
case (False, False, _, _, True):
128-
expected_error = ErrorName.invalid_include.value
128+
expected_error = "invalid_include"
129129
case _:
130130
raise ValueError("All parameters are valid, no error expected.")
131131

132132
validate_error_response(error_response, expected_error)
133133
print(f"\n Error Response - \n {error_response}")
134-
# def operationOutcomeInvalidParams(context):
135-
# error_response = parse_errorResponse(context.response.json())
136-
137-
# error_checks = [
138-
# (not is_valid_disease_type(context.DiseaseType), ErrorName.invalid_DiseaseType.value) if getattr(context, "DiseaseType", None) else (False, None),
139-
# (not is_valid_date(context.DateFrom), ErrorName.invalid_DateFrom.value) if getattr(context, "DateFrom", None) else (False, None),
140-
# (not is_valid_date(context.DateTo), ErrorName.invalid_DateTo.value) if getattr(context, "DateTo", None) else (False, None),
141-
# (not is_valid_nhs_number(context.NHSNumber), ErrorName.invalid_NHSNumber.value) if getattr(context, "NHSNumber", None) else (False, None),
142-
# ]
143-
144-
# for failed, errorName in error_checks:
145-
# if failed:
146-
# break
147-
# else:
148-
# raise ValueError("All parameters are valid, no error expected.")
149-
150-
# if errorName:
151-
# validateErrorResponse(error_response, errorName)
152-
# print(f"\n Error Response - \n {error_response}")
153-
134+
154135
@then('The X-Request-ID and X-Correlation-ID keys in header will populate correctly')
155136
def validateCreateHeader(context):
156137
assert "X-Request-ID" in context.response.request.headers, "X-Request-ID missing in headers"
@@ -202,7 +183,7 @@ def validate_imms_event_table_by_operation(context, operation: Operation):
202183
@then(parsers.parse("The Response JSONs should contain correct error message for Imms_id '{errorName}'"))
203184
def validateForbiddenAccess(context, errorName):
204185
error_response = parse_error_response(context.response.json())
205-
validate_error_response(error_response, ErrorName[errorName].value, context.ImmsID)
186+
validate_error_response(error_response, errorName, context.ImmsID)
206187
print(f"\n Error Response - \n {error_response}")
207188

208189
@then('The Etag in header will containing the latest event version')

features/batchTests/Steps/test_create_batch_steps.py

Lines changed: 110 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -50,43 +50,129 @@ def valid_batch_file_is_created_with_invalid_person_dateOfBirth_date(datatable,
5050
@ignore_if_local_run
5151
def valid_batch_file_is_created_with_invalid_patient_data(datatable, context):
5252
build_dataFrame_using_datatable(datatable, context)
53-
context.vaccine_df.loc[0,["NHS_NUMBER"]] = "12345678"
54-
context.vaccine_df.loc[1,["NHS_NUMBER"]] = "1234567890"
55-
context.vaccine_df.loc[2,["PERSON_FORENAME"]] = ""
53+
context.vaccine_df.loc[0,"NHS_NUMBER"] = "12345678"
54+
context.vaccine_df.loc[1,"NHS_NUMBER"] = "1234567890"
55+
context.vaccine_df.loc[2,"PERSON_FORENAME"] = ""
5656
context.vaccine_df.loc[3,["PERSON_FORENAME", "PERSON_SURNAME"]] = ""
57-
context.vaccine_df.loc[4,["PERSON_SURNAME"]] = ""
58-
context.vaccine_df.loc[5,["PERSON_GENDER_CODE"]] = "8"
59-
context.vaccine_df.loc[6,["PERSON_GENDER_CODE"]] = "unknow"
60-
context.vaccine_df.loc[7,["PERSON_GENDER_CODE"]] = ""
61-
context.vaccine_df.loc[8,["PERSON_FORENAME"]] = " "
62-
context.vaccine_df.loc[9,["PERSON_SURNAME"]] = " "
63-
context.vaccine_df.loc[10,["PERSON_SURNAME"]] = get_text("name_length_36")
64-
context.vaccine_df.loc[11,["PERSON_FORENAME"]] = get_text("name_length_36")
57+
context.vaccine_df.loc[4,"PERSON_SURNAME"] = ""
58+
context.vaccine_df.loc[5,"PERSON_GENDER_CODE"] = "8"
59+
context.vaccine_df.loc[6,"PERSON_GENDER_CODE"] = "unknow"
60+
context.vaccine_df.loc[7,"PERSON_GENDER_CODE"] = ""
61+
context.vaccine_df.loc[8,"PERSON_FORENAME"] = " "
62+
context.vaccine_df.loc[9,"PERSON_SURNAME"] = " "
63+
context.vaccine_df.loc[10,"PERSON_SURNAME"] = get_text("name_length_36")
64+
context.vaccine_df.loc[11,"PERSON_FORENAME"] = get_text("name_length_36")
6565
create_batch_file(context)
6666

6767
@given("batch file is created for below data where performer detail has invalid data")
6868
@ignore_if_local_run
6969
def valid_batch_file_is_created_with_invalid_performer_data(datatable, context):
7070
build_dataFrame_using_datatable(datatable, context)
71-
context.vaccine_df.loc[0,["PERFORMING_PROFESSIONAL_FORENAME"]] = ""
72-
context.vaccine_df.loc[1,["PERFORMING_PROFESSIONAL_SURNAME"]] = ""
71+
context.vaccine_df.loc[0,"PERFORMING_PROFESSIONAL_FORENAME"] = ""
72+
context.vaccine_df.loc[1,"PERFORMING_PROFESSIONAL_SURNAME"] = ""
7373
create_batch_file(context)
7474

7575
@given("batch file is created for below data where person detail has valid values")
7676
@ignore_if_local_run
7777
def valid_batch_file_is_created_with_different_values_gender(datatable, context):
7878
build_dataFrame_using_datatable(datatable, context)
79-
context.vaccine_df.loc[0,["PERSON_GENDER_CODE"]] = "0"
80-
context.vaccine_df.loc[1,["PERSON_GENDER_CODE"]] = "1"
81-
context.vaccine_df.loc[2,["PERSON_GENDER_CODE"]] = "2"
82-
context.vaccine_df.loc[3,["PERSON_GENDER_CODE"]] = "9"
83-
context.vaccine_df.loc[4,["PERSON_GENDER_CODE"]] = "unknown"
84-
context.vaccine_df.loc[5,["PERSON_GENDER_CODE"]] = "male"
85-
context.vaccine_df.loc[6,["PERSON_GENDER_CODE"]] = "female"
86-
context.vaccine_df.loc[7,["PERSON_GENDER_CODE"]] = "other"
87-
context.vaccine_df.loc[8,["PERSON_SURNAME"]] = get_text("name_length_35")
88-
context.vaccine_df.loc[9,["PERSON_FORENAME"]] = get_text("name_length_35")
89-
context.vaccine_df.loc[10,["PERSON_FORENAME"]] = f'Elan {get_text("name_length_15")}'
79+
context.vaccine_df.loc[0,"PERSON_GENDER_CODE"] = "0"
80+
context.vaccine_df.loc[1,"PERSON_GENDER_CODE"] = "1"
81+
context.vaccine_df.loc[2,"PERSON_GENDER_CODE"] = "2"
82+
context.vaccine_df.loc[3,"PERSON_GENDER_CODE"] = "9"
83+
context.vaccine_df.loc[4,"PERSON_GENDER_CODE"] = "unknown"
84+
context.vaccine_df.loc[5,"PERSON_GENDER_CODE"] = "male"
85+
context.vaccine_df.loc[6,"PERSON_GENDER_CODE"] = "female"
86+
context.vaccine_df.loc[7,"PERSON_GENDER_CODE"] = "other"
87+
context.vaccine_df.loc[8,"PERSON_SURNAME"] = get_text("name_length_35")
88+
context.vaccine_df.loc[9,"PERSON_FORENAME"] = get_text("name_length_35")
89+
context.vaccine_df.loc[10,"PERSON_FORENAME"] = f'Elan {get_text("name_length_15")}'
90+
create_batch_file(context)
91+
92+
@given("batch file is created for below data where mandatory fields for site, location, action flag, primary source and unique identifiers are missing")
93+
@ignore_if_local_run
94+
def valid_batch_file_is_created_with_missing_mandatory_fields(datatable, context):
95+
build_dataFrame_using_datatable(datatable, context)
96+
context.vaccine_df.loc[0, "SITE_CODE"] = ""
97+
context.vaccine_df.loc[1, "SITE_CODE_TYPE_URI"] = ""
98+
context.vaccine_df.loc[2, "LOCATION_CODE"] = ""
99+
context.vaccine_df.loc[3, "LOCATION_CODE_TYPE_URI"] = ""
100+
context.vaccine_df.loc[4, ["UNIQUE_ID","PERSON_SURNAME"]] = ["", "no_unique_identifiers"]
101+
context.vaccine_df.loc[5, ["UNIQUE_ID_URI", "PERSON_SURNAME"]] = ["", "no_unique_identifiers"]
102+
context.vaccine_df.loc[6, "PRIMARY_SOURCE"] = ""
103+
context.vaccine_df.loc[7, "VACCINATION_PROCEDURE_CODE"] = ""
104+
context.vaccine_df.loc[8, "SITE_CODE"] = " "
105+
context.vaccine_df.loc[9, "SITE_CODE_TYPE_URI"] = " "
106+
context.vaccine_df.loc[10, "LOCATION_CODE"] = " "
107+
context.vaccine_df.loc[11, "LOCATION_CODE_TYPE_URI"] = " "
108+
context.vaccine_df.loc[12, ["UNIQUE_ID","PERSON_SURNAME"]] = [" ", "no_unique_id"]
109+
context.vaccine_df.loc[13, ["UNIQUE_ID_URI", "PERSON_SURNAME"]] = [" ", "no_unique_id_uri"]
110+
context.vaccine_df.loc[14, "PRIMARY_SOURCE"] = " "
111+
context.vaccine_df.loc[15, "VACCINATION_PROCEDURE_CODE"] = " "
112+
context.vaccine_df.loc[16, "PRIMARY_SOURCE"] = "test"
113+
context.vaccine_df.loc[17, "ACTION_FLAG"] = ""
114+
context.vaccine_df.loc[18, "ACTION_FLAG"] = " "
115+
create_batch_file(context)
116+
117+
@given("batch file is created for below data where mandatory field for site, location and unique uri values are invalid")
118+
@ignore_if_local_run
119+
def valid_batch_file_is_created_with_invalid_mandatory_fields(datatable, context):
120+
build_dataFrame_using_datatable(datatable, context)
121+
context.vaccine_df.loc[0, "UNIQUE_ID_URI"] = "invalid_uri"
122+
context.vaccine_df.loc[1, "SITE_CODE_TYPE_URI"] = "invalid_uri"
123+
context.vaccine_df.loc[2, "LOCATION_CODE_TYPE_URI"] = "invalid_uri"
124+
create_batch_file(context)
125+
126+
127+
@given("batch file is created for below data where action flag has different cases")
128+
@ignore_if_local_run
129+
def valid_batch_file_is_created_with_different_action_flag_cases(datatable, context):
130+
build_dataFrame_using_datatable(datatable, context)
131+
context.vaccine_df.loc[0, "ACTION_FLAG"] = "NEW"
132+
context.vaccine_df.loc[1, "ACTION_FLAG"] = "New"
133+
context.vaccine_df.loc[2, "ACTION_FLAG"] = "new"
134+
context.vaccine_df.loc[3, "ACTION_FLAG"] = "nEw"
135+
create_batch_file(context)
136+
137+
138+
@given("batch file is created for below data where non mandatory fields are empty string")
139+
@ignore_if_local_run
140+
def valid_batch_file_is_created_with_empty_non_mandatory_fields(datatable, context):
141+
build_dataFrame_using_datatable(datatable, context)
142+
context.vaccine_df.loc[0, "NHS_NUMBER"] = " "
143+
context.vaccine_df.loc[1, "VACCINATION_PROCEDURE_TERM"] = " "
144+
context.vaccine_df.loc[2, "VACCINE_PRODUCT_CODE"] = " "
145+
context.vaccine_df.loc[3, "VACCINE_PRODUCT_TERM"] = " "
146+
context.vaccine_df.loc[4, "VACCINE_MANUFACTURER"] = " "
147+
context.vaccine_df.loc[5, "BATCH_NUMBER"] = " "
148+
context.vaccine_df.loc[6, "SITE_OF_VACCINATION_CODE"] = " "
149+
context.vaccine_df.loc[7, "SITE_OF_VACCINATION_TERM"] = " "
150+
context.vaccine_df.loc[8, "ROUTE_OF_VACCINATION_CODE"] = " "
151+
context.vaccine_df.loc[9, "ROUTE_OF_VACCINATION_TERM"] = " "
152+
context.vaccine_df.loc[10, "DOSE_SEQUENCE"] = " "
153+
context.vaccine_df.loc[11, "DOSE_UNIT_CODE"] = " "
154+
context.vaccine_df.loc[12, "DOSE_UNIT_TERM"] = " "
155+
context.vaccine_df.loc[13, "INDICATION_CODE"] = " "
156+
create_batch_file(context)
157+
158+
@given("batch file is created for below data where non mandatory fields are missing")
159+
@ignore_if_local_run
160+
def valid_batch_file_is_created_with_missing_non_mandatory_fields(datatable, context):
161+
build_dataFrame_using_datatable(datatable, context)
162+
context.vaccine_df.loc[0, "NHS_NUMBER"] = ""
163+
context.vaccine_df.loc[1, "VACCINATION_PROCEDURE_TERM"] = ""
164+
context.vaccine_df.loc[2, "VACCINE_PRODUCT_CODE"] = ""
165+
context.vaccine_df.loc[3, "VACCINE_PRODUCT_TERM"] = ""
166+
context.vaccine_df.loc[4, "VACCINE_MANUFACTURER"] = ""
167+
context.vaccine_df.loc[5, "BATCH_NUMBER"] = ""
168+
context.vaccine_df.loc[6, "SITE_OF_VACCINATION_CODE"] = ""
169+
context.vaccine_df.loc[7, "SITE_OF_VACCINATION_TERM"] = ""
170+
context.vaccine_df.loc[8, "ROUTE_OF_VACCINATION_CODE"] = ""
171+
context.vaccine_df.loc[9, "ROUTE_OF_VACCINATION_TERM"] = ""
172+
context.vaccine_df.loc[10, "DOSE_SEQUENCE"] = ""
173+
context.vaccine_df.loc[11, "DOSE_UNIT_CODE"] = ""
174+
context.vaccine_df.loc[12, "DOSE_UNIT_TERM"] = ""
175+
context.vaccine_df.loc[13, "INDICATION_CODE"] = ""
90176
create_batch_file(context)
91177

92178
@then("all records are rejected in the bus ack file and no imms id is generated")

0 commit comments

Comments
 (0)