mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-18 04:41:56 +00:00
fix(honcho): respect HOME-anchored default profile fallback
This commit is contained in:
parent
4ca5e72444
commit
d18618f48f
2 changed files with 35 additions and 8 deletions
|
|
@ -6,6 +6,8 @@ import os
|
|||
from pathlib import Path
|
||||
from unittest.mock import patch, MagicMock
|
||||
|
||||
from hermes_cli.profiles import _get_default_hermes_home
|
||||
|
||||
import pytest
|
||||
|
||||
from plugins.memory.honcho.client import (
|
||||
|
|
@ -349,18 +351,22 @@ class TestResolveConfigPath:
|
|||
result = resolve_config_path()
|
||||
assert result == local_cfg
|
||||
|
||||
def test_falls_back_to_global_when_no_local(self, tmp_path):
|
||||
def test_falls_back_to_default_profile_when_no_local(self, tmp_path, monkeypatch):
|
||||
hermes_home = tmp_path / "hermes"
|
||||
hermes_home.mkdir()
|
||||
# No honcho.json in HERMES_HOME — also isolate ~/.hermes so
|
||||
# the default-profile fallback doesn't hit the real filesystem.
|
||||
fake_home = tmp_path / "fakehome"
|
||||
fake_home.mkdir()
|
||||
default_cfg = fake_home / ".hermes" / "honcho.json"
|
||||
default_cfg.parent.mkdir(parents=True)
|
||||
default_cfg.write_text('{"apiKey": "default-key"}')
|
||||
|
||||
with patch.dict(os.environ, {"HERMES_HOME": str(hermes_home)}), \
|
||||
patch.object(Path, "home", return_value=fake_home):
|
||||
result = resolve_config_path()
|
||||
assert result == fake_home / ".honcho" / "config.json"
|
||||
monkeypatch.setattr(Path, "home", lambda: fake_home)
|
||||
monkeypatch.setenv("HERMES_HOME", str(hermes_home))
|
||||
|
||||
result = resolve_config_path()
|
||||
|
||||
assert _get_default_hermes_home() == fake_home / ".hermes"
|
||||
assert result == default_cfg
|
||||
|
||||
def test_falls_back_to_global_without_hermes_home_env(self, tmp_path):
|
||||
fake_home = tmp_path / "fakehome"
|
||||
|
|
@ -383,6 +389,26 @@ class TestResolveConfigPath:
|
|||
assert resolve_global_config_path() == fake_home / ".honcho" / "config.json"
|
||||
assert resolve_config_path() == fake_home / ".honcho" / "config.json"
|
||||
|
||||
def test_from_global_config_uses_default_profile_fallback(self, tmp_path, monkeypatch):
|
||||
hermes_home = tmp_path / "hermes"
|
||||
hermes_home.mkdir()
|
||||
fake_home = tmp_path / "fakehome"
|
||||
fake_home.mkdir()
|
||||
default_cfg = fake_home / ".hermes" / "honcho.json"
|
||||
default_cfg.parent.mkdir(parents=True)
|
||||
default_cfg.write_text(json.dumps({
|
||||
"apiKey": "default-key",
|
||||
"workspace": "default-ws",
|
||||
}))
|
||||
|
||||
monkeypatch.setattr(Path, "home", lambda: fake_home)
|
||||
monkeypatch.setenv("HERMES_HOME", str(hermes_home))
|
||||
|
||||
config = HonchoClientConfig.from_global_config()
|
||||
|
||||
assert config.api_key == "default-key"
|
||||
assert config.workspace_id == "default-ws"
|
||||
|
||||
def test_from_global_config_uses_local_path(self, tmp_path):
|
||||
hermes_home = tmp_path / "hermes"
|
||||
hermes_home.mkdir()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue