"""Unit tests for navi.core.tool_executor."""
from navi.core.registry import ToolRegistry
from navi.core.tool_executor import ToolExecutor
from navi.llm.base import ToolCallRequest
from tests.conftest_factory import FakeTool
class TestToolExecutorMcpAliases:
async def test_executes_bare_mcp_tool_alias(self):
registry = ToolRegistry()
tool = FakeTool("mcp:gnexus-book:search_docs")
registry.register(tool, builtin=True)
executor = ToolExecutor(registry)
messages, images = await executor._execute_tool_calls(
[ToolCallRequest(id="1", name="search_docs", arguments={"query": "git"})],
[tool],
)
assert images == []
assert messages[0].name == "mcp:gnexus-book:search_docs"
assert messages[0].content == "executed mcp:gnexus-book:search_docs"
async def test_executes_mcp_tool_alias_with_underscore_server_name(self):
registry = ToolRegistry()
tool = FakeTool("mcp:gnexus-book:search_docs")
registry.register(tool, builtin=True)
executor = ToolExecutor(registry)
messages, images = await executor._execute_tool_calls(
[ToolCallRequest(id="1", name="mcp:gnexus_book:search_docs", arguments={"query": "git"})],
[tool],
)
assert images == []
assert messages[0].name == "mcp:gnexus-book:search_docs"
assert messages[0].content == "executed mcp:gnexus-book:search_docs"