mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-18 04:41:56 +00:00
Includes paired change: browser tool now searches ~/.hermes/node_modules/.bin/ for agent-browser installed via install.sh --ensure browser.
43 lines
1.9 KiB
Python
43 lines
1.9 KiB
Python
from pathlib import Path
|
|
from unittest.mock import patch
|
|
|
|
|
|
def test_ensure_dependency_skips_when_present():
|
|
"""ensure_dependency is a no-op when the dep is already available."""
|
|
from hermes_cli.dep_ensure import ensure_dependency
|
|
with patch("hermes_cli.dep_ensure.shutil") as mock_shutil:
|
|
mock_shutil.which.return_value = "/usr/bin/node"
|
|
result = ensure_dependency("node", interactive=False)
|
|
assert result is True
|
|
|
|
|
|
def test_ensure_dependency_returns_false_when_missing_noninteractive():
|
|
"""ensure_dependency returns False for missing dep in non-interactive mode."""
|
|
from hermes_cli.dep_ensure import ensure_dependency
|
|
with patch("hermes_cli.dep_ensure.shutil") as mock_shutil:
|
|
mock_shutil.which.return_value = None
|
|
with patch("hermes_cli.dep_ensure._find_install_script", return_value=None):
|
|
result = ensure_dependency("node", interactive=False)
|
|
assert result is False
|
|
|
|
|
|
def test_find_install_script_from_checkout(tmp_path):
|
|
"""_find_install_script finds scripts/install.sh in a git checkout."""
|
|
from hermes_cli.dep_ensure import _find_install_script
|
|
scripts_dir = tmp_path / "scripts"
|
|
scripts_dir.mkdir()
|
|
(scripts_dir / "install.sh").write_text("#!/bin/bash", encoding="utf-8")
|
|
result = _find_install_script(package_dir=tmp_path / "hermes_cli", repo_root=tmp_path)
|
|
assert result is not None
|
|
assert result.name == "install.sh"
|
|
|
|
|
|
def test_find_install_script_from_wheel(tmp_path):
|
|
"""_find_install_script finds bundled install.sh in a wheel."""
|
|
from hermes_cli.dep_ensure import _find_install_script
|
|
bundled = tmp_path / "hermes_cli" / "scripts"
|
|
bundled.mkdir(parents=True)
|
|
(bundled / "install.sh").write_text("#!/bin/bash", encoding="utf-8")
|
|
result = _find_install_script(package_dir=tmp_path / "hermes_cli", repo_root=tmp_path)
|
|
assert result is not None
|
|
assert result.name == "install.sh"
|