#!/usr/bin/env python3
"""Verify illustrative hold outputs for PAE-LEFTOVER-20260823."""

from __future__ import annotations

import csv
import pathlib
import sys


def main() -> int:
    path = pathlib.Path(__file__).with_name("held-table-PAE-LEFTOVER-20260823.csv")
    with path.open(newline="", encoding="utf-8") as handle:
        rows = list(csv.DictReader(handle))
    rates = [row["value"] for row in rows if row["status"] == "published_rate_pct"]
    held = [row for row in rows if row["status"].startswith("suppressed_")]
    statuses = {row["status"] for row in held}
    expected = {"suppressed_n_under_5", "suppressed_complement"}
    if rates != ["6.1", "8.4"] or statuses != expected:
        print("FAIL: rates or hold statuses are incorrect.", file=sys.stderr)
        return 1
    if any(row["value"] for row in held):
        print("FAIL: a held row exposes a value.", file=sys.stderr)
        return 1
    print("OK: two rates, one small-cell hold, and one complement hold verified.")
    return 0


if __name__ == "__main__":
    raise SystemExit(main())
