test(backend): fournit une session reelle aux tests d'integration

Les repositories a venir parlent du SQL : les eprouver sur un double ne prouve
rien. La fixture ouvre une vraie connexion, d'ou le marqueur integration.
This commit is contained in:
Johan LEROY
2026-09-15 10:00:42 +02:00
parent d14b3afc8e
commit d58647cad4
+8
View File
@@ -4,6 +4,7 @@ from collections.abc import AsyncIterator, Callable, Iterator
import pytest
from fastapi import FastAPI
from httpx import ASGITransport, AsyncClient
from sqlalchemy.ext.asyncio import AsyncSession
from app.core.config import get_settings
from app.db.session import get_engine, get_session, get_session_factory
@@ -64,3 +65,10 @@ def fake_session(app: FastAPI) -> Callable[..., None]:
app.dependency_overrides[get_session] = override
return install
# Contrainte : ouvre une vraie connexion, donc reservee aux tests `integration`.
@pytest.fixture
async def session() -> AsyncIterator[AsyncSession]:
async with get_session_factory()() as async_session:
yield async_session