Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions sandbox/src/routes/stu3/services/mockResponseProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,19 +166,24 @@ module.exports = {

getExampleResponseForRetrieveAttachment: function (request) {

const attachmentId = request.params.attachmentLogicalID
const attachmentId = request.params.attachmentLogicalID;

if (attachmentId) {

if (attachmentId.startsWith('att-')) {
return { responsePath: 'stu3/retrieveAttachment/responses/example_attachment.pdf', filename: 'example_attachment.pdf', responseCode: 200 }
return { responsePath: 'stu3/retrieveAttachment/responses/example_attachment.pdf', filename: 'example_attachment.pdf', responseCode: 200 };
}

if (attachmentId === 'c5d2d200-7613-4a69-9c5f-1bb68e04b8d8') {
return { responsePath: 'stu3/retrieveAttachment/responses/example_attachment.pdf', filename: 'example_attachment.pdf', responseCode: 200 }
if (this.isvalidUuid(attachmentId)) {
return { responsePath: 'stu3/retrieveAttachment/responses/example_attachment.pdf', filename: 'example_attachment.pdf', responseCode: 200 };
}
}

return {};
},

isvalidUuid: function(string) {
return /^[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i.test(string);
},

getExampleResponseForRetrieveReferralRequest: function (request) {
Expand Down
20 changes: 17 additions & 3 deletions tests/sandbox/stu3/test_a006_get_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ class TestGetAttachment(SandboxTest):
required_business_functions=allowed_business_function_data
)

testdata = [
valid_test_data = [
(
"att-70000-70001",
"stu3/retrieveAttachment/responses/example_attachment.pdf",
"example_attachment.pdf",
),
(
"c5d2d200-7613-4a69-9c5f-1bb68e04b8d8",
# Any arbitrary v4 UUID should work here
"f1b1b2b1-30db-48f9-8906-8b703adca5fb",
"stu3/retrieveAttachment/responses/example_attachment.pdf",
"example_attachment.pdf",
),
Expand Down Expand Up @@ -63,7 +64,7 @@ def call_endpoint(
)

@pytest.mark.parametrize("actor", authorised_actor_data)
@pytest.mark.parametrize("id,response, filename", testdata)
@pytest.mark.parametrize("id,response, filename", valid_test_data)
def test_success(
self,
call_endpoint_url_with_pathParams: Callable[
Expand All @@ -90,3 +91,16 @@ def test_success(
"content-length": str(len(expected_response)),
},
)

@pytest.mark.parametrize("actor", authorised_actor_data)
def test_failure_not_a_uuid(
self,
call_endpoint_url_with_pathParams: Callable[
[Actor, Dict[str, str], Dict[str, str]], Response
],
actor: Actor,
):
response = call_endpoint_url_with_pathParams(
actor, {"attachmentLogicalID": "f1bb2b1-30db-48f9-8906-8b703adca5fb"}
)
asserts.assert_status_code(404, response.status_code)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've noticed that this 404 should be a 422. This is caused by a bug that I've fixed in #1922 - path to files STU3-SandboxErrorOutcome.json and R4-SandboxErrorOutcome.json aren't correct for most files under routes/

Loading