from datetime import UTC, datetime

from zbt.commands.seed import build_seed_manifest


def test_seed_manifest_contains_fixed_accounts_products_versions_and_plans() -> None:
    manifest = build_seed_manifest()

    assert len(manifest.admin_users) == 9
    assert {user.username for user in manifest.admin_users} == {
        "admin",
        "operator01",
        "reviewer01",
        "sales_a",
        "sales_b",
        "sales_c",
        "sales_d",
        "sales_e",
        "sales_f",
    }
    assert len(manifest.products) == 4
    assert {item.code for item in manifest.promotion_codes} == {
        "ZBT-SALES-A",
        "ZBT-SALES-B",
        "ZBT-SALES-C",
        "ZBT-SALES-D",
        "ZBT-SALES-E",
        "ZBT-SALES-F",
    }
    assert len(manifest.versions) == 7
    assert sum(len(version.plans) for version in manifest.versions) == 10

    when = datetime(2026, 1, 1, tzinfo=UTC)
    available = {
        (product.product_code, version.version_no)
        for product in manifest.products
        for version in manifest.versions
        if version.product_id == product.id and version.is_available_at(when)
    }
    assert available == {
        ("MED-BASIC", "2.0.0"),
        ("MED-UPGRADE", "1.0.0"),
        ("MED-SENIOR", "1.0.0"),
        ("ACC-FAMILY", "1.0.0"),
    }
