hello_world / tests /test_config_name_collisions.py
Matt Hartman
Initial commit
719d94f
from pathlib import Path
import pytest
import hello_world.config as config_mod
def test_config_raises_on_external_profile_name_collision(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
"""Config should fail fast when external/built-in profile names collide."""
external_profiles = tmp_path / "external_profiles"
external_profiles.mkdir(parents=True)
(external_profiles / "default").mkdir()
monkeypatch.setattr(config_mod.Config, "PROFILES_DIRECTORY", external_profiles)
monkeypatch.setattr(config_mod.Config, "TOOLS_DIRECTORY", None)
with pytest.raises(RuntimeError, match="Ambiguous profile names"):
config_mod.Config()
def test_config_raises_on_external_tool_name_collision(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
"""Config should fail fast when external/built-in tool names collide."""
external_tools = tmp_path / "external_tools"
external_tools.mkdir(parents=True)
(external_tools / "dance.py").write_text("# collision with built-in dance tool\n", encoding="utf-8")
monkeypatch.setattr(config_mod.Config, "PROFILES_DIRECTORY", config_mod.DEFAULT_PROFILES_DIRECTORY)
monkeypatch.setattr(config_mod.Config, "TOOLS_DIRECTORY", external_tools)
with pytest.raises(RuntimeError, match="Ambiguous tool names"):
config_mod.Config()
def test_config_raises_when_selected_external_profile_is_missing(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
"""Config should fail fast when selected profile is absent from external root."""
external_profiles = tmp_path / "external_profiles"
external_profiles.mkdir(parents=True)
monkeypatch.setattr(config_mod.Config, "REACHY_MINI_CUSTOM_PROFILE", "missing_profile")
monkeypatch.setattr(config_mod.Config, "PROFILES_DIRECTORY", external_profiles)
monkeypatch.setattr(config_mod.Config, "TOOLS_DIRECTORY", None)
with pytest.raises(RuntimeError, match="Selected profile 'missing_profile' was not found"):
config_mod.Config()