from __future__ import annotations import pytest from gap_pipeline.surface import ( apply_rename_map, create_surface_variant, validate_rename_map, ) 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_variant_changes_problem_and_solution(item) -> None: variant = create_surface_variant( item, "descriptive_long", {"a": "positiveScalar"}, ) 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=[], ) with pytest.raises(ValueError, match="one-to-one"): validate_rename_map( {"a": "sharedName", "b": "sharedName"}, existing_identifiers=["a", "b"], scientific_constants=[], )