mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-10 18:35:48 +08:00
- 在 oclaw/ 下重新初始化 Git 仓库 - 补齐子仓库 .gitignore,避免提交本地运行态数据(_local、node_modules、logs 等) - 提交当前工程代码与配置 Made-with: Cursor
42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
from unittest.mock import patch
|
|
|
|
from oclaw.tools.base import ToolSpec
|
|
from oclaw.tools.catalog import materialize_tool_specs
|
|
|
|
|
|
def _mk_spec(name: str) -> ToolSpec:
|
|
return ToolSpec(
|
|
name=name,
|
|
description="d",
|
|
parameters={"type": "object", "properties": {}},
|
|
handler=lambda _args: {"ok": True},
|
|
tags=frozenset({"internal"}),
|
|
)
|
|
|
|
|
|
def test_catalog_loads_role_scoped_expert_tools() -> None:
|
|
with patch(
|
|
"oclaw.tools.catalog.materialize_tools_for_expert",
|
|
return_value=[_mk_spec("custom_tool_a"), _mk_spec("custom_tool_b")],
|
|
):
|
|
with patch("oclaw.tools.catalog.materialize_public_tools", return_value=[_mk_spec("system_time")]):
|
|
specs = materialize_tool_specs(expert="generalist")
|
|
names = {x.name for x in specs}
|
|
assert "system_time" in names
|
|
assert "custom_tool_a" in names
|
|
assert "custom_tool_b" in names
|
|
|
|
|
|
def test_catalog_deduplicates_same_tool_name() -> None:
|
|
with patch(
|
|
"oclaw.tools.catalog.materialize_tools_for_expert",
|
|
return_value=[_mk_spec("system_time"), _mk_spec("custom_tool_a")],
|
|
):
|
|
with patch("oclaw.tools.catalog.materialize_public_tools", return_value=[_mk_spec("system_time")]):
|
|
specs = materialize_tool_specs(expert="generalist")
|
|
names = [x.name for x in specs]
|
|
assert names.count("system_time") == 1
|
|
assert "custom_tool_a" in set(names)
|
|
|