#!/usr/bin/env python3
"""Structural checks for the support-request CSV reviewed with csv-quality-triage."""
import csv
from pathlib import Path

path = Path(__file__).with_name("csv-quality-input.csv")
with path.open(newline="", encoding="utf-8") as stream:
    reader = csv.DictReader(stream)
    assert reader.fieldnames == ["ticket_id", "request_text"], reader.fieldnames
    rows = list(reader)

ids = [row["ticket_id"] for row in rows]
assert len(rows) == 8, f"expected 8 records, got {len(rows)}"
assert len(ids) == len(set(ids)), "duplicate ticket_id values"
assert all(row["ticket_id"].strip() and row["request_text"].strip() for row in rows), "blank required value"
assert any("," in row["request_text"] for row in rows), "fixture lost the comma case"
assert not {"amount", "currency"}.intersection(reader.fieldnames or []), "fixture unexpectedly contains transaction fields"
print("PASS: CSV parser read 8 records and two named columns; IDs unique; no blank ID or request text; quoted comma preserved; no amount/currency fields to aggregate.")
