"""ManualAdapter — building a SaleEvent from CLI-style kwargs."""

from __future__ import annotations

from decimal import Decimal

from app.adapters.manual import ManualAdapter


def test_build_sale_minimal_defaults():
    a = ManualAdapter()
    sale = a.build_sale(name="Jane Doe", email="jane@example.com", tier="core")
    assert sale.source == "manual"
    assert sale.source_order_id is None
    assert sale.buyer_name == "Jane Doe"
    assert sale.buyer_email == "jane@example.com"
    assert sale.tier == "core"
    assert sale.years == 1
    assert sale.currency == "USD"
    assert sale.promotion is None
    assert sale.amount_paid is None
    assert sale.notes is None


def test_build_sale_full_metadata():
    a = ManualAdapter()
    sale = a.build_sale(
        name="Acme",
        email="ops@acme.example",
        tier="pro",
        years=2,
        promotion="LAUNCH50",
        amount_paid=Decimal("249.00"),
        currency="EUR",
        notes="comp for beta tester",
    )
    assert sale.years == 2
    assert sale.promotion == "LAUNCH50"
    assert sale.amount_paid == Decimal("249.00")
    assert sale.currency == "EUR"
    assert sale.notes == "comp for beta tester"


def test_verify_webhook_always_false():
    """Manual flow never originates from a webhook."""
    a = ManualAdapter()
    assert a.verify_webhook(body=b"{}", headers={}) is False


def test_parse_refund_returns_none():
    a = ManualAdapter()
    assert a.parse_refund({"any": "payload"}) is None
