How to use the mangum.platforms.azure.adapter.AzureFunctionAdapter function in mangum

To help you get started, we’ve selected a few mangum examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github erm / mangum / tests / test_azure.py View on Github external
"type": "http.response.body",
                        "body": b"<h1>Hello, world!</h1>",
                    }
                )

        return asgi

    mock_request = MockHttpRequest(
        "GET",
        "/",
        headers={"content-type": "text/html; charset=utf-8"},
        params={"name": "val"},
        route_params=None,
        body=None,
    )
    handler = AzureFunctionAdapter(app)
    response = handler(mock_request)

    assert response.status_code == 200
    assert response.get_body() == b"<h1>Hello, world!</h1>"
    assert response.charset == "utf-8"
    assert response.mimetype == "text/html"
github erm / mangum / tests / test_azure.py View on Github external
app = Starlette()

    @app.route("/")
    def homepage(request):
        return HTMLResponse("<h1>Hello, world!</h1>")

    mock_request = MockHttpRequest(
        "GET",
        "/",
        headers={"content-type": "text/html; charset=utf-8"},
        params=None,
        route_params=None,
        body=None,
    )

    handler = AzureFunctionAdapter(app)
    response = handler(mock_request)

    assert response.status_code == 200
    assert response.get_body() == b"<h1>Hello, world!</h1>"
    assert response.charset == "utf-8"
    assert response.mimetype == "text/html"
github erm / mangum / tests / test_azure.py View on Github external
mock_request = MockHttpRequest(
        "GET",
        "/",
        headers={"content-type": "text/html; charset=utf-8"},
        params=None,
        route_params=None,
        body=None,
    )
    app = Quart(__name__)

    @app.route("/")
    async def hello():
        return "<h1>Hello, world!</h1>"

    handler = AzureFunctionAdapter(app)
    response = handler(mock_request)

    assert response.status_code == 200
    assert response.get_body() == b"<h1>Hello, world!</h1>"
    assert response.charset == "utf-8"
    assert response.mimetype == "text/html"
github erm / mangum / tests / test_azure.py View on Github external
)
            await send({"type": "http.response.body", "body": body})

        return asgi

    body = b"123"
    mock_request = MockHttpRequest(
        "POST",
        "/",
        headers={"content-type": "text/html; charset=utf-8"},
        params=None,
        route_params=None,
        body=body,
    )

    handler = AzureFunctionAdapter(app)
    response = handler(mock_request)

    assert response.status_code == 200
    assert response.get_body() == b"123"
    assert response.charset == "utf-8"
    assert response.mimetype == "text/html"