Files
hermes-agent/tests/gateway/test_approvals_command.py
kshitijk4poor 1d70b4a489 chore: drop the last Honcho leftovers from core
The gateway lost its Honcho managers when Honcho left core (7e53b3ef82), but 26 test
files still stubbed runner._capture_gateway_honcho_if_configured,
_get_or_create_gateway_honcho, _shutdown_all_gateway_honcho, _honcho_managers and
_honcho_configs: attributes no production code reads. .env.example still listed
HONCHO_API_KEY as a core key; the plugin prompts for it on install. The profiles
guide described the profile hook as future work; Honcho 1.2.0 implements it.
2026-11-10 00:49:30 +05:30

59 lines
1.6 KiB
Python

"""Gateway contract and live dispatch for /approvals."""
from types import SimpleNamespace
from unittest.mock import AsyncMock, MagicMock, patch
import pytest
import hermes_yaml as yaml
import gateway.run as gateway_run
from gateway.config import Platform
from gateway.platforms.event import MessageEvent
from gateway.session import SessionSource
def _event(text: str = "/approvals") -> MessageEvent:
return MessageEvent(
text=text,
source=SessionSource(
platform=Platform.TELEGRAM,
user_id="user-1",
chat_id="chat-1",
chat_type="dm",
),
)
def _runner():
runner = object.__new__(gateway_run.GatewayRunner)
runner.config = SimpleNamespace(platforms={})
runner.hooks = MagicMock(loaded_hooks=[])
runner.hooks.emit = AsyncMock(return_value=[])
runner._running_agents = {}
runner._is_user_authorized = lambda _source: True
runner.session_store = SimpleNamespace(get_or_create_session=lambda _source: None)
return runner
@pytest.mark.asyncio
async def test_gateway_rejects_non_admin_persistent_approval_change():
runner = _runner()
runner.config = SimpleNamespace(
platforms={
Platform.TELEGRAM: SimpleNamespace(
extra={
"allow_admin_from": ["admin-1"],
"user_allowed_commands": ["approvals"],
}
)
}
)
with patch("hermes_cli.approval_mode.run_approval_mode_command") as run:
output = await runner._handle_approvals_command(_event("/approvals off"))
assert "admin" in output.lower()
run.assert_not_called()