mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-27 01:11:40 +00:00
Fix variable name breakage (run_agent, hermes_constants, etc.) where import rewriter changed 'import X' to 'import hermes_agent.Y' but test code still referenced 'X' as a variable name. Fix package-vs-module confusion (cli.auth, cli.models, cli.ui) where single files became directories. Fix hardcoded file paths in tests pointing to old locations. Fix tool registry to discover tools in subpackage directories. Fix stale import in hermes_agent/tools/__init__.py. Part of #14182, #14183
63 lines
2 KiB
Python
63 lines
2 KiB
Python
from unittest.mock import MagicMock, patch
|
|
|
|
|
|
def test_format_banner_version_label_without_git_state():
|
|
from hermes_agent.cli.ui import banner
|
|
|
|
with patch.object(banner, "get_git_banner_state", return_value=None):
|
|
value = banner.format_banner_version_label()
|
|
|
|
assert value == f"Hermes Agent v{banner.VERSION} ({banner.RELEASE_DATE})"
|
|
|
|
|
|
def test_format_banner_version_label_on_upstream_main():
|
|
from hermes_agent.cli.ui import banner
|
|
|
|
with patch.object(
|
|
banner,
|
|
"get_git_banner_state",
|
|
return_value={"upstream": "b2f477a3", "local": "b2f477a3", "ahead": 0},
|
|
):
|
|
value = banner.format_banner_version_label()
|
|
|
|
assert value.endswith("· upstream b2f477a3")
|
|
assert "local" not in value
|
|
|
|
|
|
def test_format_banner_version_label_with_carried_commits():
|
|
from hermes_agent.cli.ui import banner
|
|
|
|
with patch.object(
|
|
banner,
|
|
"get_git_banner_state",
|
|
return_value={"upstream": "b2f477a3", "local": "af8aad31", "ahead": 3},
|
|
):
|
|
value = banner.format_banner_version_label()
|
|
|
|
assert "upstream b2f477a3" in value
|
|
assert "local af8aad31" in value
|
|
assert "+3 carried commits" in value
|
|
|
|
|
|
def test_get_git_banner_state_reads_origin_and_head(tmp_path):
|
|
from hermes_agent.cli.ui import banner
|
|
|
|
repo_dir = tmp_path / "repo"
|
|
(repo_dir / ".git").mkdir(parents=True)
|
|
|
|
results = {
|
|
("git", "rev-parse", "--short=8", "origin/main"): MagicMock(returncode=0, stdout="b2f477a3\n"),
|
|
("git", "rev-parse", "--short=8", "HEAD"): MagicMock(returncode=0, stdout="af8aad31\n"),
|
|
("git", "rev-list", "--count", "origin/main..HEAD"): MagicMock(returncode=0, stdout="3\n"),
|
|
}
|
|
|
|
def fake_run(cmd, **kwargs):
|
|
key = tuple(cmd)
|
|
if key not in results:
|
|
raise AssertionError(f"unexpected command: {cmd}")
|
|
return results[key]
|
|
|
|
with patch("hermes_agent.cli.ui.banner.subprocess.run", side_effect=fake_run):
|
|
state = banner.get_git_banner_state(repo_dir)
|
|
|
|
assert state == {"upstream": "b2f477a3", "local": "af8aad31", "ahead": 3}
|