mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-30 19:09:28 +00:00
Systematic prune per AGENTS.md test policy, one pass over every major test tree (gateway, hermes_cli, tools, agent, run_agent, plugins, cli, cron, tui_gateway, honcho/openviking, root-level): - DELETE: source-reading tests (read_text/getsource on prod files), change-detector tests (exact catalog counts, model-name snapshots, config version literals), mock-echo tests (assert a mock returns what it was told), assertion-free/trivial tests, near-duplicate parametrizations (boundaries + one representative kept), async/sync twin duplicates, cosmetic within-file variations. - KEEP (mandatory): security/redaction/approval guards, message-role alternation invariants, prompt-caching/deterministic-call-id invariants, issue-number regression tests (deduped), E2E tests. - 6 test files deleted outright (script-style/no-assert or fully redundant); conftest.py, fakes/, fixtures/ untouched. - tests/acp/conftest.py added: autouse fixture stubs the live models.dev/GitHub/Copilot/Anthropic inventory fetches that ACP server tests performed on every session create — test_server.py 147s → 3.4s, and the tests are now genuinely hermetic. - Sleep-based slowness shrunk where safe (codex_ttfb_watchdog, compression_concurrent_fork, etc.); no wall-clock assertion tightened. Verification: full hermetic suite via scripts/run_tests.sh — 2439 files, 31,130 tests passed, 0 failed, 0 flaky retries, 315s wall (baseline: 583s wall, 13,564s subprocess CPU).
89 lines
2.8 KiB
Python
89 lines
2.8 KiB
Python
from types import SimpleNamespace
|
||
from unittest.mock import MagicMock, patch
|
||
|
||
from cli import HermesCLI, _rich_text_from_ansi
|
||
from hermes_cli.skin_engine import get_active_skin, set_active_skin
|
||
|
||
|
||
def _make_cli_stub():
|
||
cli = HermesCLI.__new__(HermesCLI)
|
||
cli._sudo_state = None
|
||
cli._secret_state = None
|
||
cli._approval_state = None
|
||
cli._clarify_state = None
|
||
cli._clarify_freetext = False
|
||
cli._command_running = False
|
||
cli._agent_running = False
|
||
cli._voice_recording = False
|
||
cli._voice_processing = False
|
||
cli._voice_mode = False
|
||
cli._command_spinner_frame = lambda: "⟳"
|
||
cli._tui_style_base = {
|
||
"prompt": "#fff",
|
||
"input-area": "#fff",
|
||
"input-rule": "#aaa",
|
||
"prompt-working": "#888 italic",
|
||
}
|
||
cli._app = SimpleNamespace(style=None)
|
||
cli._invalidate = MagicMock()
|
||
return cli
|
||
|
||
|
||
class TestCliSkinPromptIntegration:
|
||
|
||
def test_ares_prompt_fragments_use_skin_symbol(self):
|
||
cli = _make_cli_stub()
|
||
|
||
set_active_skin("ares")
|
||
assert cli._get_tui_prompt_fragments() == [("class:prompt", "⚔ ")]
|
||
|
||
def test_secret_prompt_fragments_preserve_secret_state(self):
|
||
cli = _make_cli_stub()
|
||
cli._secret_state = {"response_queue": object()}
|
||
|
||
set_active_skin("ares")
|
||
assert cli._get_tui_prompt_fragments() == [("class:sudo-prompt", "🔑 ⚔ ")]
|
||
|
||
|
||
def test_narrow_terminals_compact_voice_recording_prompt_fragments(self):
|
||
cli = _make_cli_stub()
|
||
cli._voice_recording = True
|
||
cli._voice_recorder = SimpleNamespace(current_rms=3000)
|
||
|
||
with patch.object(HermesCLI, "_get_tui_terminal_width", return_value=50):
|
||
frags = cli._get_tui_prompt_fragments()
|
||
|
||
assert frags[0][0] == "class:voice-recording"
|
||
assert frags[0][1].startswith("●")
|
||
assert "❯" not in frags[0][1]
|
||
|
||
|
||
|
||
def test_apply_tui_skin_style_updates_running_app(self):
|
||
cli = _make_cli_stub()
|
||
|
||
set_active_skin("ares")
|
||
assert cli._apply_tui_skin_style() is True
|
||
assert cli._app.style is not None
|
||
cli._invalidate.assert_called_once_with(min_interval=0.0)
|
||
|
||
def test_handle_skin_command_refreshes_live_tui(self, capsys):
|
||
cli = _make_cli_stub()
|
||
|
||
with patch("cli.save_config_value", return_value=True):
|
||
cli._handle_skin_command("/skin ares")
|
||
|
||
output = capsys.readouterr().out
|
||
assert "Skin set to: ares (saved)" in output
|
||
assert "Prompt + TUI colors updated." in output
|
||
assert cli._app.style is not None
|
||
|
||
|
||
class TestAnsiRichTextHelper:
|
||
def test_preserves_literal_brackets(self):
|
||
text = _rich_text_from_ansi("[notatag] literal")
|
||
assert text.plain == "[notatag] literal"
|
||
|
||
def test_strips_ansi_but_keeps_plain_text(self):
|
||
text = _rich_text_from_ansi("\x1b[31mred\x1b[0m")
|
||
assert text.plain == "red"
|