import csv, json
from pathlib import Path
rows = list(csv.DictReader(Path(__file__).with_name('visibility-toy.csv').open()))
attempts = [r for r in rows if r['seeded'] == 'false']
valid = [r for r in attempts if r['status'] == 'ok']
counts = {k: sum(int(r[k]) for r in valid) for k in ('mention', 'recommendation', 'owned_citation')}
assert len(attempts) == 8 and len(valid) == 6
assert counts == {'mention': 4, 'recommendation': 2, 'owned_citation': 3}
assert all(int(r['recommendation']) <= int(r['mention']) for r in valid)
print(json.dumps({'illustrative': True, 'unbranded_attempts': 8, 'valid_answers': 6, 'failures': 2,
                  'collection_completion': '6/8 = 75%', 'valid_answer_rates': {
                      'mention': '4/6 = 66.7%', 'recommendation': '2/6 = 33.3%', 'owned_citation': '3/6 = 50%'
                  }, 'seeded_diagnostics_excluded': 2}, indent=2))
