Skip to content

Commit 58e7c82

Browse files
NPA-5088: Update sandbox so consent ids are UUID
1 parent a350e1e commit 58e7c82

File tree

4 files changed

+28
-26
lines changed

4 files changed

+28
-26
lines changed

sandbox/api/patch_consent.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,38 +31,38 @@ def patch_consent_response(identifier: str) -> Union[dict, tuple]:
3131
# Validate body - validation is beyond the scope of the sandbox.
3232
# Assume all requests are valid
3333

34-
if identifier == "c6f48e4d":
34+
if identifier == "c512b0db-6702-43ee-8c21-bbded2552da9":
3535
# Successful status update
3636
return generate_response_from_example(PATCH_CONSENT__SUCCESS, 200)
3737

38-
elif identifier == "0c56a594":
38+
elif identifier == "6b71ac92-baa3-4b76-b0f5-a601257e2722":
3939
# Successful end date for a role
4040
return generate_response_from_example(PATCH_CONSENT__SUCCESS, 200)
4141

42-
elif identifier == "b02ea26c":
42+
elif identifier == "43003db8-ffcd-4bd6-ab2f-b49b9656f9e5":
4343
# Multiple valid changes
4444
return generate_response_from_example(PATCH_CONSENT__SUCCESS, 200)
4545

46-
elif identifier == "3a2679eb":
46+
elif identifier == "849ea584-2318-471b-a24c-cee1b5ad0137":
4747
# Invalid patch format
4848
return generate_response_from_example(PATCH_CONSENT__INVALID_PATCH_FORMAT, 400)
4949

50-
elif identifier == "94df7c8f":
50+
elif identifier == "01abb0c5-b1ac-499d-9655-9cd0b8d3588f":
5151
# Invalid path
5252
return generate_response_from_example(PATCH_CONSENT__INVALID_PATH, 400)
5353

54-
elif identifier == "2a7b736d":
54+
elif identifier == "78c35330-fa2f-4934-a5dd-fff847f38de5":
5555
# Invalid status code
5656
return generate_response_from_example(PATCH_CONSENT__INVALID_STATUS_CODE, 422)
5757

58-
elif identifier == "6fb4361b":
59-
# Invalid state transition
60-
return generate_response_from_example(PATCH_CONSENT__INVALID_STATE_TRANSITION, 422)
61-
62-
elif identifier == "4b6792be":
58+
elif identifier == "51fb4df5-815a-45cd-8427-04d6558336b7":
6359
# Invalid status reason
6460
return generate_response_from_example(PATCH_CONSENT__INVALID_STATUS_REASON, 422)
6561

62+
elif identifier == "7b7f47b8-96e5-43eb-b733-283bf1449f2c":
63+
# Invalid state transition
64+
return generate_response_from_example(PATCH_CONSENT__INVALID_STATE_TRANSITION, 422)
65+
6666
else:
6767
# Resource not found
6868
return generate_response_from_example(PATCH_CONSENT__RESOURCE_NOT_FOUND, 404)

sandbox/api/post_consent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def post_consent_response() -> Union[dict, tuple]:
3232
# Successful parent-child proxy creation
3333
# Successful adult-adult proxy creation
3434
if patient_identifier == "9000000009" or patient_identifier == "9000000017":
35-
header = {"location": f"{CONSENT_APP_BASE_PATH}/{patient_identifier}"}
35+
header = {"location": f"{CONSENT_APP_BASE_PATH}/90b9863e-e33c-4895-a333-fd0ea0e23205"}
3636
response = generate_response_from_example(POST_CONSENT__SUCCESS, 201, headers=header)
3737

3838
# Duplicate relationship

sandbox/api/tests/test_patch_consent.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
@pytest.mark.parametrize(
2121
("nhs_num", "response_file_name", "status_code"),
2222
[
23-
("c6f48e4d", PATCH_CONSENT__SUCCESS, 200),
24-
("0c56a594", PATCH_CONSENT__SUCCESS, 200),
25-
("b02ea26c", PATCH_CONSENT__SUCCESS, 200),
26-
("3a2679eb", PATCH_CONSENT__INVALID_PATCH_FORMAT, 400),
27-
("94df7c8f", PATCH_CONSENT__INVALID_PATH, 400),
28-
("2a7b736d", PATCH_CONSENT__INVALID_STATUS_CODE, 422),
29-
("4b6792be", PATCH_CONSENT__INVALID_STATUS_REASON, 422),
30-
("6fb4361b", PATCH_CONSENT__INVALID_STATE_TRANSITION, 422),
23+
("c512b0db-6702-43ee-8c21-bbded2552da9", PATCH_CONSENT__SUCCESS, 200),
24+
("6b71ac92-baa3-4b76-b0f5-a601257e2722", PATCH_CONSENT__SUCCESS, 200),
25+
("43003db8-ffcd-4bd6-ab2f-b49b9656f9e5", PATCH_CONSENT__SUCCESS, 200),
26+
("849ea584-2318-471b-a24c-cee1b5ad0137", PATCH_CONSENT__INVALID_PATCH_FORMAT, 400),
27+
("01abb0c5-b1ac-499d-9655-9cd0b8d3588f", PATCH_CONSENT__INVALID_PATH, 400),
28+
("78c35330-fa2f-4934-a5dd-fff847f38de5", PATCH_CONSENT__INVALID_STATUS_CODE, 422),
29+
("51fb4df5-815a-45cd-8427-04d6558336b7", PATCH_CONSENT__INVALID_STATUS_REASON, 422),
30+
("7b7f47b8-96e5-43eb-b733-283bf1449f2c", PATCH_CONSENT__INVALID_STATE_TRANSITION, 422),
3131
("xxxxxxxx", PATCH_CONSENT__RESOURCE_NOT_FOUND, 404),
3232
("12345678", PATCH_CONSENT__RESOURCE_NOT_FOUND, 404),
3333
],

sandbox/api/tests/test_post_consent.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@
1414

1515

1616
@pytest.mark.parametrize(
17-
("nhs_num", "response_file_name", "status_code", "location"),
17+
("nhs_num", "response_file_name", "status_code", "id"),
1818
[
1919
(
2020
"9000000009",
2121
POST_CONSENT__SUCCESS,
2222
201,
23-
"https://sandbox.api.service.nhs.uk/validated-relationships/FHIR/R4/Consent/9000000009",
23+
"90b9863e-e33c-4895-a333-fd0ea0e23205",
2424
),
2525
(
2626
"9000000017",
2727
POST_CONSENT__SUCCESS,
2828
201,
29-
"https://sandbox.api.service.nhs.uk/validated-relationships/FHIR/R4/Consent/9000000017",
29+
"90b9863e-e33c-4895-a333-fd0ea0e23205",
3030
),
3131
("9000000000", POST_CONSENT__PERFORMER_IDENTIFIER_ERROR, 422, None),
3232
("9000000049", POST_CONSENT__DUPLICATE_RELATIONSHIP_ERROR, 409, None),
@@ -37,7 +37,7 @@ def test_post_consent_when_valid_returns_expected_response(
3737
mock_generate_response_from_example: MagicMock,
3838
response_file_name: str,
3939
nhs_num: str,
40-
location: str,
40+
id: str,
4141
client: object,
4242
status_code: int,
4343
) -> None:
@@ -51,9 +51,11 @@ def test_post_consent_when_valid_returns_expected_response(
5151
json = {"performer": [{"identifier": {"value": nhs_num}}]}
5252
response = client.post(CONSENT_API_ENDPOINT, json=json)
5353
# Assert
54-
if location is not None:
54+
if id is not None:
5555
mock_generate_response_from_example.assert_called_once_with(
56-
response_file_name, status_code, headers={"location": location}
56+
response_file_name,
57+
status_code,
58+
headers={"location": f"https://sandbox.api.service.nhs.uk/validated-relationships/FHIR/R4/Consent/{id}"},
5759
)
5860
else:
5961
mock_generate_response_from_example.assert_called_once_with(response_file_name, status_code)

0 commit comments

Comments
 (0)