summaryrefslogtreecommitdiff
path: root/tests/test_surface.py
diff options
context:
space:
mode:
authorAnonymous Authors <anonymous@invalid.example>2026-07-24 13:52:11 -0500
committerAnonymous Authors <anonymous@invalid.example>2026-07-24 13:52:11 -0500
commitd4eb26780a8a8c70ca75812af0c3c6a295c0797c (patch)
tree46d2aa0fca13f6db2c8226471981ce06c1423eac /tests/test_surface.py
parentdb293f3606a97b3e417de27124858e134005acbd (diff)
Restore original GAP prompts and lock prompt bytes
Diffstat (limited to 'tests/test_surface.py')
-rw-r--r--tests/test_surface.py79
1 files changed, 47 insertions, 32 deletions
diff --git a/tests/test_surface.py b/tests/test_surface.py
index 78c4d5e..4d92de3 100644
--- a/tests/test_surface.py
+++ b/tests/test_surface.py
@@ -1,43 +1,58 @@
from __future__ import annotations
+import asyncio
+
import pytest
-from gap_pipeline.surface import (
- apply_rename_map,
- create_surface_variant,
- validate_rename_map,
-)
+from gap_pipeline.clients import ScriptedClient
+from gap_pipeline.store import RunStore
+from gap_pipeline.surface import SurfacePipeline, validate_surface_variant
-def test_math_only_rename_preserves_english_article(item) -> None:
- text = r"Let \(a\) be a randomly chosen value with \(a>0\)."
- renamed = apply_rename_map(text, {"a": "coefalpha"})
- assert renamed == (
- r"Let \(coefalpha\) be a randomly chosen value with \(coefalpha>0\)."
+def test_surface_pipeline_uses_full_original_contract(tmp_path, item) -> None:
+ response = {
+ "map": {"a": "positivequantity"},
+ "question": r"Let \(positivequantity>0\). Prove the renamed inequality.",
+ "solution": r"Apply the same proof to \(positivequantity\).",
+ }
+ client = ScriptedClient(
+ {f"{item.item_id}.surface.descriptive_long": response}
)
-
-
-def test_surface_variant_changes_problem_and_solution(item) -> None:
- variant = create_surface_variant(
- item,
- "descriptive_long",
- {"a": "positiveScalar"},
+ variant = asyncio.run(
+ SurfacePipeline(
+ client,
+ RunStore(tmp_path, item.item_id),
+ ).run_family(item, "descriptive_long")
)
- assert "positiveScalar" in variant.problem
- assert "positiveScalar" in variant.solution
- assert "Let positiveScalar" not in variant.problem
-
-
-def test_collision_and_nonbijection_are_rejected(item) -> None:
- with pytest.raises(ValueError, match="collides"):
- validate_rename_map(
- {"a": "a"},
- existing_identifiers=["a"],
- scientific_constants=[],
+ assert variant.rename_map == {"a": "positivequantity"}
+ assert variant.question == response["question"]
+ assert variant.solution == response["solution"]
+
+
+def test_missing_symbol_and_nonbijection_are_rejected(item) -> None:
+ with pytest.raises(ValueError, match="every var and param"):
+ validate_surface_variant(
+ item,
+ rename_map={},
+ question="question",
+ solution="solution",
)
+
+ item.variables.append("b")
with pytest.raises(ValueError, match="one-to-one"):
- validate_rename_map(
- {"a": "sharedName", "b": "sharedName"},
- existing_identifiers=["a", "b"],
- scientific_constants=[],
+ validate_surface_variant(
+ item,
+ rename_map={"a": "sharedname", "b": "sharedname"},
+ question="question",
+ solution="solution",
+ )
+
+
+def test_original_identifier_contract_is_enforced(item) -> None:
+ with pytest.raises(ValueError, match="original prompt contract"):
+ validate_surface_variant(
+ item,
+ rename_map={"a": "TooShort"},
+ question="question",
+ solution="solution",
)