Skip to content

Commit 906a5da

Browse files
NPA-5357: Update formatting and API sandbox test
1 parent 55d55af commit 906a5da

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

sandbox/api/post_questionnaire_response.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
)
1111
from .utils import generate_response_from_example
1212

13-
QUESTIONNAIRE_RESPONSE_APP_BASE_PATH = "https://sandbox.api.service.nhs.uk/validated-relationships/FHIR/R4/QuestionnaireResponse"
13+
QUESTIONNAIRE_RESPONSE_APP_BASE_PATH = (
14+
"https://sandbox.api.service.nhs.uk/validated-relationships/FHIR/R4/QuestionnaireResponse"
15+
)
1416
basicConfig(level=INFO, format="%(asctime)s - %(message)s")
1517
logger = getLogger(__name__)
1618

sandbox/api/tests/test_post_questionnaire_response.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,44 @@
1010
INTERNAL_SERVER_ERROR_EXAMPLE,
1111
)
1212

13+
SANDBOX_API_URL = "https://sandbox.api.service.nhs.uk/validated-relationships"
1314
QUESTIONNAIRE_RESPONSE_API_ENDPOINT = "/FHIR/R4/QuestionnaireResponse"
1415

1516

1617
@pytest.mark.parametrize(
17-
("nhs_num", "response_file_name", "status_code"),
18+
("nhs_num", "response_file_name", "status_code", "id"),
1819
[
1920
(
2021
"9000000009",
2122
POST_QUESTIONNAIRE_RESPONSE__SUCCESS,
2223
200,
24+
"156e1560-e532-4e2a-85ad-5aeff03dc43e",
2325
),
2426
(
2527
"9000000017",
2628
POST_QUESTIONNAIRE_RESPONSE__SUCCESS,
2729
200,
30+
"156e1560-e532-4e2a-85ad-5aeff03dc43e",
2831
),
2932
(
3033
"9000000049",
3134
POST_QUESTIONNAIRE_RESPONSE__DUPLICATE_RELATIONSHIP_ERROR,
3235
409,
36+
None,
3337
),
3438
(
3539
"INVALID_NHS_NUMBER",
3640
INTERNAL_SERVER_ERROR_EXAMPLE,
3741
500,
42+
None,
3843
),
3944
],
4045
)
4146
@patch("sandbox.api.post_questionnaire_response.generate_response_from_example")
4247
def test_post_questionnaire_response(
4348
mock_generate_response_from_example: MagicMock,
4449
nhs_num: str,
50+
id: str,
4551
response_file_name: str,
4652
status_code: int,
4753
client: object,
@@ -57,6 +63,13 @@ def test_post_questionnaire_response(
5763
# Act
5864
response = client.post(QUESTIONNAIRE_RESPONSE_API_ENDPOINT, json=json)
5965
# Assert
60-
mock_generate_response_from_example.assert_called_once_with(response_file_name, status_code)
66+
if id is not None:
67+
mock_generate_response_from_example.assert_called_once_with(
68+
response_file_name,
69+
status_code,
70+
headers={"location": f"{SANDBOX_API_URL}{QUESTIONNAIRE_RESPONSE_API_ENDPOINT}?ID={id}"},
71+
)
72+
else:
73+
mock_generate_response_from_example.assert_called_once_with(response_file_name, status_code)
6174
assert response.status_code == status_code
6275
assert response.json == loads(mocked_response.get_data(as_text=True))

specification/examples/responses/GET_QuestionnaireResponse/errors/questionnaire_response_not_found.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
QuestionnaireResponseNotFound:
22
summary: Questionnaire response not found
3-
description: The Questionnaire response could not be found using the provided access request UUID.
3+
description: The Questionnaire response could not be found using the provided access request ID.
44
value:
55
resourceType: "OperationOutcome"
66
issue:

specification/validated-relationships-service-api.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,11 +298,11 @@ paths:
298298
summary: Get a proxy access request
299299
description: |
300300
## Overview
301-
Retrieve a QuestionnaireResponse using its unique access request UUID. This endpoint returns the full
301+
Retrieve a QuestionnaireResponse using its unique access request ID. This endpoint returns the full
302302
QuestionnaireResponse document that was previously submitted.
303303
304304
## Request Requirements
305-
A valid access request UUID must be provided as a query parameter. This access request UUID is returned
305+
A valid access request ID must be provided as a query parameter. This access request ID is returned
306306
when a QuestionnaireResponse is initially submitted via the POST endpoint.
307307
308308
## Access modes

0 commit comments

Comments
 (0)