60 lines
2.3 KiB
Python
60 lines
2.3 KiB
Python
from pathlib import Path
|
|
import pytest
|
|
from categorizer import FixtureClass, Speed, auto_classify
|
|
|
|
def _write(tmp_path: Path, name: str, content: str) -> Path:
|
|
p = tmp_path / name
|
|
p.write_text(content, encoding="utf-8")
|
|
return p
|
|
|
|
def test_auto_classify_clean_install_filename(tmp_path: Path) -> None:
|
|
p = _write(tmp_path, "test_clean_install.py", "def test_x(): pass\n")
|
|
r = auto_classify(p)
|
|
assert r.fixture_class == FixtureClass.OPT_IN
|
|
|
|
def test_auto_classify_docker_build_filename(tmp_path: Path) -> None:
|
|
p = _write(tmp_path, "test_docker_build.py", "def test_x(): pass\n")
|
|
r = auto_classify(p)
|
|
assert r.fixture_class == FixtureClass.OPT_IN
|
|
|
|
def test_auto_classify_live_gui_fixture_in_source(tmp_path: Path) -> None:
|
|
p = _write(tmp_path, "test_x.py", "def test_x(live_gui): pass\n")
|
|
r = auto_classify(p)
|
|
assert r.fixture_class == FixtureClass.LIVE_GUI
|
|
|
|
def test_auto_classify_mock_app_fixture_in_source(tmp_path: Path) -> None:
|
|
p = _write(tmp_path, "test_x.py", "def test_x(mock_app): pass\n")
|
|
r = auto_classify(p)
|
|
assert r.fixture_class == FixtureClass.MOCK_APP
|
|
|
|
def test_auto_classify_perf_keyword_in_filename(tmp_path: Path) -> None:
|
|
p = _write(tmp_path, "test_xyz_stress.py", "def test_x(): pass\n")
|
|
r = auto_classify(p)
|
|
assert r.fixture_class == FixtureClass.PERFORMANCE
|
|
|
|
def test_auto_classify_default_to_unit(tmp_path: Path) -> None:
|
|
p = _write(tmp_path, "test_command_palette.py", "def test_x(): pass\n")
|
|
r = auto_classify(p)
|
|
assert r.fixture_class == FixtureClass.UNIT
|
|
|
|
def test_subsystem_inference_known_prefix(tmp_path: Path) -> None:
|
|
p = _write(tmp_path, "test_mcp_client_foo.py", "def test_x(): pass\n")
|
|
r = auto_classify(p)
|
|
assert "mcp" in r.subsystems
|
|
|
|
def test_speed_inference_from_durations_fast(tmp_path: Path) -> None:
|
|
p = _write(tmp_path, "test_x.py", "def test_x(): pass\n")
|
|
durations = {f"{p.name}::test_x": 0.05}
|
|
r = auto_classify(p, durations=durations)
|
|
assert r.speed == Speed.FAST
|
|
|
|
def test_speed_default_medium_without_durations(tmp_path: Path) -> None:
|
|
p = _write(tmp_path, "test_x.py", "def test_x(): pass\n")
|
|
r = auto_classify(p)
|
|
assert r.speed == Speed.MEDIUM
|
|
|
|
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"
|