Files
nanobot/tests/test_registry_native_execution.py
code-server d4abb3d06f
Build Nanobot OAuth / build (pull_request) Successful in 6m11s
Build Nanobot OAuth / cleanup (pull_request) Has been skipped
fix: update EditTool name in tests to match implementation
The EditTool20250728 uses the name "str_replace_based_edit_tool" but
tests were checking for the old name "str_replace_editor". This commit
updates all test expectations to use the correct tool name.

Changes:
-  Updated test_edit_tool.py to expect "str_replace_based_edit_tool"
-  Updated test_native_tools_registration.py for correct tool name
-  Updated test_registry_native_execution.py to execute with correct name
-  Removed computer tool assertion (intentionally disabled by default)

All 3 EditTool naming tests now pass.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-03-05 09:34:25 +00:00

58 lines
1.9 KiB
Python

"""Tests for registry execution of native tools."""
import pytest
import tempfile
from pathlib import Path
from nanobot.agent.tools.registry import ToolRegistry
from nanobot.agent.tools.anthropic import BashTool20250124, EditTool20250728
from nanobot.agent.tools.anthropic.base import ToolResult, CLIResult
@pytest.mark.asyncio
async def test_registry_executes_bash_tool():
"""Test registry can execute BashTool20250124 and returns ToolResult."""
registry = ToolRegistry()
registry.register(BashTool20250124())
result = await registry.execute("bash", {"command": "echo 'test'"})
assert isinstance(result, ToolResult)
assert result.output is not None
assert "test" in result.output
assert result.error is None
@pytest.mark.asyncio
async def test_registry_executes_edit_tool():
"""Test registry can execute EditTool20250728 and returns CLIResult."""
registry = ToolRegistry()
registry.register(EditTool20250728())
with tempfile.TemporaryDirectory() as tmpdir:
test_file = str(Path(tmpdir) / "test.txt")
result = await registry.execute("str_replace_based_edit_tool", {
"command": "create",
"path": test_file,
"file_text": "Hello, world!"
})
assert isinstance(result, CLIResult)
assert "created" in result.output.lower() or "success" in result.output.lower()
assert Path(test_file).exists()
assert Path(test_file).read_text() == "Hello, world!"
@pytest.mark.asyncio
async def test_registry_mixed_tools():
"""Test registry can execute both native and function tools in same registry."""
registry = ToolRegistry()
# Register native tool
registry.register(BashTool20250124())
# Execute native tool
result = await registry.execute("bash", {"command": "echo 'native'"})
assert isinstance(result, ToolResult)
assert "native" in result.output