mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-30 01:41:43 +00:00
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
54 lines
1.6 KiB
Python
54 lines
1.6 KiB
Python
from types import SimpleNamespace
|
|
from unittest.mock import patch
|
|
|
|
from hermes_agent.cli.config import (
|
|
format_managed_message,
|
|
get_managed_system,
|
|
recommended_update_command,
|
|
)
|
|
from hermes_agent.cli.main import cmd_update
|
|
from hermes_agent.tools.skills.hub import OptionalSkillSource
|
|
|
|
|
|
def test_get_managed_system_homebrew(monkeypatch):
|
|
monkeypatch.setenv("HERMES_MANAGED", "homebrew")
|
|
|
|
assert get_managed_system() == "Homebrew"
|
|
assert recommended_update_command() == "brew upgrade hermes-agent"
|
|
|
|
|
|
def test_format_managed_message_homebrew(monkeypatch):
|
|
monkeypatch.setenv("HERMES_MANAGED", "homebrew")
|
|
|
|
message = format_managed_message("update Hermes Agent")
|
|
|
|
assert "managed by Homebrew" in message
|
|
assert "brew upgrade hermes-agent" in message
|
|
|
|
|
|
def test_recommended_update_command_defaults_to_hermes_update(monkeypatch):
|
|
monkeypatch.delenv("HERMES_MANAGED", raising=False)
|
|
|
|
assert recommended_update_command() == "hermes update"
|
|
|
|
|
|
def test_cmd_update_blocks_managed_homebrew(monkeypatch, capsys):
|
|
monkeypatch.setenv("HERMES_MANAGED", "homebrew")
|
|
|
|
with patch("hermes_agent.cli.main.subprocess.run") as mock_run:
|
|
cmd_update(SimpleNamespace())
|
|
|
|
assert not mock_run.called
|
|
captured = capsys.readouterr()
|
|
assert "managed by Homebrew" in captured.err
|
|
assert "brew upgrade hermes-agent" in captured.err
|
|
|
|
|
|
def test_optional_skill_source_honors_env_override(monkeypatch, tmp_path):
|
|
optional_dir = tmp_path / "optional-skills"
|
|
optional_dir.mkdir()
|
|
monkeypatch.setenv("HERMES_OPTIONAL_SKILLS", str(optional_dir))
|
|
|
|
source = OptionalSkillSource()
|
|
|
|
assert source._optional_dir == optional_dir
|