mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-16 15:30:47 +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
63
tests/test_mcp_e2e_probe.py
Normal file
63
tests/test_mcp_e2e_probe.py
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import unittest
|
||||
|
||||
from oclaw.admin.mcp_e2e_probe import build_mcp_e2e_probe_plans, parse_mcp_bound_tool_name
|
||||
from oclaw.tools.base import ToolRegistry, ToolSpec
|
||||
|
||||
|
||||
class McpE2eProbeTests(unittest.TestCase):
|
||||
def test_parse_mcp_bound_tool_name(self) -> None:
|
||||
self.assertEqual(parse_mcp_bound_tool_name("mcp__srv__ping"), ("srv", "ping"))
|
||||
self.assertIsNone(parse_mcp_bound_tool_name("read_file"))
|
||||
self.assertIsNone(parse_mcp_bound_tool_name("mcp__only"))
|
||||
|
||||
def test_build_plans_empty_registry(self) -> None:
|
||||
reg = ToolRegistry([])
|
||||
plans, skipped = build_mcp_e2e_probe_plans(reg, workspace_root="/tmp")
|
||||
self.assertEqual(plans, [])
|
||||
self.assertEqual(skipped, [])
|
||||
|
||||
def test_build_one_probe_per_server(self) -> None:
|
||||
def _h(_a):
|
||||
return {"ok": True}
|
||||
|
||||
reg = ToolRegistry(
|
||||
[
|
||||
ToolSpec(
|
||||
name="mcp__alpha__zebra",
|
||||
description="z",
|
||||
parameters={"type": "object", "properties": {}, "required": []},
|
||||
handler=_h,
|
||||
tags=frozenset({"mcp"}),
|
||||
),
|
||||
ToolSpec(
|
||||
name="mcp__alpha__apple",
|
||||
description="a",
|
||||
parameters={"type": "object", "properties": {}, "required": []},
|
||||
handler=_h,
|
||||
tags=frozenset({"mcp"}),
|
||||
),
|
||||
ToolSpec(
|
||||
name="mcp__beta__read_graph",
|
||||
description="g",
|
||||
parameters={"type": "object", "properties": {}, "required": []},
|
||||
handler=_h,
|
||||
tags=frozenset({"mcp"}),
|
||||
),
|
||||
]
|
||||
)
|
||||
plans, skipped = build_mcp_e2e_probe_plans(reg, workspace_root="/tmp")
|
||||
self.assertEqual(skipped, [])
|
||||
self.assertEqual(len(plans), 2)
|
||||
by_sid = {p[0]: p for p in plans}
|
||||
self.assertIn("alpha", by_sid)
|
||||
self.assertIn("beta", by_sid)
|
||||
# read_graph wins priority over apple/zebra for beta
|
||||
self.assertEqual(by_sid["beta"][1], "mcp__beta__read_graph")
|
||||
# alpha: apple before zebra lexicographically among equal priority
|
||||
self.assertEqual(by_sid["alpha"][1], "mcp__alpha__apple")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue