oclaw/tests/test_mcp_registry.py
oliver 4a23b715a2 重构仓库目录为统一的 runtime 分层并清理历史 openclaw 残留。
本次迁移将网关/通道/工具/技能/脚本与协议资源集中到新结构,统一路径常量与脚本转发机制,减少顶层噪音并保证运行与测试行为一致。

Made-with: Cursor
2026-04-25 01:24:23 +08:00

34 lines
1.1 KiB
Python

from __future__ import annotations
import tempfile
import unittest
from pathlib import Path
from oclaw.platform.persistence.sqlite_store import SqliteStore
from oclaw.runtime.tools.mcp.manifest import McpServerManifest
from oclaw.runtime.tools.mcp.registry import McpRegistry
class McpRegistryTests(unittest.TestCase):
def test_upsert_and_snapshot(self) -> None:
with tempfile.TemporaryDirectory(ignore_cleanup_errors=True) as td:
store = SqliteStore(str(Path(td) / "ops.sqlite"))
reg = McpRegistry(store)
reg.upsert_manifest(
McpServerManifest(
server_id="demo",
source_type="github",
source_ref="https://github.com/acme/demo",
entry_command="python",
entry_args=["-m", "demo"],
enabled=True,
)
)
snap = reg.snapshot()
self.assertEqual(int(snap["count"]), 1)
self.assertEqual(str(snap["servers"][0]["server_id"]), "demo")
if __name__ == "__main__":
unittest.main()