"""Product → tier mapping lookup."""

from __future__ import annotations

from app.products import lookup, reload_for_tests


def setup_function(_):
    # The yaml file is read once at import; reload to be safe if
    # other tests mutate state in the future.
    reload_for_tests()


def test_lookup_known_gumroad_product():
    m = lookup("gumroad", "datatools-core")
    assert m is not None
    assert m.tier == "core"
    assert m.years == 1


def test_lookup_unknown_product_returns_none():
    assert lookup("gumroad", "no-such-product") is None


def test_lookup_unknown_source_returns_none():
    assert lookup("paddle", "datatools-core") is None


def test_all_three_tiers_mapped():
    assert lookup("gumroad", "datatools-lite").tier == "lite"
    assert lookup("gumroad", "datatools-core").tier == "core"
    assert lookup("gumroad", "datatools-pro").tier == "pro"
