"""Tests for the first use case, `bank_statement_header` (spec ยง7).""" from __future__ import annotations from datetime import date from decimal import Decimal from ix.use_cases.bank_statement_header import BankStatementHeader, Request class TestRequest: def test_defaults(self) -> None: r = Request() assert r.use_case_name == "Bank Statement Header" assert r.default_model == "qwen3:14b" # Stable substring for agent/worker tests that want to confirm the # prompt is what they think it is. assert "extract header metadata" in r.system_prompt class TestBankStatementHeader: def test_all_fields_optional_except_bank_name_and_currency(self) -> None: # Minimal valid instance (per spec only bank_name + currency are required). hdr = BankStatementHeader(bank_name="UBS", currency="CHF") assert hdr.bank_name == "UBS" assert hdr.currency == "CHF" assert hdr.account_iban is None assert hdr.statement_date is None assert hdr.opening_balance is None def test_full_populated_instance_roundtrip(self) -> None: hdr = BankStatementHeader( bank_name="UBS Switzerland AG", account_iban="CH9300762011623852957", account_type="checking", currency="CHF", statement_date=date(2026, 3, 31), statement_period_start=date(2026, 3, 1), statement_period_end=date(2026, 3, 31), opening_balance=Decimal("1234.56"), closing_balance=Decimal("2345.67"), ) dumped = hdr.model_dump(mode="json") rt = BankStatementHeader.model_validate(dumped) assert rt.account_type == "checking" assert rt.opening_balance == Decimal("1234.56") assert rt.statement_period_start == date(2026, 3, 1) def test_account_type_literal_rejects_unknown(self) -> None: import pytest from pydantic import ValidationError with pytest.raises(ValidationError): BankStatementHeader(bank_name="UBS", currency="CHF", account_type="weird") # type: ignore[arg-type]