mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 00:40:45 +08:00
初始化:独立 oclaw 仓库首提交
- 在 oclaw/ 下重新初始化 Git 仓库 - 补齐子仓库 .gitignore,避免提交本地运行态数据(_local、node_modules、logs 等) - 提交当前工程代码与配置 Made-with: Cursor
This commit is contained in:
commit
ba3836f00f
579 changed files with 83112 additions and 0 deletions
42
tests/test_catalog_expert_role_loading.py
Normal file
42
tests/test_catalog_expert_role_loading.py
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
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)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue