examples: to_gbp currency normalisation helper
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Viktor Barzin 2026-05-28 22:24:47 +00:00
parent e75a635d25
commit 0d442de918
2 changed files with 37 additions and 0 deletions

View file

@ -12,6 +12,7 @@ import respx
from fire_planner.examples.llm_extract import (
extract_with_fallback,
extract_with_qwen,
to_gbp,
)
from fire_planner.examples.models import RawPost
@ -171,3 +172,20 @@ async def test_fallback_keeps_high_confidence_qwen_result() -> None:
assert out is not None
assert out.llm_model == "qwen3-8b"
assert claude_route.called is False # high-confidence qwen → claude not hit
def test_to_gbp_converts_usd() -> None:
rates = {"GBP": Decimal("1"), "USD": Decimal("0.80")}
assert to_gbp(Decimal("100"), "USD", rates) == Decimal("80.00")
def test_to_gbp_passes_through_gbp() -> None:
assert to_gbp(Decimal("100"), "GBP", {"GBP": Decimal("1")}) == Decimal("100.00")
def test_to_gbp_returns_none_for_unknown_currency() -> None:
assert to_gbp(Decimal("100"), "XYZ", {"GBP": Decimal("1"), "USD": Decimal("0.8")}) is None
def test_to_gbp_returns_none_for_none_amount() -> None:
assert to_gbp(None, "USD", {"USD": Decimal("0.8")}) is None