99520c69d7
1.新增后端测试 2.增加了后端的加密 3.增加了i18n(国际化)
42 lines
1.5 KiB
Python
42 lines
1.5 KiB
Python
"""``plugin/tool_plugin`` 下各工具的元数据类正确性。
|
|
|
|
``BaseToolData`` 本身不带 ``name`` 字段;工具名以目录名为准(由 ``GlobalToolManager``
|
|
扫描时注入到 ``tool_metadata`` 中)。这里只验证子类对 BaseToolData 字段的覆写。
|
|
"""
|
|
|
|
from kilostar.plugin.tool_plugin.approval.approval import ApprovalToolData
|
|
from kilostar.plugin.tool_plugin.file_reader import FileReaderToolData
|
|
from kilostar.plugin.tool_plugin.tavily_search import TavilySearchToolData
|
|
|
|
|
|
def test_approval_metadata():
|
|
data = ApprovalToolData()
|
|
assert data.is_system is True
|
|
assert data.category == "system"
|
|
assert "control_node" in data.action_scope
|
|
assert "consciousness_node" in data.action_scope
|
|
|
|
|
|
def test_file_reader_metadata():
|
|
data = FileReaderToolData()
|
|
assert data.is_system is True
|
|
assert data.category == "system"
|
|
assert "control_node" in data.action_scope
|
|
|
|
|
|
def test_tavily_search_metadata():
|
|
data = TavilySearchToolData()
|
|
assert data.is_system is False
|
|
assert data.category == "search"
|
|
assert "control_node" in data.action_scope
|
|
assert "consciousness_node" in data.action_scope
|
|
# 默认配置 schema 含 api_key 字段(用于 GSM 配置面板)
|
|
assert "api_key" in data.config_args
|
|
|
|
|
|
def test_base_tool_extra_allowed():
|
|
"""``ConfigDict(extra="allow")`` 允许子类外的 KV 也能装进来。"""
|
|
data = ApprovalToolData(some_extension="ok") # type: ignore[call-arg]
|
|
assert data.model_extra is not None
|
|
assert data.model_extra.get("some_extension") == "ok"
|