Core modules: - Laws: CRUD, search, AI-powered QA - Analysis: legal research and case management - Contracts: lifecycle management with templates - Signatures: electronic signature workflow Infrastructure: - FastAPI + SQLite + async SQLAlchemy - Docker deployment support - 54 unit tests passing Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
37 lines
914 B
Python
37 lines
914 B
Python
"""Pytest configuration and fixtures."""
|
|
import asyncio
|
|
import pytest
|
|
import pytest_asyncio
|
|
from typing import AsyncGenerator
|
|
from sqlalchemy.ext.asyncio import (
|
|
AsyncSession,
|
|
create_async_engine,
|
|
async_sessionmaker,
|
|
)
|
|
|
|
from app.core.database import Base
|
|
from app.models.user import User
|
|
from app.models.law import Law, LawArticle
|
|
|
|
|
|
@pytest_asyncio.fixture
|
|
async def db_session(tmp_path) -> AsyncGenerator[AsyncSession, None]:
|
|
"""Create a test database session."""
|
|
db_file = tmp_path / "test.db"
|
|
engine = create_async_engine(
|
|
f"sqlite+aiosqlite:///{db_file}",
|
|
echo=False,
|
|
)
|
|
|
|
async with engine.begin() as conn:
|
|
await conn.run_sync(Base.metadata.create_all)
|
|
|
|
async_session = async_sessionmaker(
|
|
engine, class_=AsyncSession, expire_on_commit=False
|
|
)
|
|
|
|
async with async_session() as session:
|
|
yield session
|
|
|
|
await engine.dispose()
|