mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-31 19:16:29 +00:00
Second, deeper pass over tools/gateway/hermes_cli plus first pass over the trees wave 1 missed (acp, acp_adapter, skills, computer_use, docker, dashboard, conformance, monitoring, secret_sources, hermes_state, providers). Same rubric as wave 1 (AGENTS.md test policy); security, alternation/caching invariants, issue-number regressions, and E2E kept. Real test-quality fixes found and rooted out along the way: - tests/tools/test_command_guards.py made real auxiliary-LLM HTTPS calls (DEFAULT_CONFIG smart-approval leaked in) — pinned approval mode=manual via autouse fixture: 17.4s → 0.4s. - test_model_switch_custom_providers.py / test_user_providers_model_switch.py silently probed live provider catalogs (~2s/test) — stubbed cached_provider_model_ids/provider_model_ids/fetch_api_models. - test_telegram_noise_filter.py: 15-platform copy-paste matrix over shared gateway.run logic → 3 representative platforms (55s → 3.9s). - test_gateway_shutdown.py: stop()'s 5s interrupt-deadline loop spun on MagicMock agents — interrupt.side_effect now clears _running_agents (22s → 1.0s). - test_gateway_inactivity_timeout.py poll-harness timings shrunk 3-5x (24s → 1.1s); test_mcp_stability.py backoff/SIGTERM-grace sleeps patched (15.4s → 2.5s); test_async_delegation.py negative-drain wait 5s → 0.5s. - test_telegram_init_deadline.py: loop-block margin restored to 1.0s with rationale comment — the watchdog-dump assertion needs the loop blocked well past deadline+grace under parallel load (flaked once in the 40-worker verification run at a 0.2s margin). Verification: full hermetic suite via scripts/run_tests.sh — 2,438 files, 21,718 tests passed, 0 failed, 293.9s wall. Suite totals vs original baseline: 46,820 → 19,757 test functions (−57.8%), wall 583.5s → 293.9s (−50%), subprocess CPU 13,564s → 11,623s.
112 lines
3.4 KiB
Python
112 lines
3.4 KiB
Python
"""Tests for hermes_cli.gui_uninstall — GUI-only uninstall + install discovery.
|
|
|
|
Covers the cross-platform artifact discovery, the agent/GUI detection the
|
|
desktop UI gates options on, and that ``uninstall_gui`` removes only GUI
|
|
artifacts (built renderer/release/node_modules, packaged bundle, Electron
|
|
userData) while leaving the Python agent + config/sessions/.env intact.
|
|
"""
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
import hermes_cli.gui_uninstall as gu
|
|
|
|
|
|
def _make_agent(hermes_home: Path) -> Path:
|
|
"""Create a fake agent install: source package + venv."""
|
|
agent_root = hermes_home / "hermes-agent"
|
|
(agent_root / "hermes_cli").mkdir(parents=True)
|
|
(agent_root / "hermes_cli" / "__init__.py").write_text("")
|
|
(agent_root / "venv" / "bin").mkdir(parents=True)
|
|
return agent_root
|
|
|
|
|
|
def _make_gui_build(hermes_home: Path) -> None:
|
|
"""Create the source-built GUI artifacts a `hermes desktop` run produces."""
|
|
desktop = hermes_home / "hermes-agent" / "apps" / "desktop"
|
|
(desktop / "dist").mkdir(parents=True)
|
|
(desktop / "dist" / "index.html").write_text("<html>")
|
|
(desktop / "release" / "linux-unpacked").mkdir(parents=True)
|
|
(desktop / "node_modules").mkdir(parents=True)
|
|
(hermes_home / "hermes-agent" / "node_modules").mkdir(parents=True)
|
|
(hermes_home / "desktop-build-stamp.json").write_text("{}")
|
|
|
|
|
|
def _make_user_data(hermes_home: Path) -> None:
|
|
(hermes_home / "config.yaml").write_text("x: 1\n")
|
|
(hermes_home / ".env").write_text("KEY=secret\n")
|
|
(hermes_home / "sessions").mkdir()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_gui_install_summary_shape(tmp_path, monkeypatch):
|
|
hermes_home = tmp_path / ".hermes"
|
|
_make_agent(hermes_home)
|
|
_make_gui_build(hermes_home)
|
|
monkeypatch.setattr(gu, "packaged_gui_app_paths", lambda: [])
|
|
monkeypatch.setattr(gu, "desktop_userdata_dir", lambda: tmp_path / "none")
|
|
|
|
summary = gu.gui_install_summary(hermes_home)
|
|
# JSON-serializable primitives the desktop UI gates on.
|
|
assert summary["agent_installed"] is True
|
|
assert summary["gui_installed"] is True
|
|
assert isinstance(summary["source_built_artifacts"], list)
|
|
assert all(isinstance(p, str) for p in summary["source_built_artifacts"])
|
|
assert summary["hermes_home"] == str(hermes_home)
|
|
assert summary["platform"] == sys.platform
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.skipif(sys.platform == "win32", reason="POSIX symlink semantics")
|
|
def test_remove_path_handles_symlink(tmp_path):
|
|
target = tmp_path / "real"
|
|
target.mkdir()
|
|
link = tmp_path / "link"
|
|
link.symlink_to(target)
|
|
assert gu._remove_path(link) is True
|
|
assert not link.exists()
|
|
# The symlink is gone but its target is untouched.
|
|
assert target.exists()
|
|
|
|
|
|
class _Args:
|
|
"""Minimal argparse-Namespace stand-in for run_uninstall."""
|
|
|
|
def __init__(self, *, yes=False, full=False, gui=False, gui_summary=False):
|
|
self.yes = yes
|
|
self.full = full
|
|
self.gui = gui
|
|
self.gui_summary = gui_summary
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_uninstall_args_namespace_mode_mapping():
|
|
"""_UninstallArgs maps mode → the gui/full flags run_uninstall reads."""
|
|
import hermes_cli.uninstall as uninstall
|
|
|
|
gui = uninstall._UninstallArgs(mode="gui")
|
|
assert gui.gui is True and gui.full is False and gui.yes is True
|
|
|
|
lite = uninstall._UninstallArgs(mode="lite")
|
|
assert lite.gui is False and lite.full is False and lite.yes is True
|
|
|
|
full = uninstall._UninstallArgs(mode="full")
|
|
assert full.gui is False and full.full is True and full.yes is True
|
|
|