diff --git a/src/eligibility_signposting_api/app.py b/src/eligibility_signposting_api/app.py index 9073bb779..26be07c99 100644 --- a/src/eligibility_signposting_api/app.py +++ b/src/eligibility_signposting_api/app.py @@ -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) diff --git a/tests/integration/lambda/test_app_running_as_lambda.py b/tests/integration/lambda/test_app_running_as_lambda.py index 0e9308796..b157fe44f 100644 --- a/tests/integration/lambda/test_app_running_as_lambda.py +++ b/tests/integration/lambda/test_app_running_as_lambda.py @@ -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.", + } + ] + }, + ) + ), ) ), ),