Skip to content

Commit a0e730b

Browse files
test(cli): update tests for mcp show removal
1 parent fd2c290 commit a0e730b

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

tests/integration/cli/test_cli_reporter_integration.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2378,3 +2378,62 @@ def test_mcp_show_servers_json_output(self):
23782378
server = data["servers"][0]
23792379
assert "name" in server, "Server should have 'name' key"
23802380
assert "hosts" in server, "Server should have 'hosts' key"
2381+
2382+
2383+
class TestMCPShowCommandRemoval:
2384+
"""Tests for mcp show command behavior after removal of legacy syntax.
2385+
2386+
Reference: R11 §5 (11-enhancing_show_command_v0.md) - Migration Path
2387+
2388+
These tests verify that:
2389+
1. 'hatch mcp show' without subcommand shows help/error
2390+
2. Invalid subcommands show appropriate error
2391+
"""
2392+
2393+
def test_mcp_show_without_subcommand_shows_help(self):
2394+
"""'hatch mcp show' without subcommand should show help message.
2395+
2396+
Reference: R11 §5.3 - Clean removal
2397+
"""
2398+
from hatch.cli.__main__ import _route_mcp_command
2399+
2400+
# Create args with no show_command
2401+
args = Namespace(
2402+
mcp_command="show",
2403+
show_command=None,
2404+
)
2405+
2406+
captured_output = io.StringIO()
2407+
with patch('sys.stdout', captured_output):
2408+
result = _route_mcp_command(args)
2409+
2410+
output = captured_output.getvalue()
2411+
2412+
# Should return error code
2413+
assert result == 1, "Should return error code when no subcommand"
2414+
2415+
# Should show helpful message
2416+
assert "hosts" in output or "servers" in output, \
2417+
"Error message should mention available subcommands"
2418+
2419+
def test_mcp_show_invalid_subcommand_error(self):
2420+
"""Invalid subcommand should show error message.
2421+
2422+
Reference: R11 §5.3 - Clean removal
2423+
"""
2424+
from hatch.cli.__main__ import _route_mcp_command
2425+
2426+
# Create args with invalid show_command
2427+
args = Namespace(
2428+
mcp_command="show",
2429+
show_command="invalid",
2430+
)
2431+
2432+
captured_output = io.StringIO()
2433+
with patch('sys.stdout', captured_output):
2434+
result = _route_mcp_command(args)
2435+
2436+
output = captured_output.getvalue()
2437+
2438+
# Should return error code
2439+
assert result == 1, "Should return error code for invalid subcommand"

0 commit comments

Comments
 (0)