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,62 @@
|
||||
"""Tests for gateway /yolo session scoping."""
|
||||
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
import gateway.run as gateway_run
|
||||
from gateway.config import Platform
|
||||
from gateway.platforms.base import MessageEvent
|
||||
from gateway.session import SessionSource
|
||||
from tools.approval import disable_session_yolo, is_session_yolo_enabled
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _clean_yolo_state(monkeypatch):
|
||||
monkeypatch.delenv("HERMES_YOLO_MODE", raising=False)
|
||||
disable_session_yolo("agent:main:telegram:dm:chat-a")
|
||||
disable_session_yolo("agent:main:telegram:dm:chat-b")
|
||||
yield
|
||||
monkeypatch.delenv("HERMES_YOLO_MODE", raising=False)
|
||||
disable_session_yolo("agent:main:telegram:dm:chat-a")
|
||||
disable_session_yolo("agent:main:telegram:dm:chat-b")
|
||||
|
||||
|
||||
def _make_runner():
|
||||
runner = object.__new__(gateway_run.GatewayRunner)
|
||||
runner.session_store = None
|
||||
runner.config = None
|
||||
return runner
|
||||
|
||||
|
||||
def _make_event(chat_id: str) -> MessageEvent:
|
||||
source = SessionSource(
|
||||
platform=Platform.TELEGRAM,
|
||||
user_id=f"user-{chat_id}",
|
||||
chat_id=chat_id,
|
||||
user_name="tester",
|
||||
chat_type="dm",
|
||||
)
|
||||
return MessageEvent(text="/yolo", source=source)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_yolo_command_toggles_only_current_session(monkeypatch):
|
||||
runner = _make_runner()
|
||||
|
||||
event_a = _make_event("chat-a")
|
||||
session_a = runner._session_key_for_source(event_a.source)
|
||||
session_b = runner._session_key_for_source(_make_event("chat-b").source)
|
||||
|
||||
result_on = await runner._handle_yolo_command(event_a)
|
||||
|
||||
assert "ON" in result_on
|
||||
assert is_session_yolo_enabled(session_a) is True
|
||||
assert is_session_yolo_enabled(session_b) is False
|
||||
assert os.environ.get("HERMES_YOLO_MODE") is None
|
||||
|
||||
result_off = await runner._handle_yolo_command(event_a)
|
||||
|
||||
assert "OFF" in result_off
|
||||
assert is_session_yolo_enabled(session_a) is False
|
||||
assert os.environ.get("HERMES_YOLO_MODE") is None
|
||||
Reference in New Issue
Block a user