44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
|
|
"""Schema test — FireExample ORM round-trips through the in-memory engine."""
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from datetime import date
|
||
|
|
from decimal import Decimal
|
||
|
|
|
||
|
|
import pytest
|
||
|
|
from sqlalchemy import select
|
||
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||
|
|
|
||
|
|
from fire_planner.db import FireExample
|
||
|
|
|
||
|
|
|
||
|
|
@pytest.mark.asyncio
|
||
|
|
async def test_fire_example_round_trip(session: AsyncSession) -> None:
|
||
|
|
row = FireExample(
|
||
|
|
reddit_id="abc123",
|
||
|
|
source_sub="financialindependence",
|
||
|
|
post_url="https://reddit.com/r/financialindependence/abc123",
|
||
|
|
post_date=date(2026, 1, 1),
|
||
|
|
post_title="Hit £1m at 38, living in Manila",
|
||
|
|
country="Philippines",
|
||
|
|
city="Manila",
|
||
|
|
portfolio_gbp=Decimal("1000000.00"),
|
||
|
|
annual_exp_gbp=Decimal("14400.00"),
|
||
|
|
age=38,
|
||
|
|
family_size=2,
|
||
|
|
fi_status="FIRE",
|
||
|
|
is_retired=True,
|
||
|
|
raw_currency="GBP",
|
||
|
|
raw_excerpt="...£1m...Manila...",
|
||
|
|
llm_model="qwen3-8b",
|
||
|
|
llm_confidence=Decimal("0.82"),
|
||
|
|
)
|
||
|
|
session.add(row)
|
||
|
|
await session.commit()
|
||
|
|
|
||
|
|
result = await session.execute(select(FireExample).where(FireExample.reddit_id == "abc123"))
|
||
|
|
fetched = result.scalar_one()
|
||
|
|
assert fetched.country == "Philippines"
|
||
|
|
assert fetched.portfolio_gbp == Decimal("1000000.00")
|
||
|
|
assert fetched.fi_status == "FIRE"
|
||
|
|
assert fetched.is_retired is True
|