Skip to content

Commit 65de166

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

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-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: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,19 @@
1414

1515

1616
@pytest.mark.parametrize(
17-
("nhs_num", "response_file_name", "status_code"),
17+
("nhs_num", "response_file_name", "status_code", "id"),
1818
[
1919
(
2020
"9000000009",
2121
POST_QUESTIONNAIRE_RESPONSE__SUCCESS,
2222
200,
23+
"156e1560-e532-4e2a-85ad-5aeff03dc43e",
2324
),
2425
(
2526
"9000000017",
2627
POST_QUESTIONNAIRE_RESPONSE__SUCCESS,
2728
200,
29+
"156e1560-e532-4e2a-85ad-5aeff03dc43e",
2830
),
2931
(
3032
"9000000049",
@@ -42,6 +44,7 @@
4244
def test_post_questionnaire_response(
4345
mock_generate_response_from_example: MagicMock,
4446
nhs_num: str,
47+
id: str,
4548
response_file_name: str,
4649
status_code: int,
4750
client: object,
@@ -57,6 +60,15 @@ def test_post_questionnaire_response(
5760
# Act
5861
response = client.post(QUESTIONNAIRE_RESPONSE_API_ENDPOINT, json=json)
5962
# Assert
60-
mock_generate_response_from_example.assert_called_once_with(response_file_name, status_code)
63+
if id is not None:
64+
mock_generate_response_from_example.assert_called_once_with(
65+
response_file_name,
66+
status_code,
67+
headers={
68+
"location": f"https://sandbox.api.service.nhs.uk/validated-relationships/FHIR/R4/QuestionnaireResponse?ID={id}"
69+
},
70+
)
71+
else:
72+
mock_generate_response_from_example.assert_called_once_with(response_file_name, status_code)
6173
assert response.status_code == status_code
6274
assert response.json == loads(mocked_response.get_data(as_text=True))

0 commit comments

Comments
 (0)