Files
mcma-backend/tests/conftest.py
T
2026-06-01 18:47:59 +03:00

29 lines
825 B
Python

"""Shared test fixtures.
The ASGI app is driven in-process via httpx + asgi-lifespan (no network, no
running server). DB/Redis-backed integration fixtures arrive with the data
layer (plan §11 step 2).
"""
import os
from collections.abc import AsyncIterator
import pytest
from asgi_lifespan import LifespanManager
from httpx import ASGITransport, AsyncClient
# Force a test-safe environment before settings load.
os.environ.setdefault("ENVIRONMENT", "test")
os.environ.setdefault("JWT_SECRET", "test-secret")
@pytest.fixture
async def client() -> AsyncIterator[AsyncClient]:
from app.main import create_app
app = create_app()
async with LifespanManager(app):
transport = ASGITransport(app=app)
async with AsyncClient(transport=transport, base_url="http://test") as ac:
yield ac