hermes-agent/tests/hermes_cli/test_launcher.py
alt-glitch 4b16341975 refactor(restructure): rewrite all imports for hermes_agent package
Rewrite all import statements, patch() targets, sys.modules keys,
importlib.import_module() strings, and subprocess -m references to use
hermes_agent.* paths.

Strip sys.path.insert hacks from production code (rely on editable install).
Update COMPONENT_PREFIXES for logger filtering.
Fix 3 hardcoded getLogger() calls to use __name__.
Update transport and tool registry discovery paths.
Update plugin module path strings.
Add legacy process-name patterns for gateway PID detection.
Add main() to skills_sync for console_script entry point.
Fix _get_bundled_dir() path traversal after move.

Part of #14182, #14183
2026-04-23 08:35:34 +05:30

42 lines
1.3 KiB
Python

"""Tests for the top-level `./hermes` launcher script."""
import runpy
import sys
import types
from pathlib import Path
def test_launcher_delegates_to_argparse_entrypoint(monkeypatch):
"""`./hermes` should use `hermes_cli.main`, not the legacy Fire wrapper."""
launcher_path = Path(__file__).resolve().parents[2] / "hermes"
called = []
fake_main_module = types.ModuleType("hermes_agent.cli.main")
def fake_main():
called.append("hermes_agent.cli.main")
fake_main_module.main = fake_main
monkeypatch.setitem(sys.modules, "hermes_agent.cli.main", fake_main_module)
fake_cli_module = types.ModuleType("cli")
def legacy_cli_main(*args, **kwargs):
raise AssertionError("launcher should not import cli.main")
fake_cli_module.main = legacy_cli_main
monkeypatch.setitem(sys.modules, "hermes_agent.cli.repl", fake_cli_module)
fake_fire_module = types.ModuleType("fire")
def legacy_fire(*args, **kwargs):
raise AssertionError("launcher should not invoke fire.Fire")
fake_fire_module.Fire = legacy_fire
monkeypatch.setitem(sys.modules, "fire", fake_fire_module)
monkeypatch.setattr(sys, "argv", [str(launcher_path), "hermes_agent.gateway", "status"])
runpy.run_path(str(launcher_path), run_name="__main__")
assert called == ["hermes_agent.cli.main"]