Skip to content

Commit 347907c

Browse files
committed
NPA-5534: sandbox reformat
1 parent 1cd60bd commit 347907c

15 files changed

+92
-221
lines changed

sandbox/api/constants.py

Lines changed: 45 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010

1111
# Common examples
1212
INTERNAL_SERVER_ERROR_EXAMPLE = "./api/examples/errors/internal-server-error.yaml"
13-
BAD_REQUEST_INCLUDE_PARAM_INVALID = (
14-
"./api/examples/errors/invalid-include-parameter.yaml"
15-
)
13+
BAD_REQUEST_INCLUDE_PARAM_INVALID = "./api/examples/errors/invalid-include-parameter.yaml"
1614
INVALIDATED_RESOURCE = "./api/examples/errors/invalidated-resource.yaml"
1715
MISSING_IDENTIFIER = "./api/examples/errors/missing-identifier.yaml"
1816
INVALID_IDENTIFIER = "./api/examples/errors/invalid-identifier.yaml"
@@ -29,9 +27,7 @@
2927
GET_CONSENT__FILTERED_RELATIONSHIPS_STATUS_PROPOSED_ACTIVE = (
3028
f"{GET_CONSENT__DIRECTORY}filtered-relationships-status-proposed-active.yaml"
3129
)
32-
GET_CONSENT__MULTIPLE_RELATIONSHIPS = (
33-
f"{GET_CONSENT__DIRECTORY}multiple-relationships.yaml"
34-
)
30+
GET_CONSENT__MULTIPLE_RELATIONSHIPS = f"{GET_CONSENT__DIRECTORY}multiple-relationships.yaml"
3531
GET_CONSENT__MULTIPLE_RELATIONSHIPS_INCLUDE_BOTH = (
3632
f"{GET_CONSENT__DIRECTORY}multiple-relationships-include-performer-patient.yaml"
3733
)
@@ -42,124 +38,88 @@
4238
f"{GET_CONSENT__DIRECTORY}multiple-relationships-include-performer.yaml"
4339
)
4440
GET_CONSENT__NO_RELATIONSHIPS = f"{GET_CONSENT__DIRECTORY}no-relationships.yaml"
45-
GET_CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP = (
46-
f"{GET_CONSENT__DIRECTORY}single-consenting-adult-relationship.yaml"
41+
GET_CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP = f"{GET_CONSENT__DIRECTORY}single-consenting-adult-relationship.yaml"
42+
GET_CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP_INCLUDE_BOTH = (
43+
f"{GET_CONSENT__DIRECTORY}single-consenting-adult-relationship-include-performer-patient.yaml"
4744
)
48-
GET_CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP_INCLUDE_BOTH = f"{GET_CONSENT__DIRECTORY}single-consenting-adult-relationship-include-performer-patient.yaml"
4945
GET_CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP_INCLUDE_PATIENT = (
5046
f"{GET_CONSENT__DIRECTORY}single-consenting-adult-relationship-include-patient.yaml"
5147
)
52-
GET_CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP_INCLUDE_PERFORMER = f"{GET_CONSENT__DIRECTORY}single-consenting-adult-relationship-include-performer.yaml"
53-
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP = (
54-
f"{GET_CONSENT__DIRECTORY}single-mother-child-relationship.yaml"
48+
GET_CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP_INCLUDE_PERFORMER = (
49+
f"{GET_CONSENT__DIRECTORY}single-consenting-adult-relationship-include-performer.yaml"
50+
)
51+
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP = f"{GET_CONSENT__DIRECTORY}single-mother-child-relationship.yaml"
52+
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_BOTH = (
53+
f"{GET_CONSENT__DIRECTORY}single-mother-child-relationship-include-performer-patient.yaml"
5554
)
56-
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_BOTH = f"{GET_CONSENT__DIRECTORY}single-mother-child-relationship-include-performer-patient.yaml"
5755
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_PATIENT = (
5856
f"{GET_CONSENT__DIRECTORY}single-mother-child-relationship-include-patient.yaml"
5957
)
6058
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_PERFORMER = (
6159
f"{GET_CONSENT__DIRECTORY}single-mother-child-relationship-include-performer.yaml"
6260
)
63-
GET_CONSENT__STATUS_PARAM_INVALID = (
64-
f"{GET_CONSENT__DIRECTORY}errors/invalid-status-parameter.yaml"
65-
)
61+
GET_CONSENT__STATUS_PARAM_INVALID = f"{GET_CONSENT__DIRECTORY}errors/invalid-status-parameter.yaml"
6662
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT = (
6763
f"{GET_CONSENT__DIRECTORY}multiple-relationships-single-patient.yaml"
6864
)
69-
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_PERFORMER = f"{GET_CONSENT__DIRECTORY}multiple-relationships-single-patient-include-performer.yaml"
70-
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_PATIENT = f"{GET_CONSENT__DIRECTORY}multiple-relationships-single-patient-include-patient.yaml"
71-
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_BOTH = f"{GET_CONSENT__DIRECTORY}multiple-relationships-single-patient-include-performer-patient.yaml"
65+
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_PERFORMER = (
66+
f"{GET_CONSENT__DIRECTORY}multiple-relationships-single-patient-include-performer.yaml"
67+
)
68+
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_PATIENT = (
69+
f"{GET_CONSENT__DIRECTORY}multiple-relationships-single-patient-include-patient.yaml"
70+
)
71+
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_BOTH = (
72+
f"{GET_CONSENT__DIRECTORY}multiple-relationships-single-patient-include-performer-patient.yaml"
73+
)
7274

7375
# GET Consent by ID
74-
GET_CONSENT_BY_ID__INVALID_ID_ERROR = (
75-
f"{GET_CONSENT__DIRECTORY}ID/errors/invalid-id.yaml"
76-
)
76+
GET_CONSENT_BY_ID__INVALID_ID_ERROR = f"{GET_CONSENT__DIRECTORY}ID/errors/invalid-id.yaml"
7777

7878
# POST Consent
7979
POST_CONSENT__DIRECTORY = "./api/examples/POST_Consent/"
8080
POST_CONSENT__SUCCESS = f"{POST_CONSENT__DIRECTORY}success.yaml"
81-
POST_CONSENT__DUPLICATE_RELATIONSHIP_ERROR = (
82-
f"{POST_CONSENT__DIRECTORY}errors/duplicate_relationship_error.yaml"
83-
)
84-
POST_CONSENT__PERFORMER_IDENTIFIER_ERROR = (
85-
f"{POST_CONSENT__DIRECTORY}errors/invalid_performer_identifier_error.yaml"
86-
)
81+
POST_CONSENT__DUPLICATE_RELATIONSHIP_ERROR = f"{POST_CONSENT__DIRECTORY}errors/duplicate_relationship_error.yaml"
82+
POST_CONSENT__PERFORMER_IDENTIFIER_ERROR = f"{POST_CONSENT__DIRECTORY}errors/invalid_performer_identifier_error.yaml"
8783

8884
# PATCH Consent
8985
PATCH_CONSENT__DIRECTORY = "./api/examples/PATCH_Consent/"
9086
PATCH_CONSENT__SUCCESS = f"{PATCH_CONSENT__DIRECTORY}success.yaml"
91-
PATCH_CONSENT__INVALID_PATCH_FORMAT = (
92-
f"{PATCH_CONSENT__DIRECTORY}errors/invalid_patch_format.yaml"
93-
)
87+
PATCH_CONSENT__INVALID_PATCH_FORMAT = f"{PATCH_CONSENT__DIRECTORY}errors/invalid_patch_format.yaml"
9488
PATCH_CONSENT__INVALID_PATH = f"{PATCH_CONSENT__DIRECTORY}errors/invalid_path.yaml"
95-
PATCH_CONSENT__INVALID_STATUS_CODE = (
96-
f"{PATCH_CONSENT__DIRECTORY}errors/invalid_status_code.yaml"
97-
)
98-
PATCH_CONSENT__INVALID_STATUS_REASON = (
99-
f"{PATCH_CONSENT__DIRECTORY}errors/invalid_status_reason.yaml"
100-
)
101-
PATCH_CONSENT__RESOURCE_NOT_FOUND = (
102-
f"{PATCH_CONSENT__DIRECTORY}errors/resource_not_found.yaml"
103-
)
104-
PATCH_CONSENT__INVALID_STATE_TRANSITION = (
105-
f"{PATCH_CONSENT__DIRECTORY}errors/invalid_state_transition.yaml"
106-
)
89+
PATCH_CONSENT__INVALID_STATUS_CODE = f"{PATCH_CONSENT__DIRECTORY}errors/invalid_status_code.yaml"
90+
PATCH_CONSENT__INVALID_STATUS_REASON = f"{PATCH_CONSENT__DIRECTORY}errors/invalid_status_reason.yaml"
91+
PATCH_CONSENT__RESOURCE_NOT_FOUND = f"{PATCH_CONSENT__DIRECTORY}errors/resource_not_found.yaml"
92+
PATCH_CONSENT__INVALID_STATE_TRANSITION = f"{PATCH_CONSENT__DIRECTORY}errors/invalid_state_transition.yaml"
10793

10894
# POST QuestionnaireResponse
10995
POST_QUESTIONNAIRE_RESPONSE_DIRECTORY = "./api/examples/POST_QuestionnaireResponse/"
110-
POST_QUESTIONNAIRE_RESPONSE__SUCCESS = (
111-
f"{POST_QUESTIONNAIRE_RESPONSE_DIRECTORY}success.yaml"
112-
)
96+
POST_QUESTIONNAIRE_RESPONSE__SUCCESS = f"{POST_QUESTIONNAIRE_RESPONSE_DIRECTORY}success.yaml"
11397
POST_QUESTIONNAIRE_RESPONSE__DUPLICATE_RELATIONSHIP_ERROR = (
11498
f"{POST_QUESTIONNAIRE_RESPONSE_DIRECTORY}errors/duplicate_relationship_error.yaml"
11599
)
116100

117101
# GET QuestionnaireResponse
118102
GET_QUESTIONNAIRE_RESPONSE_DIRECTORY = "./api/examples/GET_QuestionnaireResponse/"
119-
GET_QUESTIONNAIRE_RESPONSE__SUCCESS = (
120-
f"{GET_QUESTIONNAIRE_RESPONSE_DIRECTORY}success.yaml"
121-
)
122-
GET_QUESTIONNAIRE_RESPONSE__INVALID = (
123-
f"{GET_QUESTIONNAIRE_RESPONSE_DIRECTORY}errors/invalid_access_request_id.yaml"
124-
)
125-
GET_QUESTIONNAIRE_RESPONSE__MISSING = (
126-
f"{GET_QUESTIONNAIRE_RESPONSE_DIRECTORY}errors/missing_access_request_id.yaml"
103+
GET_QUESTIONNAIRE_RESPONSE__SUCCESS = f"{GET_QUESTIONNAIRE_RESPONSE_DIRECTORY}success.yaml"
104+
GET_QUESTIONNAIRE_RESPONSE__INVALID = f"{GET_QUESTIONNAIRE_RESPONSE_DIRECTORY}errors/invalid_access_request_id.yaml"
105+
GET_QUESTIONNAIRE_RESPONSE__MISSING = f"{GET_QUESTIONNAIRE_RESPONSE_DIRECTORY}errors/missing_access_request_id.yaml"
106+
GET_QUESTIONNAIRE_RESPONSE__NOT_FOUND = (
107+
f"{GET_QUESTIONNAIRE_RESPONSE_DIRECTORY}errors/questionnaire_response_not_found.yaml"
127108
)
128-
GET_QUESTIONNAIRE_RESPONSE__NOT_FOUND = f"{GET_QUESTIONNAIRE_RESPONSE_DIRECTORY}errors/questionnaire_response_not_found.yaml"
129109

130110
# GET RelatedPerson
131111
RELATED_DIRECTORY = "./api/examples/GET_RelatedPerson/"
132-
RELATED__ERROR_IDENTIFIER_MISSING = (
133-
f"{RELATED_DIRECTORY}errors/invalid-identifier-missing.yaml"
134-
)
135-
RELATED__ERROR_IDENTIFIER_SYSTEM = (
136-
f"{RELATED_DIRECTORY}errors/invalid-identifier-system.yaml"
137-
)
112+
RELATED__ERROR_IDENTIFIER_MISSING = f"{RELATED_DIRECTORY}errors/invalid-identifier-missing.yaml"
113+
RELATED__ERROR_IDENTIFIER_SYSTEM = f"{RELATED_DIRECTORY}errors/invalid-identifier-system.yaml"
138114
RELATED__ERROR_IDENTIFIER = f"{RELATED_DIRECTORY}errors/invalid-identifier.yaml"
139-
RELATED__ERROR_PATIENT_IDENTIFIER = (
140-
f"{RELATED_DIRECTORY}errors/invalid-patient-identifier.yaml"
141-
)
115+
RELATED__ERROR_PATIENT_IDENTIFIER = f"{RELATED_DIRECTORY}errors/invalid-patient-identifier.yaml"
142116
RELATED__EMPTY_RESPONSE = f"{RELATED_DIRECTORY}empty_response.yaml"
143117
RELATED__LIST_RELATIONSHIP = f"{RELATED_DIRECTORY}list_relationship_9000000017.yaml"
144-
RELATED__LIST_RELATIONSHIP_WITH_INCLUDE = (
145-
f"{RELATED_DIRECTORY}list_relationship_9000000017_include.yaml"
146-
)
147-
RELATED__LIST_CHILD_RELATIONSHIP = (
148-
f"{RELATED_DIRECTORY}list_relationship_9000000042.yaml"
149-
)
150-
RELATED__LIST_CHILD_RELATIONSHIP_WITH_INCLUDE = (
151-
f"{RELATED_DIRECTORY}list_relationship_9000000042_include.yaml"
152-
)
153-
RELATED__VERIFY_RELATIONSHIP_09 = (
154-
f"{RELATED_DIRECTORY}verify_relationship_9000000009.yaml"
155-
)
156-
RELATED__VERIFY_RELATIONSHIP_09_WITH_INCLUDE = (
157-
f"{RELATED_DIRECTORY}verify_relationship_9000000009_include.yaml"
158-
)
159-
RELATED__VERIFY_RELATIONSHIP_25 = (
160-
f"{RELATED_DIRECTORY}verify_relationship_9000000025.yaml"
161-
)
162-
RELATED__VERIFY_RELATIONSHIP_25_WITH_INCLUDE = (
163-
f"{RELATED_DIRECTORY}verify_relationship_9000000025_include.yaml"
164-
)
118+
RELATED__LIST_RELATIONSHIP_WITH_INCLUDE = f"{RELATED_DIRECTORY}list_relationship_9000000017_include.yaml"
119+
RELATED__LIST_CHILD_RELATIONSHIP = f"{RELATED_DIRECTORY}list_relationship_9000000042.yaml"
120+
RELATED__LIST_CHILD_RELATIONSHIP_WITH_INCLUDE = f"{RELATED_DIRECTORY}list_relationship_9000000042_include.yaml"
121+
RELATED__VERIFY_RELATIONSHIP_09 = f"{RELATED_DIRECTORY}verify_relationship_9000000009.yaml"
122+
RELATED__VERIFY_RELATIONSHIP_09_WITH_INCLUDE = f"{RELATED_DIRECTORY}verify_relationship_9000000009_include.yaml"
123+
RELATED__VERIFY_RELATIONSHIP_25 = f"{RELATED_DIRECTORY}verify_relationship_9000000025.yaml"
124+
RELATED__VERIFY_RELATIONSHIP_25_WITH_INCLUDE = f"{RELATED_DIRECTORY}verify_relationship_9000000025_include.yaml"
165125
RELATED__EMPTY_RESPONSE = f"{RELATED_DIRECTORY}empty_response_9000000033.yaml"

sandbox/api/get_consent_by_id.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ def get_consent_by_id_response(identifier: str) -> Union[dict, tuple]:
3131
try:
3232
params = request.args.to_dict()
3333
if "_include" not in params and len(params) > 0:
34-
return generate_response_from_example(
35-
BAD_REQUEST_INCLUDE_PARAM_INVALID, 422
36-
)
34+
return generate_response_from_example(BAD_REQUEST_INCLUDE_PARAM_INVALID, 422)
3735
else:
3836
_include = request.args.getlist("_include")
3937

@@ -56,9 +54,7 @@ def get_consent_by_id_response(identifier: str) -> Union[dict, tuple]:
5654
elif identifier == "a0922245-1072-40c3-8f4e-a7490c10d365":
5755
return generate_response_from_example(INVALIDATED_RESOURCE, 404)
5856
else:
59-
return generate_response_from_example(
60-
GET_CONSENT_BY_ID__INVALID_ID_ERROR, 400
61-
)
57+
return generate_response_from_example(GET_CONSENT_BY_ID__INVALID_ID_ERROR, 400)
6258

6359
except Exception:
6460
logger.exception("An error occurred while processing the request")

sandbox/api/get_questionnaire_response.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,13 @@ def get_questionnaire_response_response(access_request_id: str) -> Union[dict, t
2424
"""
2525
try:
2626
if access_request_id == "156e1560-e532-4e2a-85ad-5aeff03dc43e":
27-
return generate_response_from_example(
28-
GET_QUESTIONNAIRE_RESPONSE__SUCCESS, 200
29-
)
27+
return generate_response_from_example(GET_QUESTIONNAIRE_RESPONSE__SUCCESS, 200)
3028
elif access_request_id == "INVALID":
31-
return generate_response_from_example(
32-
GET_QUESTIONNAIRE_RESPONSE__INVALID, 400
33-
)
29+
return generate_response_from_example(GET_QUESTIONNAIRE_RESPONSE__INVALID, 400)
3430
elif access_request_id == "" or access_request_id is None:
3531
return generate_response_from_example(METHOD_NOT_ALLOWED, 405)
3632
elif access_request_id == "60d09b82-f4bb-41f9-b41e-767999b4ac9b":
37-
return generate_response_from_example(
38-
GET_QUESTIONNAIRE_RESPONSE__NOT_FOUND, 404
39-
)
33+
return generate_response_from_example(GET_QUESTIONNAIRE_RESPONSE__NOT_FOUND, 404)
4034
else:
4135
raise ValueError("Invalid access request ID")
4236
except Exception:

sandbox/api/patch_consent.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,37 +45,27 @@ def patch_consent_response(id: str) -> Union[dict, tuple]:
4545

4646
elif id == "849ea584-2318-471b-a24c-cee1b5ad0137":
4747
# Invalid patch format
48-
return generate_response_from_example(
49-
PATCH_CONSENT__INVALID_PATCH_FORMAT, 400
50-
)
48+
return generate_response_from_example(PATCH_CONSENT__INVALID_PATCH_FORMAT, 400)
5149

5250
elif id == "01abb0c5-b1ac-499d-9655-9cd0b8d3588f":
5351
# Invalid path
5452
return generate_response_from_example(PATCH_CONSENT__INVALID_PATH, 400)
5553

5654
elif id == "78c35330-fa2f-4934-a5dd-fff847f38de5":
5755
# Invalid status code
58-
return generate_response_from_example(
59-
PATCH_CONSENT__INVALID_STATUS_CODE, 422
60-
)
56+
return generate_response_from_example(PATCH_CONSENT__INVALID_STATUS_CODE, 422)
6157

6258
elif id == "51fb4df5-815a-45cd-8427-04d6558336b7":
6359
# Invalid status reason
64-
return generate_response_from_example(
65-
PATCH_CONSENT__INVALID_STATUS_REASON, 422
66-
)
60+
return generate_response_from_example(PATCH_CONSENT__INVALID_STATUS_REASON, 422)
6761

6862
elif id == "7b7f47b8-96e5-43eb-b733-283bf1449f2c":
6963
# Invalid state transition
70-
return generate_response_from_example(
71-
PATCH_CONSENT__INVALID_STATE_TRANSITION, 422
72-
)
64+
return generate_response_from_example(PATCH_CONSENT__INVALID_STATE_TRANSITION, 422)
7365

7466
else:
7567
# Resource not found
76-
return generate_response_from_example(
77-
PATCH_CONSENT__RESOURCE_NOT_FOUND, 404
78-
)
68+
return generate_response_from_example(PATCH_CONSENT__RESOURCE_NOT_FOUND, 404)
7969

8070
except Exception:
8171
# Handle any general error

sandbox/api/post_consent.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
)
1212
from .utils import generate_response_from_example
1313

14-
CONSENT_APP_BASE_PATH = (
15-
"https://sandbox.api.service.nhs.uk/validated-relationships/FHIR/R4/Consent"
16-
)
14+
CONSENT_APP_BASE_PATH = "https://sandbox.api.service.nhs.uk/validated-relationships/FHIR/R4/Consent"
1715
basicConfig(level=INFO, format="%(asctime)s - %(message)s")
1816
logger = getLogger(__name__)
1917

@@ -34,23 +32,15 @@ def post_consent_response() -> Union[dict, tuple]:
3432
# Successful parent-child proxy creation
3533
# Successful adult-adult proxy creation
3634
if patient_identifier == "9000000009" or patient_identifier == "9000000017":
37-
header = {
38-
"location": f"{CONSENT_APP_BASE_PATH}/90b9863e-e33c-4895-a333-fd0ea0e23205"
39-
}
40-
response = generate_response_from_example(
41-
POST_CONSENT__SUCCESS, 201, headers=header
42-
)
35+
header = {"location": f"{CONSENT_APP_BASE_PATH}/90b9863e-e33c-4895-a333-fd0ea0e23205"}
36+
response = generate_response_from_example(POST_CONSENT__SUCCESS, 201, headers=header)
4337

4438
# Duplicate relationship
4539
elif patient_identifier == "9000000049":
46-
response = generate_response_from_example(
47-
POST_CONSENT__DUPLICATE_RELATIONSHIP_ERROR, 409
48-
)
40+
response = generate_response_from_example(POST_CONSENT__DUPLICATE_RELATIONSHIP_ERROR, 409)
4941
# Invalid performer NHS number
5042
elif patient_identifier == "9000000000":
51-
response = generate_response_from_example(
52-
POST_CONSENT__PERFORMER_IDENTIFIER_ERROR, 422
53-
)
43+
response = generate_response_from_example(POST_CONSENT__PERFORMER_IDENTIFIER_ERROR, 422)
5444
else:
5545
# Out of scope errors
5646
raise ValueError("Invalid Request")

sandbox/api/post_questionnaire_response.py

Lines changed: 6 additions & 10 deletions
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

@@ -30,17 +32,11 @@ def post_questionnaire_response_response() -> Union[dict, tuple]:
3032

3133
# Successful questionnaire response
3234
if source_identifier in ["9000000009", "9000000017"]:
33-
header = {
34-
"location": f"{QUESTIONNAIRE_RESPONSE_APP_BASE_PATH}?ID=156e1560-e532-4e2a-85ad-5aeff03dc43e"
35-
}
36-
response = generate_response_from_example(
37-
POST_QUESTIONNAIRE_RESPONSE__SUCCESS, 200, headers=header
38-
)
35+
header = {"location": f"{QUESTIONNAIRE_RESPONSE_APP_BASE_PATH}?ID=156e1560-e532-4e2a-85ad-5aeff03dc43e"}
36+
response = generate_response_from_example(POST_QUESTIONNAIRE_RESPONSE__SUCCESS, 200, headers=header)
3937
# Duplicate relationship
4038
elif source_identifier == "9000000049":
41-
response = generate_response_from_example(
42-
POST_QUESTIONNAIRE_RESPONSE__DUPLICATE_RELATIONSHIP_ERROR, 409
43-
)
39+
response = generate_response_from_example(POST_QUESTIONNAIRE_RESPONSE__DUPLICATE_RELATIONSHIP_ERROR, 409)
4440
else:
4541
# Out of scope errors
4642
raise ValueError("Invalid Request")

sandbox/api/tests/test_get_consent.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ def test_get_consent_returns_expected_responses__mocked_get_consent(
4040
# Act
4141
response = client.get(f"{CONSENT_API_ENDPOINT}?{request_args}")
4242
# Assert
43-
mock_generate_response_from_example.assert_called_once_with(
44-
response_file_name, status_code
45-
)
43+
mock_generate_response_from_example.assert_called_once_with(response_file_name, status_code)
4644
assert response.status_code == status_code
4745
assert response.json == loads(mocked_response.get_data(as_text=True))
4846

@@ -214,9 +212,7 @@ def test_get_consent_returns_expected_responses__mocked_utils(
214212
# Act
215213
response = client.get(f"{CONSENT_API_ENDPOINT}?{request_args}")
216214
# Assert
217-
mock_generate_response_from_example.assert_called_once_with(
218-
response_file_name, status_code
219-
)
215+
mock_generate_response_from_example.assert_called_once_with(response_file_name, status_code)
220216
assert response.status_code == status_code
221217
assert response.json == loads(mocked_response.get_data(as_text=True))
222218

@@ -231,10 +227,6 @@ def test_get_consent__500_internal_server_error(
231227
"""Test Consent endpoint."""
232228
mock_remove_system.side_effect = Exception("Test exception")
233229
# Act
234-
client.get(
235-
f"{CONSENT_API_ENDPOINT}?performer:identifier=9000000015&status=active&_include=Consent:performer"
236-
)
230+
client.get(f"{CONSENT_API_ENDPOINT}?performer:identifier=9000000015&status=active&_include=Consent:performer")
237231
# Assert
238-
mock_generate_response_from_example.assert_called_once_with(
239-
"./api/examples/errors/internal-server-error.yaml", 500
240-
)
232+
mock_generate_response_from_example.assert_called_once_with("./api/examples/errors/internal-server-error.yaml", 500)

0 commit comments

Comments
 (0)