Skip to content

Commit 0652739

Browse files
committed
refactor: formatting updated
1 parent 36f85b5 commit 0652739

File tree

3 files changed

+25
-29
lines changed

3 files changed

+25
-29
lines changed

sandbox/api/constants.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,11 @@
6666
CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP = (
6767
f"{CONSENT__DIRECTORY}single-consenting-adult-relationship.yaml"
6868
)
69-
CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP_INCLUDE_BOTH = (
70-
f"{CONSENT__DIRECTORY}single-consenting-adult-relationship-include-performer-patient.yaml"
71-
)
69+
CONSENT__SINGLE_CONSENTING_ADULT_RELATIONSHIP_INCLUDE_BOTH = f"{CONSENT__DIRECTORY}single-consenting-adult-relationship-include-performer-patient.yaml"
7270
CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP = (
7371
f"{CONSENT__DIRECTORY}single-mother-child-relationship.yaml"
7472
)
75-
CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_BOTH = (
76-
f"{CONSENT__DIRECTORY}single-mother-child-relationship-include-performer-patient.yaml"
73+
CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_BOTH = f"{CONSENT__DIRECTORY}single-mother-child-relationship-include-performer-patient.yaml"
74+
CONSENT__STATUS_PARAM_INVALID = (
75+
f"{CONSENT__DIRECTORY}errors/invalid-status-parameter.yaml"
7776
)
78-
CONSENT__STATUS_PARAM_INVALID = f"{CONSENT__DIRECTORY}errors/invalid-status-parameter.yaml"

sandbox/api/tests/test_utils.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,17 +163,17 @@ def test_get_response(mock_open: MagicMock) -> None:
163163
"request_args,response_file_name",
164164
[
165165
(
166-
"", # identifier is missing
166+
"", # identifier is missing
167167
"./api/responses/GET_RelatedPerson/bad_request_identifier_missing.json",
168168
),
169169
(
170-
"identifier=123456789", # identifier length is less than 10
170+
"identifier=123456789", # identifier length is less than 10
171171
"./api/responses/GET_RelatedPerson/bad_request_identifier_invalid.json",
172172
),
173173
(
174174
"identifier=https://fhir.nhs.uk/Id/nhs-number|A730675929", # identifier system invalid
175175
"./api/responses/GET_RelatedPerson/bad_request_identifier_invalid_system.json",
176-
)
176+
),
177177
],
178178
)
179179
@patch(f"{FILE_PATH}.load_json_file")
@@ -196,21 +196,21 @@ def test_check_for_related_person_errors(
196196
"request_args,response_file_name,status_code",
197197
[
198198
(
199-
"performer:identifier=90000009990", # Invalid performer identifier
199+
"performer:identifier=90000009990", # Invalid performer identifier
200200
"./api/examples/GET_Consent/errors/invalid-identifier.yaml",
201201
400,
202202
),
203203
(
204-
"", # missing performer identifier
204+
"", # missing performer identifier
205205
"./api/examples/GET_Consent/errors/missing-identifier.yaml",
206206
400,
207207
),
208208
(
209-
"performer:identifier=https://fhir.nhs.uk/Id/nhs-number|A730675929", # identifier system invalid
209+
"performer:identifier=https://fhir.nhs.uk/Id/nhs-number|A730675929", # identifier system invalid
210210
"./api/examples/GET_Consent/errors/invalid-identifier-system.yaml",
211211
400,
212212
),
213-
]
213+
],
214214
)
215215
@patch(f"{FILE_PATH}.generate_response_from_example")
216216
def test_check_for_consent_errors(

sandbox/api/utils.py

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,32 +42,32 @@ def check_for_related_person_errors(request: Request) -> Optional[tuple]:
4242
identifier_without_system = remove_system(request.args.get("identifier"))
4343

4444
if not identifier:
45-
return (
46-
generate_response(load_json_file(
45+
return generate_response(
46+
load_json_file(
4747
"./api/responses/GET_RelatedPerson/bad_request_identifier_missing.json"
4848
),
4949
400,
50-
))
50+
)
5151
elif identifier and len(identifier_without_system) != 10:
5252
# invalid identifier
53-
return (
54-
generate_response(load_json_file(
53+
return generate_response(
54+
load_json_file(
5555
"./api/responses/GET_RelatedPerson/bad_request_identifier_invalid.json"
5656
),
5757
400,
58-
))
58+
)
5959
elif (
6060
isinstance(identifier, str)
6161
and "|" in identifier
6262
and "https://fhir.nhs.uk/Id/nhs-number" == identifier.split("|", maxsplit=2)[0]
6363
):
6464
# invalid identifier system
65-
return (
66-
generate_response(load_json_file(
65+
return generate_response(
66+
load_json_file(
6767
"./api/responses/GET_RelatedPerson/bad_request_identifier_invalid_system.json"
6868
),
6969
400,
70-
))
70+
)
7171

7272

7373
def check_for_consent_errors(request: Request) -> Optional[tuple]:
@@ -287,22 +287,20 @@ def check_for_consent_filtering(
287287
"""
288288
if status == [] or status is None:
289289
return generate_response_from_example(INVALIDATED_RESOURCE, 404)
290-
if status == ["active"]:
290+
if status == ["active"]:
291291
if (
292292
len(_include) == 2
293293
and CONSENT_PERFORMER in _include
294294
and CONSENT_PERFORMER in _include
295295
):
296-
return generate_response_from_example(status_active_with_details_response_yaml, 200)
296+
return generate_response_from_example(
297+
status_active_with_details_response_yaml, 200
298+
)
297299
else:
298300
return generate_response_from_example(INVALIDATED_RESOURCE, 404)
299301
elif status == ["inactive"]:
300302
return generate_response_from_example(status_inactive_response_yaml, 200)
301-
elif (
302-
len(status) == 2
303-
and "active" in status
304-
and "proposed" in status
305-
):
303+
elif len(status) == 2 and "active" in status and "proposed" in status:
306304
return generate_response_from_example(
307305
status_proposed_and_active_response_yaml, 200
308306
)

0 commit comments

Comments
 (0)