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.
109 lines
3.6 KiB
Python
109 lines
3.6 KiB
Python
"""Tests for wildpc info command."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
from argparse import Namespace
|
|
from pathlib import Path
|
|
from unittest.mock import patch
|
|
|
|
|
|
class TestInfoCommand:
|
|
"""Tests for the info command."""
|
|
|
|
def test_info_service(self, wildpc_root: Path, capsys) -> None:
|
|
"""Show info for a service."""
|
|
from wildpc_cli.config import load_config
|
|
|
|
with patch("wildpc_cli.commands.info.load_config") as mock_load:
|
|
mock_load.return_value = load_config(wildpc_root)
|
|
|
|
from wildpc_cli.commands.info import run_info
|
|
|
|
result = run_info(Namespace(name="test-svc", json=False))
|
|
|
|
assert result == 0
|
|
output = capsys.readouterr().out
|
|
assert "test-svc" in output
|
|
assert "service" in output
|
|
assert "19000" in output
|
|
|
|
def test_info_tool(self, wildpc_root: Path, capsys) -> None:
|
|
"""Show info for a tool."""
|
|
from wildpc_cli.config import load_config
|
|
|
|
with patch("wildpc_cli.commands.info.load_config") as mock_load:
|
|
mock_load.return_value = load_config(wildpc_root)
|
|
|
|
from wildpc_cli.commands.info import run_info
|
|
|
|
result = run_info(Namespace(name="test-tool", json=False))
|
|
|
|
assert result == 0
|
|
output = capsys.readouterr().out
|
|
assert "test-tool" in output
|
|
assert "tool" in output
|
|
|
|
def test_info_not_found(self, wildpc_root: Path, capsys) -> None:
|
|
"""Info for nonexistent component returns error."""
|
|
from wildpc_cli.config import load_config
|
|
|
|
with patch("wildpc_cli.commands.info.load_config") as mock_load:
|
|
mock_load.return_value = load_config(wildpc_root)
|
|
|
|
from wildpc_cli.commands.info import run_info
|
|
|
|
result = run_info(Namespace(name="nope", json=False))
|
|
|
|
assert result == 1
|
|
output = capsys.readouterr().out
|
|
assert "nope" in output
|
|
|
|
def test_info_json_service(self, wildpc_root: Path, capsys) -> None:
|
|
"""--json produces valid JSON with service fields."""
|
|
from wildpc_cli.config import load_config
|
|
|
|
with patch("wildpc_cli.commands.info.load_config") as mock_load:
|
|
mock_load.return_value = load_config(wildpc_root)
|
|
|
|
from wildpc_cli.commands.info import run_info
|
|
|
|
result = run_info(Namespace(name="test-svc", json=True))
|
|
|
|
assert result == 0
|
|
output = capsys.readouterr().out
|
|
data = json.loads(output)
|
|
assert data["kind"] == "service"
|
|
assert data["service"]["expose"]["http"]["internal"]["port"] == 19000
|
|
|
|
def test_info_shows_env(self, wildpc_root: Path, capsys) -> None:
|
|
"""Info displays environment variables."""
|
|
from wildpc_cli.config import load_config
|
|
|
|
with patch("wildpc_cli.commands.info.load_config") as mock_load:
|
|
mock_load.return_value = load_config(wildpc_root)
|
|
|
|
from wildpc_cli.commands.info import run_info
|
|
|
|
result = run_info(Namespace(name="test-svc", json=False))
|
|
|
|
assert result == 0
|
|
output = capsys.readouterr().out
|
|
assert "TEST_SVC_DATA_DIR" in output
|
|
|
|
def test_info_shows_kind(self, wildpc_root: Path, capsys) -> None:
|
|
"""Info displays the derived kind."""
|
|
from wildpc_cli.config import load_config
|
|
|
|
with patch("wildpc_cli.commands.info.load_config") as mock_load:
|
|
mock_load.return_value = load_config(wildpc_root)
|
|
|
|
from wildpc_cli.commands.info import run_info
|
|
|
|
result = run_info(Namespace(name="test-svc", json=False))
|
|
|
|
assert result == 0
|
|
output = capsys.readouterr().out
|
|
assert "kind" in output
|
|
assert "service" in output
|