#!/usr/bin/env python3 """CHECK — verify the JSONPlaceholder /users extraction artifact. Reads users.csv (defaults to the committed copy in the troupe repo) and asserts: * header row is exactly the 8 expected columns * there are exactly 10 data rows * three spot rows match values re-derivable from the HTTP response Exit 0 only if every assertion holds; non-zero otherwise. """ import csv import sys # Committed artifact path (what ships to the repo). DEFAULT_CSV = "/root/troupe-standup/wizard-work/ledger/2026-10-23-jpv-users.csv" HEADER = ["id", "name", "username", "email", "city", "phone", "website", "company"] # (name, username, email, city, website, company) EXPECTED = { "1": ("Leanne Graham", "Bret", "Sincere@april.biz", "Gwenborough", "hildegard.org", "Romaguera-Crona"), "3": ("Clementine Bauch", "Samantha", "Nathan@yesenia.net", "McKenziehaven", "ramiro.info", "Romaguera-Jacobson"), "10": ("Clementina DuBuque", "Moriah.Stanton", "Rey.Padberg@karina.biz", "Lebsackbury", "ambrose.net", "Hoeger LLC"), } def main(): csv_path = sys.argv[1] if len(sys.argv) > 1 else DEFAULT_CSV with open(csv_path, newline="") as f: reader = csv.DictReader(f) if reader.fieldnames != HEADER: print("HEADER MISMATCH: got %r" % (reader.fieldnames,)) return 1 rows = list(reader) if len(rows) != 10: print("ROW COUNT MISMATCH: %d" % len(rows)) return 1 for r in rows: key = r["id"] if key in EXPECTED: want = EXPECTED[key] got = (r["name"], r["username"], r["email"], r["city"], r["website"], r["company"]) if got != want: print("ROW %s MISMATCH: got %r want %r" % (key, got, want)) return 1 print("OK: header exact, 10 rows, 3 spot rows verified") return 0 if __name__ == "__main__": sys.exit(main())