from __future__ import annotations

from datetime import UTC, datetime
from decimal import Decimal

from app.models.financial_record import ExpenseClaim
from app.test_helpers.db import build_in_memory_session


def test_build_in_memory_session_creates_isolated_sqlite_schema() -> None:
    with build_in_memory_session() as db:
        db.add(
            ExpenseClaim(
                claim_no="CLM-HELPER-001",
                employee_name="张三",
                department_name="研发部",
                expense_type="travel",
                reason="测试共享内存数据库夹具",
                location="上海",
                amount=Decimal("10.00"),
                occurred_at=datetime(2026, 6, 23, tzinfo=UTC),
                status="draft",
                approval_stage="待提交",
                risk_flags_json=[],
            )
        )
        db.commit()

        assert db.query(ExpenseClaim).count() == 1
