Skip to content

Test echo

test_echo(fastapi_app, client) async

Tests that echo route works.

Parameters:

Name Type Description Default
fastapi_app FastAPI

current application.

required
client AsyncClient

client for the app.

required
Source code in hestia/tests/test_echo.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
@pytest.mark.anyio
async def test_echo(fastapi_app: FastAPI, client: AsyncClient) -> None:
    """
    Tests that echo route works.

    :param fastapi_app: current application.
    :param client: client for the app.
    """
    url = fastapi_app.url_path_for("send_echo_message")
    message = uuid.uuid4().hex
    response = await client.post(
        url,
        json={
            "message": message,
        },
    )
    assert response.status_code == status.HTTP_200_OK
    assert response.json()["message"] == message