pythonasyncioapiasyncfastapiframeworkjsonjson-schemaopenapiopenapi3pydanticpython-typespython3redocreststarletteswaggerswagger-uiuvicornweb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
698 B
19 lines
698 B
import pytest
|
|
from httpx import ASGITransport, AsyncClient
|
|
|
|
from .main import app, lifespan
|
|
|
|
|
|
@pytest.mark.anyio
|
|
async def test_root():
|
|
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
|
|
async with lifespan(app=app):
|
|
# Send a GET request to the root endpoint
|
|
response = await client.get("/")
|
|
# Verify that the response is successful
|
|
assert response.status_code == 200
|
|
# Verify that the app's state is initialized
|
|
assert response.json() == {"message": "some_state_open"}
|
|
|
|
# Verify that the app's state is cleaned up
|
|
assert app.state.some_state == "some_state_close"
|
|
|