9735a5559e
Cover _USE_CASE_PLUGINS mapping, _suggest_plugins side effects, _build_system_base output for all name/purpose combinations, and GeneralConfig.purpose round-trip. Also update CLAUDE.md with the testing workflow rule. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
93 lines
2.9 KiB
Python
93 lines
2.9 KiB
Python
"""Tests for setup wizard personalization helpers."""
|
|
|
|
import pytest
|
|
|
|
|
|
def test_use_case_plugin_mapping_all_categories_have_entries():
|
|
from pyra.setup.wizard import _USE_CASE_PLUGINS
|
|
assert all(len(v) > 0 for v in _USE_CASE_PLUGINS.values())
|
|
|
|
|
|
def test_use_case_plugin_mapping_has_expected_categories():
|
|
from pyra.setup.wizard import _USE_CASE_PLUGINS
|
|
assert "Email" in _USE_CASE_PLUGINS
|
|
assert "Development & servers" in _USE_CASE_PLUGINS
|
|
assert "Research & web" in _USE_CASE_PLUGINS
|
|
|
|
|
|
def test_use_case_email_contains_email_plugin():
|
|
from pyra.setup.wizard import _USE_CASE_PLUGINS
|
|
assert "email" in _USE_CASE_PLUGINS["Email"]
|
|
|
|
|
|
def test_use_case_dev_contains_ssh_and_docker():
|
|
from pyra.setup.wizard import _USE_CASE_PLUGINS
|
|
assert "ssh_tool" in _USE_CASE_PLUGINS["Development & servers"]
|
|
assert "docker_tool" in _USE_CASE_PLUGINS["Development & servers"]
|
|
|
|
|
|
def test_use_case_file_management_contains_cloud_stores():
|
|
from pyra.setup.wizard import _USE_CASE_PLUGINS
|
|
plugins = _USE_CASE_PLUGINS["File management"]
|
|
assert "gdrive" in plugins
|
|
assert "onedrive" in plugins
|
|
assert "dropbox_tool" in plugins
|
|
|
|
|
|
def test_suggest_plugins_empty_use_cases_returns_early(monkeypatch):
|
|
calls = []
|
|
import pyra.setup.wizard as wiz
|
|
monkeypatch.setattr(wiz.console, "print", lambda *a, **kw: calls.append(a))
|
|
wiz._suggest_plugins([])
|
|
assert calls == []
|
|
|
|
|
|
def test_suggest_plugins_unknown_use_case_returns_early(monkeypatch):
|
|
calls = []
|
|
import pyra.setup.wizard as wiz
|
|
monkeypatch.setattr(wiz.console, "print", lambda *a, **kw: calls.append(a))
|
|
wiz._suggest_plugins(["Not a real category"])
|
|
assert calls == []
|
|
|
|
|
|
def test_suggest_plugins_valid_use_case_calls_print(monkeypatch):
|
|
calls = []
|
|
import pyra.setup.wizard as wiz
|
|
monkeypatch.setattr(wiz.console, "print", lambda *a, **kw: calls.append(str(a)))
|
|
wiz._suggest_plugins(["Email"])
|
|
assert len(calls) > 0
|
|
|
|
|
|
def test_suggest_plugins_panel_text_contains_plugin_name(monkeypatch):
|
|
from rich.panel import Panel
|
|
panels = []
|
|
|
|
import pyra.setup.wizard as wiz
|
|
|
|
def capture_print(*args, **kwargs):
|
|
for a in args:
|
|
if isinstance(a, Panel):
|
|
panels.append(a.renderable)
|
|
|
|
monkeypatch.setattr(wiz.console, "print", capture_print)
|
|
wiz._suggest_plugins(["Email"])
|
|
assert any("email" in str(p) for p in panels)
|
|
|
|
|
|
def test_suggest_plugins_multiple_categories(monkeypatch):
|
|
from rich.panel import Panel
|
|
panels = []
|
|
|
|
import pyra.setup.wizard as wiz
|
|
|
|
def capture_print(*args, **kwargs):
|
|
for a in args:
|
|
if isinstance(a, Panel):
|
|
panels.append(a.renderable)
|
|
|
|
monkeypatch.setattr(wiz.console, "print", capture_print)
|
|
wiz._suggest_plugins(["Email", "Development & servers"])
|
|
combined = " ".join(str(p) for p in panels)
|
|
assert "email" in combined
|
|
assert "ssh_tool" in combined
|