examples: RawPost + ExtractedExample + Summary Pydantic schemas
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
8f2a80f563
commit
c9bdf537ac
3 changed files with 133 additions and 0 deletions
46
tests/test_examples_filters.py
Normal file
46
tests/test_examples_filters.py
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
"""Tests for fire_planner.examples.models — Pydantic schemas."""
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import date
|
||||
from decimal import Decimal
|
||||
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from fire_planner.examples import ExtractedExample, FiStatus, RawPost, SummaryStats
|
||||
|
||||
|
||||
def test_raw_post_minimal() -> None:
|
||||
p = RawPost(
|
||||
reddit_id="abc123",
|
||||
source_sub="financialindependence",
|
||||
url="https://reddit.com/r/financialindependence/abc123",
|
||||
title="Hit FIRE at 38",
|
||||
body="Net worth £1.2m, living in Lisbon, family of 3, retired last year.",
|
||||
created_at=date(2026, 1, 1),
|
||||
)
|
||||
assert p.reddit_id == "abc123"
|
||||
|
||||
|
||||
def test_extracted_example_confidence_bounds() -> None:
|
||||
with pytest.raises(ValidationError):
|
||||
ExtractedExample(
|
||||
country="Portugal",
|
||||
confidence=Decimal("1.5"), # out of range
|
||||
llm_model="qwen3-8b",
|
||||
)
|
||||
|
||||
|
||||
def test_extracted_example_fi_status_enum() -> None:
|
||||
ex = ExtractedExample(
|
||||
country="Philippines",
|
||||
fi_status=FiStatus.FIRE,
|
||||
confidence=Decimal("0.8"),
|
||||
llm_model="qwen3-8b",
|
||||
)
|
||||
assert ex.fi_status == "FIRE"
|
||||
|
||||
|
||||
def test_summary_stats_optional_fields() -> None:
|
||||
s = SummaryStats(median=None, p25=None, p75=None)
|
||||
assert s.median is None
|
||||
Loading…
Add table
Add a link
Reference in a new issue