Files
yvgude--lean-ctx/integrations/hermes-lean-ctx/tests/test_registration.py
T
wehub-resource-sync 26382a7ac6
CI / Clippy (push) Failing after 15m13s
CI / Test (ubuntu-latest) (push) Failing after 16m1s
CI / Test (macos-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Build (no embeddings / no ORT) (push) Has been cancelled
CI / Format (push) Has been cancelled
CI / Cookbook (Node) (push) Has been cancelled
CI / Pi Extension (Node) (push) Has been cancelled
CI / Rust SDK (lean-ctx-client) (push) Has been cancelled
CI / Embed SDK (lean-ctx-sdk) (push) Has been cancelled
CI / Python SDK (leanctx) (push) Has been cancelled
CI / Hermes Plugin (Python) (push) Has been cancelled
CI / SDK Conformance Matrix (push) Has been cancelled
CI / Coverage (push) Has been cancelled
CI / cargo-deny (push) Has been cancelled
CI / Adversarial Safety (push) Has been cancelled
CI / Benchmarks (push) Has been cancelled
CI / Output-Quality Gate (eval A/B) (push) Has been cancelled
CI / Documentation (push) Has been cancelled
CI / CI Green (push) Has been cancelled
JetBrains Plugin / Actionlint (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
CodeQL / Analyze (rust) (push) Has been cancelled
JetBrains Plugin / Validation (push) Has been cancelled
JetBrains Plugin / Build (push) Has been cancelled
JetBrains Plugin / Test (push) Has been cancelled
Security Check / Security Scan (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:35:30 +08:00

47 lines
1.3 KiB
Python

"""Plugin registration entry point."""
from __future__ import annotations
from typing import Any, List
from agent.context_engine import ContextEngine
import hermes_lean_ctx
from hermes_lean_ctx.engine import LeanCtxEngine
class _RecorderCtx:
"""Minimal stand-in for the Hermes plugin context (host registration API)."""
def __init__(self) -> None:
self.engines: List[Any] = []
def register_context_engine(self, engine: Any) -> None:
self.engines.append(engine)
class _IncompatibleCtx:
"""A host without the context-engine registration hook."""
def test_register_registers_engine(monkeypatch):
monkeypatch.setenv("LEANCTX_BASE_URL", "http://127.0.0.1:9")
ctx = _RecorderCtx()
hermes_lean_ctx.register(ctx)
assert len(ctx.engines) == 1
engine = ctx.engines[0]
assert isinstance(engine, LeanCtxEngine)
assert isinstance(engine, ContextEngine)
assert engine.name == "lean-ctx"
def test_register_on_incompatible_host_does_not_raise(monkeypatch):
monkeypatch.setenv("LEANCTX_BASE_URL", "http://127.0.0.1:9")
# must not raise even though register_context_engine is absent
hermes_lean_ctx.register(_IncompatibleCtx())
def test_lazy_engine_export():
assert hermes_lean_ctx.LeanCtxEngine is LeanCtxEngine
assert hermes_lean_ctx.__version__