mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 05:50:44 +08:00
- 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>
50 lines
1.8 KiB
Python
50 lines
1.8 KiB
Python
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
import pytest
|
|
|
|
|
|
def test_netx_query_ume_ne_inventory_forwards_params(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
import runtime.tools.experts.network_ops.netx_tools as nt
|
|
|
|
calls: list[tuple[str, str, dict[str, Any] | None]] = []
|
|
|
|
def fake(method: str, path: str, *, params: dict[str, Any] | None = None) -> dict[str, Any]:
|
|
calls.append((method, path, params))
|
|
return {"ok": True, "data": {"total": 0, "page": 1, "page_size": 50, "items": []}}
|
|
|
|
monkeypatch.setattr(nt, "_http_json", fake)
|
|
spec = nt.netx_query_ume_ne_inventory_tool()
|
|
out = spec.handler({"keyword": "10.0.0", "page": 2, "page_size": 100})
|
|
assert out.get("ok") is True
|
|
assert len(calls) == 1
|
|
assert calls[0][0] == "GET"
|
|
assert calls[0][1] == "/v1/ume/inventory/ne"
|
|
assert calls[0][2] == {"page": 2, "page_size": 100, "keyword": "10.0.0"}
|
|
|
|
|
|
def test_netx_get_ume_ne_requires_id(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
import runtime.tools.experts.network_ops.netx_tools as nt
|
|
|
|
monkeypatch.setattr(nt, "_http_json", lambda *a, **k: {"ok": True, "data": {}})
|
|
spec = nt.netx_get_ume_ne_tool()
|
|
out = spec.handler({})
|
|
assert out.get("ok") is False
|
|
assert out.get("error_code") == "ne_id_required"
|
|
|
|
|
|
def test_netx_get_ume_ne_quotes_path(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
import runtime.tools.experts.network_ops.netx_tools as nt
|
|
|
|
paths: list[str] = []
|
|
|
|
def fake(method: str, path: str, *, params: dict[str, Any] | None = None) -> dict[str, Any]:
|
|
paths.append(path)
|
|
return {"ok": True, "data": {"ne_id": "x"}}
|
|
|
|
monkeypatch.setattr(nt, "_http_json", fake)
|
|
spec = nt.netx_get_ume_ne_tool()
|
|
nid = "550e8400-e29b-41d4-a716-446655440000"
|
|
spec.handler({"ne_id": nid})
|
|
assert paths == [f"/v1/ume/inventory/ne/{nid}"]
|