f6938b37f3
tools/terminal_tool.py: drop 30 pure re-export names (lifecycle/config/backends/
sudo/guards/result/interrupt/utils/_DockerEnvironment/is_managed_tool_gateway_ready)
and the noqa-F401 comments on the 25 names the facade itself uses. Sibling modules
(terminal_tool_backends/_result/_sudo/_lifecycle, environments/base, process_registry)
that read removed names through the facade now import from the defining module.
tools/environments/base.py: drop 11 re-exports (base_output/base_session_env/
path_utils) and the BaseEnvironment.stop() compat alias (no in-tree caller; the
lifecycle hasattr(env, 'stop') fallback stays for third-party envs).
tools/environments/docker.py: drop 1 re-export + the re-export comment.
Callers/tests repointed to tools.terminal_tool_{lifecycle,backends,sudo,config,
guards,result}, tools.interrupt, tools.environments.{base_output,base_session_env,
path_utils}.
76 lines
2.1 KiB
Python
76 lines
2.1 KiB
Python
"""Tests for MCP tools interactive configuration in hermes_cli.tools_config."""
|
|
|
|
from unittest.mock import patch
|
|
|
|
from hermes_cli.tools_config import _configure_mcp_tools_interactive
|
|
|
|
# Patch targets: imports happen inside the function body, so patch at source
|
|
_PROBE = "tools.mcp_tool_discovery.probe_mcp_server_tools"
|
|
_CHECKLIST = "hermes_cli.curses_ui.curses_checklist"
|
|
_SAVE = "hermes_cli.tools_config.save_config"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_disabling_tool_writes_include_list(capsys):
|
|
"""Unchecking a tool produces an include list of the still-chosen tools.
|
|
|
|
Standardized on tools.include (whitelist) across the codebase — the
|
|
catalog flow, `hermes mcp configure`, and this UI all write the same
|
|
shape so users don\'t see config drift across UIs.
|
|
"""
|
|
config = {
|
|
"mcp_servers": {
|
|
"github": {"command": "npx"},
|
|
}
|
|
}
|
|
tools = [
|
|
("create_issue", "Create an issue"),
|
|
("delete_repo", "Delete a repo"),
|
|
("search_repos", "Search repos"),
|
|
]
|
|
|
|
# User unchecks delete_repo (index 1)
|
|
with patch(_PROBE, return_value={"github": tools}), \
|
|
patch(_CHECKLIST, return_value={0, 2}), \
|
|
patch(_SAVE) as mock_save:
|
|
_configure_mcp_tools_interactive(config)
|
|
|
|
mock_save.assert_called_once()
|
|
tools_cfg = config["mcp_servers"]["github"]["tools"]
|
|
assert tools_cfg["include"] == ["create_issue", "search_repos"]
|
|
assert "exclude" not in tools_cfg
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_empty_tools_server_skipped(capsys):
|
|
"""Server with no tools shows info message and skips checklist."""
|
|
config = {
|
|
"mcp_servers": {
|
|
"empty": {"command": "npx"},
|
|
}
|
|
}
|
|
checklist_calls = []
|
|
|
|
def fake_checklist(title, labels, pre_selected, **kwargs):
|
|
checklist_calls.append(title)
|
|
return pre_selected
|
|
|
|
with patch(_PROBE, return_value={"empty": []}), \
|
|
patch(_CHECKLIST, side_effect=fake_checklist), \
|
|
patch(_SAVE):
|
|
_configure_mcp_tools_interactive(config)
|
|
|
|
assert len(checklist_calls) == 0
|
|
captured = capsys.readouterr()
|
|
assert "no tools found" in captured.out
|