MCPcopy Create free account
hub / github.com/IBM/mcp-cli / mock_tool_manager

Function mock_tool_manager

tests/commands/definitions/test_execute_tool_command.py:36–61  ·  view source on GitHub ↗

Create a mock tool manager.

(mock_tool)

Source from the content-addressed store, hash-verified

34
35@pytest.fixture
36def mock_tool_manager(mock_tool):
37 """Create a mock tool manager."""
38 manager = AsyncMock()
39
40 # Mock another tool without required params
41 another_tool = MagicMock()
42 another_tool.name = "another_tool"
43 another_tool.namespace = "another_server"
44 another_tool.fully_qualified_name = "another_server.another_tool"
45 another_tool.inputSchema = (
46 None # Explicitly set to None to avoid MagicMock auto-creation
47 )
48 another_tool.parameters = {}
49
50 # Mock the async methods
51 manager.get_all_tools = AsyncMock(return_value=[mock_tool, another_tool])
52 manager.execute_tool = AsyncMock(
53 return_value=ToolCallResult(
54 tool_name="test_tool", success=True, result="Tool executed successfully"
55 )
56 )
57
58 # Add server_names as a regular dict, not AsyncMock
59 manager.server_names = {0: "test_server", 1: "another_server"}
60
61 return manager
62
63
64class TestExecuteToolCommand:

Callers

nothing calls this directly

Calls 1

ToolCallResultClass · 0.90

Tested by

no test coverage detected