Initial import of NousResearch/hermes-agent
Deploy Site / deploy-vercel (push) Has been cancelled
Deploy Site / deploy-docs (push) Has been cancelled
Docker / shell lint / Lint Dockerfile (hadolint) (push) Has been cancelled
Docker / shell lint / Lint docker/ shell scripts (shellcheck) (push) Has been cancelled
Docker Build and Publish / build-amd64 (push) Has been cancelled
Docker Build and Publish / build-arm64 (push) Has been cancelled
Lint (ruff + ty) / ruff + ty diff (push) Has been cancelled
Lint (ruff + ty) / ruff enforcement (blocking) (push) Has been cancelled
Lint (ruff + ty) / Windows footguns (blocking) (push) Has been cancelled
Nix Lockfile Fix / auto-fix-main (push) Has been cancelled
Nix Lockfile Fix / fix (push) Has been cancelled
Nix / nix (macos-latest) (push) Has been cancelled
Nix / nix (ubuntu-latest) (push) Has been cancelled
OSV-Scanner / Scan lockfiles (push) Has been cancelled
Build Skills Index / build-index (push) Has been cancelled
Tests / test (1) (push) Has been cancelled
Tests / test (2) (push) Has been cancelled
Tests / test (3) (push) Has been cancelled
Tests / test (4) (push) Has been cancelled
Tests / test (5) (push) Has been cancelled
Tests / test (6) (push) Has been cancelled
Tests / e2e (push) Has been cancelled
uv.lock check / uv lock --check (push) Has been cancelled
Docker Build and Publish / merge (push) Has been cancelled
Build Skills Index / trigger-deploy (push) Has been cancelled
Tests / save-durations (push) Has been cancelled
Deploy Site / deploy-vercel (push) Has been cancelled
Deploy Site / deploy-docs (push) Has been cancelled
Docker / shell lint / Lint Dockerfile (hadolint) (push) Has been cancelled
Docker / shell lint / Lint docker/ shell scripts (shellcheck) (push) Has been cancelled
Docker Build and Publish / build-amd64 (push) Has been cancelled
Docker Build and Publish / build-arm64 (push) Has been cancelled
Lint (ruff + ty) / ruff + ty diff (push) Has been cancelled
Lint (ruff + ty) / ruff enforcement (blocking) (push) Has been cancelled
Lint (ruff + ty) / Windows footguns (blocking) (push) Has been cancelled
Nix Lockfile Fix / auto-fix-main (push) Has been cancelled
Nix Lockfile Fix / fix (push) Has been cancelled
Nix / nix (macos-latest) (push) Has been cancelled
Nix / nix (ubuntu-latest) (push) Has been cancelled
OSV-Scanner / Scan lockfiles (push) Has been cancelled
Build Skills Index / build-index (push) Has been cancelled
Tests / test (1) (push) Has been cancelled
Tests / test (2) (push) Has been cancelled
Tests / test (3) (push) Has been cancelled
Tests / test (4) (push) Has been cancelled
Tests / test (5) (push) Has been cancelled
Tests / test (6) (push) Has been cancelled
Tests / e2e (push) Has been cancelled
uv.lock check / uv lock --check (push) Has been cancelled
Docker Build and Publish / merge (push) Has been cancelled
Build Skills Index / trigger-deploy (push) Has been cancelled
Tests / save-durations (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
"""Gateway command help rendering tests."""
|
||||
|
||||
import pytest
|
||||
|
||||
from gateway.config import Platform
|
||||
from gateway.platforms.base import MessageEvent
|
||||
from gateway.session import SessionSource
|
||||
|
||||
|
||||
def _make_event(text: str, platform: Platform) -> MessageEvent:
|
||||
return MessageEvent(
|
||||
text=text,
|
||||
source=SessionSource(
|
||||
platform=platform,
|
||||
chat_id="chat-1",
|
||||
user_id="user-1",
|
||||
user_name="tester",
|
||||
chat_type="dm",
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def _make_runner():
|
||||
from gateway.run import GatewayRunner
|
||||
|
||||
return object.__new__(GatewayRunner)
|
||||
|
||||
|
||||
def test_start_is_known_gateway_command():
|
||||
"""Telegram sends /start automatically; gateway should intercept it as a no-op."""
|
||||
from hermes_cli.commands import GATEWAY_KNOWN_COMMANDS, resolve_command
|
||||
|
||||
cmd = resolve_command("start")
|
||||
assert "start" in GATEWAY_KNOWN_COMMANDS
|
||||
assert cmd is not None
|
||||
assert cmd.name == "start"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_help_sanitizes_slash_command_mentions_for_telegram(monkeypatch):
|
||||
"""Telegram help output must not expose invalid uppercase/hyphenated slashes."""
|
||||
monkeypatch.setattr(
|
||||
"agent.skill_commands.get_skill_commands",
|
||||
lambda: {
|
||||
"/Linear": {"description": "Open Linear"},
|
||||
"/Custom-Thing": {"description": "Run a custom thing"},
|
||||
},
|
||||
)
|
||||
|
||||
result = await _make_runner()._handle_help_command(
|
||||
_make_event("/help", Platform.TELEGRAM)
|
||||
)
|
||||
|
||||
assert "`/linear`" in result
|
||||
assert "`/custom_thing`" in result
|
||||
assert "`/Linear`" not in result
|
||||
assert "`/Custom-Thing`" not in result
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_commands_sanitizes_slash_command_mentions_for_telegram(monkeypatch):
|
||||
"""Paginated Telegram /commands output uses Telegram-valid slash mentions."""
|
||||
monkeypatch.setattr(
|
||||
"agent.skill_commands.get_skill_commands",
|
||||
lambda: {"/Linear": {"description": "Open Linear"}},
|
||||
)
|
||||
|
||||
result = await _make_runner()._handle_commands_command(
|
||||
_make_event("/commands 999", Platform.TELEGRAM)
|
||||
)
|
||||
|
||||
assert "`/linear`" in result
|
||||
assert "`/Linear`" not in result
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_help_keeps_non_telegram_slash_command_mentions_unchanged(monkeypatch):
|
||||
"""Only Telegram needs slash mentions rewritten to Telegram command names."""
|
||||
monkeypatch.setattr(
|
||||
"agent.skill_commands.get_skill_commands",
|
||||
lambda: {"/Linear": {"description": "Open Linear"}},
|
||||
)
|
||||
|
||||
result = await _make_runner()._handle_help_command(
|
||||
_make_event("/help", Platform.DISCORD)
|
||||
)
|
||||
|
||||
assert "`/Linear`" in result
|
||||
Reference in New Issue
Block a user