Skip to content
Merged
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
1 change: 1 addition & 0 deletions src/eligibility_signposting_api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def lambda_handler(event: LambdaEvent, context: LambdaContext) -> dict[str, Any]
app = create_app()
app.debug = config()["log_level"] == logging.DEBUG
handler = Mangum(WsgiToAsgi(app), lifespan="off")
handler.config["text_mime_types"].append("application/fhir+json")
return handler(event, context)


Expand Down
49 changes: 23 additions & 26 deletions tests/integration/lambda/test_app_running_as_lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,37 +124,34 @@ def test_install_and_call_flask_lambda_with_unknown_nhs_number(
timeout=10,
)

decoded_body_bytes = base64.b64decode(response.text)
decoded_body_json = json.loads(decoded_body_bytes.decode("utf-8"))

assert_that(
response,
is_response()
.with_status_code(HTTPStatus.NOT_FOUND)
.with_headers(has_entries({"Content-Type": "application/fhir+json"})),
)

# Then
assert_that(
decoded_body_json,
has_entries(
resourceType=equal_to("OperationOutcome"),
issue=contains_exactly(
.with_headers(has_entries({"Content-Type": "application/fhir+json"}))
.and_body(
is_json_that(
has_entries(
severity="error",
code="processing",
diagnostics=f"NHS Number '{nhs_number!s}' was not recognised by the Eligibility Signposting API",
details={
"coding": [
{
"system": "https://fhir.nhs.uk/STU3/ValueSet/Spine-ErrorOrWarningCode-1",
"code": "REFERENCE_NOT_FOUND",
"display": "The given NHS number was not found in our datasets. "
"This could be because the number is incorrect or "
"some other reason we cannot process that number.",
}
]
},
resourceType="OperationOutcome",
issue=contains_exactly(
has_entries(
severity="error",
code="processing",
diagnostics=f"NHS Number '{nhs_number!s}' was not "
f"recognised by the Eligibility Signposting API",
details={
"coding": [
{
"system": "https://fhir.nhs.uk/STU3/ValueSet/Spine-ErrorOrWarningCode-1",
"code": "REFERENCE_NOT_FOUND",
"display": "The given NHS number was not found in our datasets. "
"This could be because the number is incorrect or "
"some other reason we cannot process that number.",
}
]
},
)
),
)
),
),
Expand Down