Skip to content

Commit a3ee54e

Browse files
committed
add validator tests
1 parent 800b280 commit a3ee54e

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed

features/eps_fhir/validate.feature

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@eps_fhir @smoke @regression @ping @blocker
2+
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4895
3+
Feature: I can call the validator endpoint
4+
5+
Scenario: I can call the validator endpoint with valid fhir with x-show-validation-warnings set to false
6+
Given I am an authorised prescriber
7+
When I make a request to the eps_fhir validator endpoint
8+
Then the response indicates a success
9+
And the validator response has 1 information issue
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@eps_fhir @smoke @regression @ping @blocker
2+
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4895
3+
Feature: I can call the validator endpoint
4+
5+
Scenario: I can call the validator endpoint with valid fhir with x-show-validation-warnings set to false
6+
Given I am an authorised dispenser
7+
When I make a request to the eps_fhir_dispensing validator endpoint
8+
Then the response indicates a success
9+
And the validator response has 1 information issue
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@eps_fhir @smoke @regression @ping @blocker
2+
@allure.tms:https://nhsd-jira.digital.nhs.uk/browse/AEA-4895
3+
Feature: I can call the validator endpoint
4+
5+
Scenario: I can call the validator endpoint with valid fhir with x-show-validation-warnings set to false
6+
Given I am an authorised prescriber
7+
When I make a request to the eps_fhir_prescribing validator endpoint
8+
Then the response indicates a success
9+
And the validator response has 1 information issue

features/steps/eps_api_steps.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@
1212
release_signed_prescription,
1313
return_prescription,
1414
withdraw_dispense_notification,
15+
get_headers,
16+
post,
1517
)
1618
from methods.shared.common import assert_that, get_auth
1719
from utils.random_nhs_number_generator import generate_single
20+
from messages.eps_fhir.prescription import Prescription
1821

1922

2023
@given("I successfully prepare and sign a prescription")
@@ -166,3 +169,31 @@ def i_can_see_an_informational_operation_outcome_in_the_response(context):
166169
assert_that(json_response["resourceType"]).is_equal_to("OperationOutcome")
167170
assert_that(json_response["issue"][0]["code"]).is_equal_to("informational")
168171
assert_that(json_response["issue"][0]["severity"]).is_equal_to("information")
172+
173+
174+
@when("I make a request to the {product} validator endpoint")
175+
def i_make_a_request_to_the_validator_endpoint(context, product):
176+
base_url = None
177+
if product == "eps_fhir":
178+
base_url = context.eps_fhir_base_url
179+
if product == "eps_fhir_prescribing":
180+
base_url = context.eps_fhir_prescribing_base_url
181+
if product == "eps_fhir_dispensing":
182+
base_url = context.eps_fhir_dispensing_base_url
183+
if base_url is not None:
184+
url = f"{base_url}/FHIR/R4/$validate"
185+
additional_headers = {"Content-Type": "application/json"}
186+
headers = get_headers(context, additional_headers)
187+
188+
context.prepare_body = Prescription(context).body
189+
post(data=context.prepare_body, url=url, context=context, headers=headers)
190+
else:
191+
raise ValueError(f"unable to find base url for '{product}'")
192+
193+
194+
@then("the validator response has {issue_count} {issue_type} issue")
195+
def validator_response_has_n_issues_of_type(context, issue_count, issue_type):
196+
json_response = json.loads(context.response.content)
197+
assert_that(json_response["resourceType"]).is_equal_to("OperationOutcome")
198+
assert_that(json_response["issue"][0]["code"]).is_equal_to("informational")
199+
assert_that(json_response["issue"][0]["severity"]).is_equal_to("information")

0 commit comments

Comments
 (0)