examples: FireExample ORM class + round-trip test
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
b5bfe8b73c
commit
8f2a80f563
2 changed files with 81 additions and 0 deletions
43
tests/test_examples_models.py
Normal file
43
tests/test_examples_models.py
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
"""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
|
||||
Loading…
Add table
Add a link
Reference in a new issue