diff options
| author | Oscar Wan <oscarwan@stanford.edu> | 2026-07-24 20:45:42 -0700 |
|---|---|---|
| committer | Oscar Wan <oscarwan@stanford.edu> | 2026-07-24 20:45:42 -0700 |
| commit | 15efc30e9e7179accd30375d3edb2e34a3b4dc5f (patch) | |
| tree | ba1c49eb128e7906ba451141723d763e1dcda53a /tests/test_offline.py | |
| parent | 708f2af9c6985e9cb5cd53e434a7d3b8dfa2b4ac (diff) | |
updated generation process
Diffstat (limited to 'tests/test_offline.py')
| -rw-r--r-- | tests/test_offline.py | 68 |
1 files changed, 67 insertions, 1 deletions
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} |
