Skip to content

Commit 5889dcd

Browse files
authored
ELI-318: Adds application/fhir+json as valid mime type in Mangum (#235)
1 parent 6ea9223 commit 5889dcd

2 files changed

Lines changed: 24 additions & 26 deletions

File tree

src/eligibility_signposting_api/app.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def lambda_handler(event: LambdaEvent, context: LambdaContext) -> dict[str, Any]
2929
app = create_app()
3030
app.debug = config()["log_level"] == logging.DEBUG
3131
handler = Mangum(WsgiToAsgi(app), lifespan="off")
32+
handler.config["text_mime_types"].append("application/fhir+json")
3233
return handler(event, context)
3334

3435

tests/integration/lambda/test_app_running_as_lambda.py

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -124,37 +124,34 @@ def test_install_and_call_flask_lambda_with_unknown_nhs_number(
124124
timeout=10,
125125
)
126126

127-
decoded_body_bytes = base64.b64decode(response.text)
128-
decoded_body_json = json.loads(decoded_body_bytes.decode("utf-8"))
129-
130127
assert_that(
131128
response,
132129
is_response()
133130
.with_status_code(HTTPStatus.NOT_FOUND)
134-
.with_headers(has_entries({"Content-Type": "application/fhir+json"})),
135-
)
136-
137-
# Then
138-
assert_that(
139-
decoded_body_json,
140-
has_entries(
141-
resourceType=equal_to("OperationOutcome"),
142-
issue=contains_exactly(
131+
.with_headers(has_entries({"Content-Type": "application/fhir+json"}))
132+
.and_body(
133+
is_json_that(
143134
has_entries(
144-
severity="error",
145-
code="processing",
146-
diagnostics=f"NHS Number '{nhs_number!s}' was not recognised by the Eligibility Signposting API",
147-
details={
148-
"coding": [
149-
{
150-
"system": "https://fhir.nhs.uk/STU3/ValueSet/Spine-ErrorOrWarningCode-1",
151-
"code": "REFERENCE_NOT_FOUND",
152-
"display": "The given NHS number was not found in our datasets. "
153-
"This could be because the number is incorrect or "
154-
"some other reason we cannot process that number.",
155-
}
156-
]
157-
},
135+
resourceType="OperationOutcome",
136+
issue=contains_exactly(
137+
has_entries(
138+
severity="error",
139+
code="processing",
140+
diagnostics=f"NHS Number '{nhs_number!s}' was not "
141+
f"recognised by the Eligibility Signposting API",
142+
details={
143+
"coding": [
144+
{
145+
"system": "https://fhir.nhs.uk/STU3/ValueSet/Spine-ErrorOrWarningCode-1",
146+
"code": "REFERENCE_NOT_FOUND",
147+
"display": "The given NHS number was not found in our datasets. "
148+
"This could be because the number is incorrect or "
149+
"some other reason we cannot process that number.",
150+
}
151+
]
152+
},
153+
)
154+
),
158155
)
159156
),
160157
),

0 commit comments

Comments
 (0)