from pathlib import Path import csv, re root = Path('.') text = (root/'output/handoff.md').read_text() words = len(text.split()) assert words < 900, words with (root/'output/requirements.csv').open(newline='') as f: reader = csv.DictReader(f) assert reader.fieldnames == ['id','current_requirement','owner','status','source'] rows = list(reader) assert len({r['id'] for r in rows}) == len(rows) for row in rows: assert set(row) == set(reader.fieldnames) assert all(row.values()) assert 'inputs/' in row['source'] archive = (root/'inputs/archive.md').read_text() changes = (root/'inputs/approved-changes.md').read_text() for record in set(re.findall(r'\b(?:DEC|TEST|MAIL|EMAIL|TICKET|NOTE)-\d+\b', text + str(rows))): assert record in archive, record for record in set(re.findall(r'\bCR-\d+\b', text + str(rows))): assert record in changes, record print(f'PASS: handoff {words} whitespace-delimited words (<900); CSV {len(rows)} rows, exact header, unique IDs, all fields populated; cited record IDs found in supplied inputs.')