Skip to content

Commit 8322c3f

Browse files
NPA-4831: Updated sandbox to account for new includes scenarios
1 parent 6068b87 commit 8322c3f

File tree

4 files changed

+30
-7
lines changed

4 files changed

+30
-7
lines changed

sandbox/api/constants.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@
4949
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT = (
5050
f"{GET_CONSENT__DIRECTORY}multiple-relationships-single-patient.yaml"
5151
)
52+
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_PATIENT = (
53+
f"{GET_CONSENT__DIRECTORY}multiple-relationships-single-patient-include-patient.yaml"
54+
)
55+
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_BOTH = (
56+
f"{GET_CONSENT__DIRECTORY}multiple-relationships-single-patient-include-performer-patient.yaml"
57+
)
5258
# POST Consent
5359
POST_CONSENT__DIRECTORY = "./api/examples/POST_Consent/"
5460
POST_CONSENT__SUCCESS = f"{POST_CONSENT__DIRECTORY}success.yaml"

sandbox/api/get_consent.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
GET_CONSENT__FILTERED_RELATIONSHIPS_STATUS_INACTIVE,
99
GET_CONSENT__FILTERED_RELATIONSHIPS_STATUS_PROPOSED_ACTIVE,
1010
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT,
11+
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_PATIENT,
12+
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_BOTH,
1113
GET_CONSENT__MULTIPLE_RELATIONSHIPS,
1214
GET_CONSENT__MULTIPLE_RELATIONSHIPS_INCLUDE_BOTH,
1315
GET_CONSENT__MULTIPLE_RELATIONSHIPS_INCLUDE_PATIENT,
@@ -63,7 +65,12 @@ def get_consent_response() -> Union[dict, tuple]:
6365
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_BOTH,
6466
)
6567
elif patient_identifier == "9000000100":
66-
return generate_response_from_example(GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT, 200)
68+
return check_for_consent_include_params(
69+
_include,
70+
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT,
71+
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_BOTH,
72+
GET_CONSENT__MULTIPLE_RELATIONSHIPS_SINGLE_PATIENT_INCLUDE_PATIENT,
73+
)
6774
# Filtering
6875
elif performer_identifier == "9000000017":
6976
return check_for_consent_filtering(

sandbox/api/tests/test_get_consent.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@
2121
"./api/examples/errors/invalidated-resource.yaml",
2222
404,
2323
),
24-
(
25-
"patient:identifier=9000000100", # Multiple relationships single patient
26-
"./api/examples/GET_Consent/multiple-relationships-single-patient.yaml",
27-
200,
28-
),
2924
],
3025
)
3126
@patch("sandbox.api.get_consent.generate_response_from_example")
@@ -153,6 +148,21 @@ def test_get_consent_returns_expected_responses__mocked_get_consent(
153148
"./api/examples/GET_Consent/single-mother-child-relationship-include-performer-patient.yaml",
154149
200,
155150
),
151+
(
152+
"patient:identifier=9000000100", # Multiple relationships single patient
153+
"./api/examples/GET_Consent/multiple-relationships-single-patient.yaml",
154+
200,
155+
),
156+
(
157+
"patient:identifier=9000000100&_include=Consent:patient",
158+
"./api/examples/GET_Consent/multiple-relationships-single-patient-include-patient.yaml",
159+
200,
160+
),
161+
(
162+
"patient:identifier=9000000100&_include=Consent:performer&_include=Consent:patient",
163+
"./api/examples/GET_Consent/multiple-relationships-single-patient-include-performer-patient.yaml",
164+
200,
165+
),
156166
(
157167
"performer:identifier=9000000017&status=test", # Invalid status parameter error
158168
"./api/examples/GET_Consent/errors/invalid-status-parameter.yaml",

sandbox/api/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def check_for_consent_include_params(
248248
logger.error("No consent performer example provided")
249249
return generate_response_from_example(INTERNAL_SERVER_ERROR_EXAMPLE, 500)
250250
elif _include == [CONSENT_PATIENT]:
251-
if include_performer_response_yaml:
251+
if include_patient_response_yaml:
252252
return generate_response_from_example(include_patient_response_yaml, 200)
253253
else:
254254
logger.error("No consent:patient example provided")

0 commit comments

Comments
 (0)