fix(mcp): scope fixture NullPool + suppression imports inutiles + validation enums + cleanup tests
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -13,7 +13,7 @@ def make_test_engine():
|
||||
return create_async_engine(settings.database_url, poolclass=NullPool)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
@pytest.fixture
|
||||
async def mcp_nullpool_session():
|
||||
"""Remplace AsyncSessionLocal dans mcp_server par un sessionmaker NullPool
|
||||
pour éviter les conflits d'event loop entre tests."""
|
||||
|
||||
@@ -1,8 +1,21 @@
|
||||
import json
|
||||
import pytest
|
||||
from sqlalchemy import delete
|
||||
from app.api.mcp_server import (
|
||||
get_todos, create_todo, update_todo, postpone_todo, delete_todo,
|
||||
)
|
||||
from app.core.database import AsyncSessionLocal
|
||||
from app.models.todos import TodoItem
|
||||
|
||||
pytestmark = pytest.mark.usefixtures("mcp_nullpool_session")
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
async def cleanup_mcp_todos():
|
||||
yield
|
||||
async with AsyncSessionLocal() as session:
|
||||
await session.execute(delete(TodoItem).where(TodoItem.title.like("TEST_MCP_%")))
|
||||
await session.commit()
|
||||
|
||||
|
||||
async def test_get_todos_retourne_liste_json():
|
||||
|
||||
Reference in New Issue
Block a user