import json from pathlib import Path from gallery.examples import ALL_EXAMPLES ROOT = Path(__file__).resolve().parents[1] def test_example_ids_are_unique() -> None: ids = [example.id for example in ALL_EXAMPLES] assert len(ids) == len(set(ids)) assert len(ids) >= 25 def test_every_example_builds_a_control() -> None: for example in ALL_EXAMPLES: assert example.builder() is not None, example.id def test_source_manifest_is_complete_and_exact() -> None: manifest_path = ROOT / "src" / "gallery" / "source_manifest.json" manifest = json.loads(manifest_path.read_text(encoding="utf-8")) assert set(manifest) == {example.id for example in ALL_EXAMPLES} for anchor in manifest.values(): source = (ROOT / anchor["path"]).read_text(encoding="utf-8").splitlines() assert source[anchor["line"] - 1].startswith(f"def {anchor['function']}(")