|
24 | 24 |
|
25 | 25 | scenarios("APITests/search.feature") |
26 | 26 |
|
27 | | -TARGET_DISEASE_SYSTEM = "http://snomed.info/sct" |
28 | | -INVALID_TARGET_DISEASE_CODE = "99999" |
29 | | -PATIENT_IDENTIFIER_SYSTEM = "https://fhir.nhs.uk/Id/nhs-number" |
30 | | - |
31 | 27 |
|
32 | 28 | @when("I send a search request with Post method using identifier parameter for Immunization event created") |
33 | 29 | def send_search_post_request_with_identifier_header(context): |
@@ -144,40 +140,47 @@ def send_search_post_with_target_disease_and_dates(context): |
144 | 140 | trigger_search_request_by_httpMethod(context, httpMethod="POST") |
145 | 141 |
|
146 | 142 |
|
147 | | -@when("Send a search request with GET method using target-disease for Immunization event created with valid NHS Number") |
148 | | -def send_search_get_with_target_disease_unauthorised_supplier(context): |
| 143 | +@when( |
| 144 | + parsers.parse( |
| 145 | + "Send a search request with GET method using target-disease for Immunization event created with valid NHS Number and patient identifier system '{patient_identifier_system}' and target-disease system '{target_disease_system}'" |
| 146 | + ) |
| 147 | +) |
| 148 | +def send_search_get_with_target_disease_unauthorised_supplier(context, patient_identifier_system, target_disease_system): |
149 | 149 | nhs_number = "9000000009" |
150 | 150 | context.params = { |
151 | | - "patient.identifier": f"{PATIENT_IDENTIFIER_SYSTEM}|{nhs_number}", |
152 | | - "target-disease": f"{TARGET_DISEASE_SYSTEM}|14189004", |
| 151 | + "patient.identifier": f"{patient_identifier_system}|{nhs_number}", |
| 152 | + "target-disease": f"{target_disease_system}|14189004", |
153 | 153 | } |
154 | 154 | trigger_search_request_by_httpMethod(context, httpMethod="GET") |
155 | 155 |
|
156 | 156 |
|
157 | 157 | @when( |
158 | 158 | parsers.parse( |
159 | | - "Send a search request with '{httpMethod}' method with valid NHS Number and all invalid target-disease codes" |
| 159 | + "Send a search request with '{httpMethod}' method with valid NHS Number and all invalid target-disease codes using patient identifier system '{patient_identifier_system}'" |
160 | 160 | ) |
161 | 161 | ) |
162 | | -def send_search_request_with_all_invalid_target_disease_codes(context, httpMethod): |
| 162 | +def send_search_request_with_all_invalid_target_disease_codes(context, httpMethod, patient_identifier_system): |
163 | 163 | context.params = context.request = { |
164 | | - "patient.identifier": f"{PATIENT_IDENTIFIER_SYSTEM}|9000000009", |
| 164 | + "patient.identifier": f"{patient_identifier_system}|9000000009", |
165 | 165 | "target-disease": "invalid-no-pipe,wrong_system|123", |
166 | 166 | } |
167 | 167 | trigger_search_request_by_httpMethod(context, httpMethod=httpMethod) |
168 | 168 |
|
169 | 169 |
|
170 | 170 | @when( |
171 | 171 | parsers.parse( |
172 | | - "Send a search request with '{httpMethod}' method using mixed valid and invalid target-disease codes for Immunization event created" |
| 172 | + "Send a search request with '{httpMethod}' method using mixed valid and invalid target-disease codes for Immunization event created with target-disease system '{target_disease_system}' and invalid target-disease code '{invalid_target_disease_code}'" |
173 | 173 | ) |
174 | 174 | ) |
175 | | -def send_search_post_with_mixed_valid_and_invalid_target_disease_codes(context, httpMethod): |
| 175 | +def send_search_post_with_mixed_valid_and_invalid_target_disease_codes( |
| 176 | + context, httpMethod, target_disease_system, invalid_target_disease_code |
| 177 | +): |
176 | 178 | patient_ident = context.create_object.contained[1].identifier[0] |
177 | 179 | target = context.create_object.protocolApplied[0].targetDisease[0].coding[0] |
| 180 | + context.invalid_target_disease_code = invalid_target_disease_code |
178 | 181 | context.params = context.request = { |
179 | 182 | "patient.identifier": f"{patient_ident.system}|{patient_ident.value}", |
180 | | - "target-disease": f"{target.system}|{target.code},{TARGET_DISEASE_SYSTEM}|{INVALID_TARGET_DISEASE_CODE}", |
| 183 | + "target-disease": f"{target.system}|{target.code},{target_disease_system}|{invalid_target_disease_code}", |
181 | 184 | } |
182 | 185 | trigger_search_request_by_httpMethod(context, httpMethod=httpMethod) |
183 | 186 |
|
@@ -499,15 +502,19 @@ def validate_invalid_target_disease_codes_error(context): |
499 | 502 | def validate_search_response_with_invalid_target_disease_operation_outcome(context): |
500 | 503 | issue = read_issue_from_response(context) |
501 | 504 | diagnostics = issue.get("diagnostics", "") |
| 505 | + invalid_target_disease_code = getattr(context, "invalid_target_disease_code", None) |
502 | 506 | assert issue.get("code") == "invalid", f"issue code should be 'invalid', got '{issue.get('code')}'" |
503 | 507 | assert "Target disease code" in diagnostics, ( |
504 | 508 | f"issue diagnostics should mention 'Target disease code', got '{diagnostics}'" |
505 | 509 | ) |
506 | 510 | assert "not a supported target disease in this service" in diagnostics, ( |
507 | 511 | f"issue diagnostics should mention unsupported target disease, got '{diagnostics}'" |
508 | 512 | ) |
509 | | - assert INVALID_TARGET_DISEASE_CODE in diagnostics, ( |
510 | | - f"issue diagnostics should contain invalid target disease code '{INVALID_TARGET_DISEASE_CODE}', got '{diagnostics}'" |
| 513 | + assert invalid_target_disease_code is not None, ( |
| 514 | + "invalid target disease code was not set by the scenario step before assertion" |
| 515 | + ) |
| 516 | + assert invalid_target_disease_code in diagnostics, ( |
| 517 | + f"issue diagnostics should contain invalid target disease code '{invalid_target_disease_code}', got '{diagnostics}'" |
511 | 518 | ) |
512 | 519 |
|
513 | 520 |
|
|
0 commit comments