From 15efc30e9e7179accd30375d3edb2e34a3b4dc5f Mon Sep 17 00:00:00 2001 From: Oscar Wan Date: Fri, 24 Jul 2026 20:45:42 -0700 Subject: updated generation process --- tests/test_offline.py | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) (limited to 'tests/test_offline.py') diff --git a/tests/test_offline.py b/tests/test_offline.py index 04b7f46..9851826 100644 --- a/tests/test_offline.py +++ b/tests/test_offline.py @@ -1,6 +1,72 @@ -from gap_pipeline.offline import normalize_latex_symbol +import json + +from gap_pipeline.offline import ( + align_run_to_release, + normalize_latex_symbol, + summarize_run, +) def test_latex_symbol_aliases_normalize_together() -> None: assert normalize_latex_symbol(r"x_{n}") == normalize_latex_symbol("x_n") assert normalize_latex_symbol(r"\\phi") == normalize_latex_symbol(r"\phi") + + +def test_run_summary_counts_acceptance_after_repair(tmp_path) -> None: + item_dir = tmp_path / "items" / "demo" + item_dir.mkdir(parents=True) + (item_dir / "final.json").write_text( + json.dumps( + { + "item_id": "demo", + "status": "accepted", + "iterations": [ + {"unanimous": False}, + {"unanimous": True}, + {"unanimous": True}, + ], + } + ), + encoding="utf-8", + ) + + summary = summarize_run(tmp_path) + assert summary["accepted_after_repair"] == 1 + + +def test_align_release_uses_current_candidate_schema(tmp_path) -> None: + run_dir = tmp_path / "run" + item_dir = run_dir / "items" / "demo" + item_dir.mkdir(parents=True) + (item_dir / "final.json").write_text( + json.dumps( + { + "item_id": "demo", + "status": "accepted", + "accepted_candidate": { + "question": "New question", + "solution": "New solution", + }, + } + ), + encoding="utf-8", + ) + dataset_dir = tmp_path / "dataset" + dataset_dir.mkdir() + (dataset_dir / "demo.json").write_text( + json.dumps( + { + "index": "demo", + "variants": { + "kernel_variant": { + "question": "New question", + "solution": "New solution", + } + }, + } + ), + encoding="utf-8", + ) + + alignment = align_run_to_release(run_dir, dataset_dir) + assert alignment["status_counts"] == {"exact_match": 1} -- cgit v1.2.3