Repo-side rename only (Phases 1-3 of the migration plan); the live box (~/.castle, systemd units, /data/castle, domains) is a separate cutover. - Slug `castle` -> `wildpc`: CLI command, module names (wildpc_core/cli/api), dist names, entry point `wildpc = wildpc_cli.main:main`. - Identifiers: CastleConfig/NATSClient/DirError/MDNS -> Wildpc*. - Env/constants: CASTLE_* -> WILDPC_*; ~/.castle -> ~/.wildpc, castle.yaml -> wildpc.yaml, /data/castle -> /data/wildpc. - Systemd UNIT_PREFIX castle- -> wildpc-; own programs castle-api/gateway/etc. - Display prose "Castle" -> "Wild PC" in docs, agent-guide files, README, frontend. - Package dirs and bootstrap yaml renamed via git mv; lockfiles regenerated; redundant nested uv.lock files dropped (workspace root lock is authoritative). Tests: core 273, cli 47, wildpc-api 120 all pass. Frontend type-checks + builds. Fixed a stale test fixture (secret_env_path kind arg) broken pre-rename.
61 lines
2.4 KiB
Python
61 lines
2.4 KiB
Python
"""Tests for the `wildpc tool` lens."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
from argparse import Namespace
|
|
from pathlib import Path
|
|
from unittest.mock import patch
|
|
|
|
|
|
def _config(wildpc_root: Path):
|
|
from wildpc_cli.config import load_config
|
|
|
|
return load_config(wildpc_root)
|
|
|
|
|
|
class TestToolList:
|
|
def test_list_includes_tool(self, wildpc_root: Path, capsys: object) -> None:
|
|
with patch("wildpc_cli.commands.tool.load_config", return_value=_config(wildpc_root)):
|
|
from wildpc_cli.commands.tool import run_tool_list
|
|
|
|
rc = run_tool_list(Namespace(json=False))
|
|
assert rc == 0
|
|
out = capsys.readouterr().out # type: ignore[attr-defined]
|
|
assert "test-tool" in out
|
|
# test-svc is a service (systemd), not a tool — must not appear.
|
|
assert "test-svc" not in out
|
|
|
|
def test_list_json_payload(self, wildpc_root: Path, capsys: object) -> None:
|
|
with patch("wildpc_cli.commands.tool.load_config", return_value=_config(wildpc_root)):
|
|
from wildpc_cli.commands.tool import run_tool_list
|
|
|
|
rc = run_tool_list(Namespace(json=True))
|
|
assert rc == 0
|
|
data = json.loads(capsys.readouterr().out) # type: ignore[attr-defined]
|
|
tool = next(t for t in data if t["name"] == "test-tool")
|
|
# The coding-assistant context payload.
|
|
for key in ("name", "executables", "description", "installed", "source"):
|
|
assert key in tool
|
|
assert isinstance(tool["executables"], list) and tool["executables"]
|
|
|
|
|
|
class TestToolInfo:
|
|
def test_info_json(self, wildpc_root: Path, capsys: object) -> None:
|
|
with patch("wildpc_cli.commands.tool.load_config", return_value=_config(wildpc_root)):
|
|
from wildpc_cli.commands.tool import run_tool_info
|
|
|
|
rc = run_tool_info(Namespace(name="test-tool", json=True))
|
|
assert rc == 0
|
|
data = json.loads(capsys.readouterr().out) # type: ignore[attr-defined]
|
|
assert data["name"] == "test-tool"
|
|
assert data["executables"]
|
|
|
|
def test_info_rejects_non_tool(self, wildpc_root: Path, capsys: object) -> None:
|
|
# test-svc is a service deployment, not a tool.
|
|
with patch("wildpc_cli.commands.tool.load_config", return_value=_config(wildpc_root)):
|
|
from wildpc_cli.commands.tool import run_tool_info
|
|
|
|
rc = run_tool_info(Namespace(name="test-svc", json=False))
|
|
assert rc == 1
|