All checks were successful
plugin-tests / test (push) Successful in 5s
Closes the documentation gap surfaced by the compliance audit. Plugin now
passes the "well organized + well documented" bar in addition to the
"protocol §10 compliant" bar.
Changes:
manifest.yaml bump plugin_version 0.1.0 → 0.2.0 · routes status: live ·
audio_processors section added · public_api adds
register_audio_attachment_processor · tested_versions
appended (v0.51.117, v0.51.118) · current_local synced
README.md Status table flipped from "TBD" to "live" everywhere ·
forced internal deps + test count surfaced
.env.example declares the 4 env vars the plugin reads at runtime
(HERMES_WEBUI_PYTHON_PLUGIN · HERMES_WEBUI_STT_URL/_KEY ·
BTE_BASE_URL · BTE_TENANT_ID)
CHANGELOG.md v0.1.0 (scaffold + vault + brand) · v0.2.0 (STT + mic +
loader API extension)
LICENSE proprietary, contact jp@svrnty.io; clarifies that runtime
integration with hermes-webui (MIT) is permitted
tests/integration/test_loader_contract.py
3 real assertions against the adjacent fork — 7-method
contract, register-our-plugin end-to-end, noop-when-env-unset
29/29 tests PASS (was 26; +3 integration).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
80 lines
2.9 KiB
Python
80 lines
2.9 KiB
Python
"""Integration test — plugin against a real hermes-webui fork checkout.
|
|
|
|
Skipped when hermes-webui isn't adjacent to the plugin repo (CI without the
|
|
fork mounted). Validates the loader hook actually loads + registers our 7
|
|
public-API methods + reports the audio processor on startup.
|
|
|
|
Run via: `pytest tests/integration -v` — make smoke uses the same harness.
|
|
"""
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
PLUGIN_REPO = Path(__file__).resolve().parents[2]
|
|
FORK_REPO = PLUGIN_REPO.parent / "hermes-webui"
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def loader():
|
|
"""Import the fork's loader. Skip cleanly when fork not adjacent."""
|
|
if not (FORK_REPO / "api" / "svrnty_plugin_loader.py").is_file():
|
|
pytest.skip(f"hermes-webui fork not at {FORK_REPO}; integration env required")
|
|
sys.path.insert(0, str(FORK_REPO))
|
|
try:
|
|
from api import svrnty_plugin_loader as loader_mod
|
|
except ImportError as e:
|
|
pytest.skip(f"loader import failed: {e}")
|
|
return loader_mod
|
|
|
|
|
|
def test_loader_exposes_seven_method_contract(loader):
|
|
"""Public API surface must be exactly 7 methods (per protocol §5.1)."""
|
|
api = loader._PluginAPI()
|
|
methods = {m for m in dir(api) if not m.startswith("_")}
|
|
expected = {
|
|
"register_route", "register_static", "inject_script",
|
|
"inject_stylesheet", "config_get", "logger",
|
|
"register_audio_attachment_processor",
|
|
}
|
|
assert methods == expected, (
|
|
f"loader API drift: missing={expected - methods} extra={methods - expected}. "
|
|
"Adding/removing methods requires a protocol PRD amendment."
|
|
)
|
|
|
|
|
|
def test_loader_register_wires_our_plugin(loader, monkeypatch):
|
|
"""End-to-end: env var → import this plugin → register() fires our 2 routes + processor."""
|
|
monkeypatch.setenv("HERMES_WEBUI_PYTHON_PLUGIN", "svrnty_hermes_webui_plugin")
|
|
# Reset loader idempotency guard so we can re-run in-process
|
|
loader._LOADED = False
|
|
loader._ROUTES.clear()
|
|
loader._STATIC.clear()
|
|
loader._SCRIPTS.clear()
|
|
loader._STYLESHEETS.clear()
|
|
loader._AUDIO_PROCESSORS.clear()
|
|
|
|
sys.path.insert(0, str(PLUGIN_REPO))
|
|
loader.load_plugin()
|
|
|
|
# Routes registered: /api/transcribe (POST) + /api/vault/status (GET)
|
|
assert ("POST", "/api/transcribe") in loader._ROUTES
|
|
assert ("GET", "/api/vault/status") in loader._ROUTES
|
|
# Static + injected URLs
|
|
assert "svrnty" in loader._STATIC
|
|
assert "/plugins/svrnty/app.css" in loader._STYLESHEETS
|
|
assert "/plugins/svrnty/app.js" in loader._SCRIPTS
|
|
# Audio processor for voice-message transcription
|
|
assert len(loader._AUDIO_PROCESSORS) == 1
|
|
|
|
|
|
def test_loader_noop_when_env_unset(loader, monkeypatch):
|
|
"""No env var = no plugin loaded. Upstream behavior fully preserved."""
|
|
monkeypatch.delenv("HERMES_WEBUI_PYTHON_PLUGIN", raising=False)
|
|
loader._LOADED = False
|
|
loader._ROUTES.clear()
|
|
|
|
loader.load_plugin()
|
|
|
|
assert loader._ROUTES == {}, "plugin must NOT load when env var unset"
|