Skip to content

Commit 415d7f5

Browse files
nesquenaclaude
andcommitted
fix(tests): mark YOLO endpoint tests agent-dependent so CI doesn't false-fail
The /api/session/yolo endpoint relies on tools.approval.{enable,disable, is_session}_yolo from hermes-agent. routes.py falls back to no-op lambdas when the import fails — so without the agent: * POST returns the input value echoed back ({"yolo_enabled": True}), making POST-only tests false-pass. * GET always returns False, breaking POST→GET round-trip tests like test_yolo_post_persists_within_session, which is exactly the test that's been failing on every CI run for over a day. This is the same pattern used by other agent-dependent endpoints (cron, skills) — mark the endpoint test classes with @requires_agent_modules so they auto-skip when tools.approval is not importable, and run normally in environments that have hermes-agent. The 17 static-analysis tests (slash command registration, HTML elements, CSS classes, i18n coverage) keep running everywhere — they don't need the agent. Local suite: 2564 passed, 7 skipped (the YOLO endpoint cluster) on agent-less environments. Will run all 24 in CI if hermes-agent is wired, or cleanly skip the 7 endpoint tests when not. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
1 parent e1a02d6 commit 415d7f5

1 file changed

Lines changed: 21 additions & 2 deletions

File tree

tests/test_issue467_yolo_mode_toggle.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import pathlib
1616
import pytest
1717

18+
from tests.conftest import requires_agent_modules
19+
1820
TEST_BASE = f"http://127.0.0.1:{os.environ.get('HERMES_WEBUI_TEST_PORT', '8788')}"
1921

2022

@@ -52,8 +54,16 @@ def _post(path, body=None, expect_ok=True):
5254

5355
# ── Backend endpoint tests ──
5456

57+
@requires_agent_modules
5558
class TestYoloEndpointGet:
56-
"""GET /api/session/yolo should return yolo_enabled state."""
59+
"""GET /api/session/yolo should return yolo_enabled state.
60+
61+
Agent-dependent: the endpoint reads from ``tools.approval._session_yolo``
62+
in the hermes-agent process. When the agent isn't installed, routes.py
63+
falls back to a no-op lambda that always returns ``False`` regardless of
64+
POST state — every assertion here would either silently false-pass or
65+
flake. Skip cleanly when modules aren't importable.
66+
"""
5767

5868
def test_yolo_get_returns_false_by_default(self):
5969
"""A fresh session should not have YOLO enabled."""
@@ -68,8 +78,17 @@ def test_yolo_get_requires_session_id(self):
6878
assert resp is not None
6979

7080

81+
@requires_agent_modules
7182
class TestYoloEndpointPost:
72-
"""POST /api/session/yolo should toggle YOLO for a session."""
83+
"""POST /api/session/yolo should toggle YOLO for a session.
84+
85+
Agent-dependent: the endpoint writes to ``tools.approval._session_yolo``
86+
in the hermes-agent process. Without the agent, routes.py falls back to
87+
a no-op lambda; the response shape ``{"yolo_enabled": <input>}`` echoes
88+
the request body, so naive POST-only tests false-pass. The
89+
``test_yolo_post_persists_within_session`` test catches this by reading
90+
state back via GET — it only succeeds when the agent is wired.
91+
"""
7392

7493
def test_yolo_post_enable(self):
7594
"""Enabling YOLO returns ok=True and yolo_enabled=True."""

0 commit comments

Comments
 (0)