pcmt-artifact / tests /test_schema.py
Lightcap's picture
Add files using upload-large-folder tool
9fc0ed7 verified
Raw
History Blame Contribute Delete
1.14 kB
from pcmt.schema import atoms_to_cell, stable_hash, validate_trace_row
def test_trace_row_validation_accepts_required_schema():
row = {
"video_id": "clip",
"window_start": 0,
"window_end": 2,
"visual_atoms": atoms_to_cell(["speaker_visible"]),
"audio_atoms": atoms_to_cell(["speech"]),
"subtitle_ocr_atoms": atoms_to_cell(["subtitle_speech"]),
"edit_type": "none",
"formula_verdict": "true",
"certificate_hash": stable_hash({"ok": True}),
"counterexample_window": "",
"defect_score": "0.0",
}
assert validate_trace_row(row) == []
def test_trace_row_validation_rejects_bad_score():
row = {
"video_id": "clip",
"window_start": 0,
"window_end": 2,
"visual_atoms": "[]",
"audio_atoms": "[]",
"subtitle_ocr_atoms": "[]",
"edit_type": "none",
"formula_verdict": "true",
"certificate_hash": stable_hash({"ok": True}),
"counterexample_window": "",
"defect_score": "4.0",
}
assert "defect_score must be in [0, 1]" in validate_trace_row(row)