Skip to content

Commit 70ac859

Browse files
committed
npa-5087 - Updated sandbox
1 parent 7004d12 commit 70ac859

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

sandbox/api/get_consent_by_id.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from logging import INFO, basicConfig, getLogger
1+
from logging import getLogger
22
from typing import Union
33

44
from flask import request
@@ -16,21 +16,28 @@
1616
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_PATIENT,
1717
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_PERFORMER,
1818
GET_CONSENT_BY_ID__INVALID_ID_ERROR,
19-
GET_CONSENT_BY_ID__MISSING_ID_ERROR
19+
GET_CONSENT_BY_ID__MISSING_ID_ERROR,
20+
BAD_REQUEST_INCLUDE_PARAM_INVALID,
21+
INVALIDATED_RESOURCE
2022
)
2123
from .utils import (
2224
generate_response_from_example,
2325
check_for_consent_include_params
2426
)
2527

28+
2629
def get_consent_by_id_response(identifier: str) -> Union[dict, tuple]:
2730
"""Sandbox API for GET /Consent/{id}
2831
2932
Returns:
3033
Union[dict, tuple]: Response for GET /Consent/{id}
3134
"""
3235
try:
33-
_include = request.args.getlist("_include")
36+
params = request.args.to_dict()
37+
if not "_include" in params and len(params) > 0:
38+
return generate_response_from_example(BAD_REQUEST_INCLUDE_PARAM_INVALID, 422)
39+
else:
40+
_include = request.args.getlist("_include")
3441

3542
if identifier == "74eed847-ca25-4e76-8cf2-f2c2d7842a7a":
3643
return check_for_consent_include_params(
@@ -48,6 +55,8 @@ def get_consent_by_id_response(identifier: str) -> Union[dict, tuple]:
4855
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_PATIENT,
4956
GET_CONSENT__SINGLE_MOTHER_CHILD_RELATIONSHIP_INCLUDE_PERFORMER
5057
)
58+
elif identifier == "a0922245-1072-40c3-8f4e-a7490c10d365":
59+
return generate_response_from_example(INVALIDATED_RESOURCE, 404)
5160
elif identifier == " " or identifier is None:
5261
return generate_response_from_example(GET_CONSENT_BY_ID__MISSING_ID_ERROR, 400)
5362
else:

sandbox/api/tests/test_get_consent_by_id.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
),
3838
],
3939
)
40-
@patch("sandbox.api.get_consent_by_id.generate_response_from_example")
40+
@patch(f"{GET_CONSENT_BY_ID_FILE_PATH}.generate_response_from_example")
4141
def test_get_consent_by_id_returns_expected_responses__mocked_get_consent_by_id(
4242
mock_generate_response_from_example: MagicMock,
4343
consent_id: str,

0 commit comments

Comments
 (0)