Files
cad-Integration/CADDesigner-Code-main/test/test_builtin_file_tool_integration.py
2026-07-22 13:48:46 +08:00

56 lines
1.4 KiB
Python

import os
import sys
PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
if PROJECT_ROOT not in sys.path:
sys.path.insert(0, PROJECT_ROOT)
from agent.CADAgent import CADAgent
from tools import create_builtin_file_tools
from tools.code_tools import create_codegen_subagent_tools
def _tool_name(tool):
if hasattr(tool, "_tool"):
return tool._tool.name
return getattr(tool, "name", getattr(tool, "__name__", None))
def test_create_builtin_file_tools_exposes_simplellmfunc_file_tool_names(tmp_path):
tools = create_builtin_file_tools(tmp_path)
assert [tool.name for tool in tools] == [
"read_file",
"grep",
"sed",
"echo_into",
]
def test_codegen_subagent_tools_include_command_and_builtin_file_tools(tmp_path):
tools = create_codegen_subagent_tools(tmp_path)
assert [_tool_name(tool) for tool in tools] == [
"execute_command",
"sketch_pad_operations",
"read_file",
"grep",
"sed",
"echo_into",
]
def test_main_cad_agent_toolkit_exposes_codegen_specialist_not_low_level_file_tools():
agent = object.__new__(CADAgent)
toolkit = CADAgent.get_toolkit(agent)
names = [_tool_name(tool) for tool in toolkit]
assert "cad_code_generator" in names
assert "execute_command" in names
assert "read_file" not in names
assert "grep" not in names
assert "sed" not in names
assert "echo_into" not in names