Skip to content

Commit ed0e8cf

Browse files
NPA-5357: Update formatting and API sandbox test
1 parent f33895f commit ed0e8cf

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
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,21 +10,24 @@
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",
@@ -42,6 +45,7 @@
4245
def test_post_questionnaire_response(
4346
mock_generate_response_from_example: MagicMock,
4447
nhs_num: str,
48+
id: str,
4549
response_file_name: str,
4650
status_code: int,
4751
client: object,
@@ -57,6 +61,15 @@ def test_post_questionnaire_response(
5761
# Act
5862
response = client.post(QUESTIONNAIRE_RESPONSE_API_ENDPOINT, json=json)
5963
# Assert
60-
mock_generate_response_from_example.assert_called_once_with(response_file_name, status_code)
64+
if id is not None:
65+
mock_generate_response_from_example.assert_called_once_with(
66+
response_file_name,
67+
status_code,
68+
headers={
69+
"location": f"{SANDBOX_API_URL}{QUESTIONNAIRE_RESPONSE_API_ENDPOINT}?ID={id}"
70+
},
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))

0 commit comments

Comments
 (0)