oclaw/tests/test_mcp_registry.py
oliver 420abac9f1 refactor: root-package imports (svc/runtime/interfaces) and fix PYTHONPATH
- Rename platform/ to svc/ to avoid shadowing stdlib platform.
- Replace from oclaw.* with from svc/runtime/interfaces; update -m CLI paths.
- tests/conftest: prepend repo root to sys.path (no parent-folder package name).
- CI: paths and offline_eval script under repo root.
- Ops scripts: PYTHONPATH must be repo root for python -m runtime.* (fixes gateway/WhatsApp sidecar startup).
- Fix default oclaw.json path in tabular/file attachment limits; stabilize attachment test config.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-13 14:51:17 +08:00

34 lines
1.1 KiB
Python

from __future__ import annotations
import tempfile
import unittest
from pathlib import Path
from svc.persistence.sqlite_store import SqliteStore
from runtime.tools.mcp.manifest import McpServerManifest
from 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()