From 828050ae4f8a0276e17437aab45fb4eaf50ee524 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Mon, 8 Jun 2026 00:27:04 -0400 Subject: [PATCH] test(categorizer): add red tests for registry merge and full classification --- tests/test_categorizer.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/test_categorizer.py b/tests/test_categorizer.py index f15c1ea6..2e398c6c 100644 --- a/tests/test_categorizer.py +++ b/tests/test_categorizer.py @@ -57,3 +57,34 @@ def test_batch_group_inference_gui_subsystem(tmp_path: Path) -> None: p = _write(tmp_path, "test_gui_layout_foo.py", "def test_x(): pass\n") r = auto_classify(p) assert r.batch_group == "gui" + +import tomllib +from categorizer import load_registry, merge_registry, categorize_all + +def test_load_registry_returns_dict(tmp_path: Path) -> None: + toml = tmp_path / "reg.toml" + toml.write_text('[files.test_x]\nfixture_class = "mock_app"\n', encoding="utf-8") + reg = load_registry(toml) + assert "test_x" in reg + assert reg["test_x"]["fixture_class"] == "mock_app" + +def test_merge_registry_overrides_auto(tmp_path: Path) -> None: + p = _write(tmp_path, "test_x.py", "def test_x(): pass\n") + auto = auto_classify(p) + assert auto.fixture_class == FixtureClass.UNIT + reg_entry = {"fixture_class": "mock_app", "subsystems": ["x"], "speed": "fast", "batch_group": "x"} + merged = merge_registry(auto, reg_entry) + assert merged.fixture_class == FixtureClass.MOCK_APP + assert merged.source == "registry" + assert merged.subsystems == ["x"] + +def test_categorize_all_handles_real_tests_dir(tmp_path: Path) -> None: + (tmp_path / "test_a.py").write_text("def test_x(): pass\n", encoding="utf-8") + (tmp_path / "test_b_sim.py").write_text("def test_x(live_gui): pass\n", encoding="utf-8") + reg_path = tmp_path / "reg.toml" + reg_path.write_text("", encoding="utf-8") + records = categorize_all(tmp_path, reg_path) + assert len(records) == 2 + by_name = {r.filename: r for r in records} + assert by_name["test_a.py"].fixture_class == FixtureClass.UNIT + assert by_name["test_b_sim.py"].fixture_class == FixtureClass.LIVE_GUI