from pathlib import Path import csv,json,hashlib,sys,platform,datetime HERE=Path(__file__).resolve().parent def read_csv(name): with (HERE/'input'/f'{name}.csv').open(encoding='utf-8-sig',newline='') as f:return list(csv.DictReader(f)) def hashfile(path):return hashlib.sha256(path.read_bytes()).hexdigest() original=read_csv('original-example');route={r['point']:r for r in read_csv('route')};checked=[];unseen=[];missing=[] for r in original: point=r['지점'].split()[0] if r['확인 상태']=='확인': checked.append(point) if not (HERE/route[point]['required_file']).is_file():missing.append(point) else:unseen.append(point) claimed=int(read_csv('bad_summary')[0]['claimed_complete']) actual={'planned_points':len(route),'checked_points':checked,'unseen_points':unseen,'missing_checked_attachments':missing,'bad_claim_overcount':claimed-len(checked),'coverage_fraction':f'{len(checked)}/{len(route)}'} import datetime as _lab_clock expected=json.loads((HERE/'expected/report.json').read_text()) checks=[{'field':k,'pass':actual.get(k)==v,'actual':actual.get(k),'expected':v} for k,v in expected.items()] passed=all(x['pass'] for x in checks) and set(actual)==set(expected) report={'lab_id':HERE.name,'synthetic_fixture':True,'environment':{'python':platform.python_version(),'platform':platform.system(),'processor':'Python standard library; PNG rendering only uses ImageMagick during artifact preparation'},'run_utc':_lab_clock.datetime.now(_lab_clock.timezone.utc).isoformat(),'status':'PASS' if passed else 'FAIL','assertion_count':len(checks),'actual':actual,'assertions':checks,'limits':'Synthetic test data only; not a real building inspection, legal/safety verdict, or Excel application execution.'} (HERE/'results.json').write_text(json.dumps(report,ensure_ascii=False,indent=2)) print(json.dumps(report,ensure_ascii=False,indent=2)) if not passed:raise SystemExit(1)