✨ Changements majeurs: - Suppression complète du code Flask legacy - Migration backend FastAPI vers racine /backend - Migration frontend Vue.js vers racine /frontend - Suppression de notytex-v2/ (code monté à la racine) ✅ Validations: - Backend démarre correctement (port 8000) - API /api/v2/health répond healthy - 99/99 tests unitaires passent - Frontend configuré avec proxy Vite 📝 Documentation: - README.md réécrit pour v2 - Instructions de démarrage mises à jour - .gitignore adapté pour backend/frontend/ 🎯 Architecture finale: notytex/ ├── backend/ # FastAPI + SQLAlchemy + Pydantic ├── frontend/ # Vue 3 + Vite + TailwindCSS ├── docs/ # Documentation └── school_management.db # Base de données (inchangée) Jalon 6 complété: Application v2 prête pour utilisation!
64 lines
1.6 KiB
Python
64 lines
1.6 KiB
Python
"""
|
|
Configuration pytest pour les tests du backend v2.
|
|
"""
|
|
|
|
import pytest
|
|
from httpx import AsyncClient, ASGITransport
|
|
from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine, async_sessionmaker
|
|
|
|
from api.main import app
|
|
from infrastructure.database.session import get_async_session
|
|
from infrastructure.database.models import Base
|
|
|
|
|
|
# Base de données de test (en mémoire)
|
|
TEST_DATABASE_URL = "sqlite+aiosqlite:///:memory:"
|
|
|
|
test_engine = create_async_engine(
|
|
TEST_DATABASE_URL,
|
|
echo=False,
|
|
)
|
|
|
|
TestSessionLocal = async_sessionmaker(
|
|
bind=test_engine,
|
|
class_=AsyncSession,
|
|
expire_on_commit=False,
|
|
)
|
|
|
|
|
|
async def override_get_async_session():
|
|
"""Override de la session pour les tests."""
|
|
async with TestSessionLocal() as session:
|
|
yield session
|
|
|
|
|
|
@pytest.fixture
|
|
async def test_db():
|
|
"""Fixture pour créer les tables de test."""
|
|
async with test_engine.begin() as conn:
|
|
await conn.run_sync(Base.metadata.create_all)
|
|
yield
|
|
async with test_engine.begin() as conn:
|
|
await conn.run_sync(Base.metadata.drop_all)
|
|
|
|
|
|
@pytest.fixture
|
|
async def client(test_db):
|
|
"""Fixture pour le client HTTP de test."""
|
|
app.dependency_overrides[get_async_session] = override_get_async_session
|
|
|
|
async with AsyncClient(
|
|
transport=ASGITransport(app=app),
|
|
base_url="http://test"
|
|
) as ac:
|
|
yield ac
|
|
|
|
app.dependency_overrides.clear()
|
|
|
|
|
|
@pytest.fixture
|
|
async def db_session(test_db):
|
|
"""Fixture pour une session de base de données de test."""
|
|
async with TestSessionLocal() as session:
|
|
yield session
|