重组为 backend/clients/docs 三层结构,并清理 git 污染。

将后端迁入 backend/,完善根目录 .gitignore,删除误提交的 .mypy_cache 缓存文件。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Kevin
2026-05-21 16:02:25 +08:00
parent 6bc6801df9
commit 1af442481e
142 changed files with 175 additions and 212 deletions

28
backend/tests/conftest.py Normal file
View File

@@ -0,0 +1,28 @@
"""Shared test fixtures (SQLite memory DB session factory)."""
from __future__ import annotations
from collections.abc import AsyncGenerator
import pytest_asyncio
from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
import app.db.models # noqa: F401 # register ORM tables on Base.metadata
from app.db.base import Base
@pytest_asyncio.fixture
async def sqlite_session_factory() -> AsyncGenerator[async_sessionmaker[AsyncSession], None]:
"""In-memory SQLite + create_all; yields async_sessionmaker suitable for injection."""
engine = create_async_engine("sqlite+aiosqlite:///:memory:")
async with engine.begin() as conn:
await conn.run_sync(Base.metadata.create_all)
factory = async_sessionmaker(
engine,
class_=AsyncSession,
expire_on_commit=False,
autoflush=False,
autobegin=False,
)
yield factory
await engine.dispose()