test(categorizer): add red tests for registry merge and full classification
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user