mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-18 04:41:56 +00:00
fix(tests): exercise profile-mode HERMES_HOME for honcho fallback
The cherry-picked tests from #6173 set HERMES_HOME outside Path.home()/.hermes, which forces get_default_hermes_root() down its Docker branch and returns HERMES_HOME directly — so _get_default_hermes_home() never resolves to the ~/.hermes directory the tests were trying to assert about. Rewire both tests to use the real profile layout (HERMES_HOME pointing at ~/.hermes/profiles/<name>) so _get_default_hermes_home() resolves back to ~/.hermes and the default-profile fallback is actually exercised.
This commit is contained in:
parent
d18618f48f
commit
c872f07c47
1 changed files with 16 additions and 11 deletions
|
|
@ -352,20 +352,23 @@ class TestResolveConfigPath:
|
|||
assert result == local_cfg
|
||||
|
||||
def test_falls_back_to_default_profile_when_no_local(self, tmp_path, monkeypatch):
|
||||
hermes_home = tmp_path / "hermes"
|
||||
hermes_home.mkdir()
|
||||
# Profile mode: HERMES_HOME points at ~/.hermes/profiles/<name>, so
|
||||
# _get_default_hermes_home() must resolve back to ~/.hermes — that's
|
||||
# the bug the HOME-anchored helper fixes (vs. blindly using Path.home()).
|
||||
fake_home = tmp_path / "fakehome"
|
||||
fake_home.mkdir()
|
||||
default_cfg = fake_home / ".hermes" / "honcho.json"
|
||||
default_cfg.parent.mkdir(parents=True)
|
||||
default_home = fake_home / ".hermes"
|
||||
profile_home = default_home / "profiles" / "work"
|
||||
profile_home.mkdir(parents=True)
|
||||
default_cfg = default_home / "honcho.json"
|
||||
default_cfg.write_text('{"apiKey": "default-key"}')
|
||||
|
||||
monkeypatch.setattr(Path, "home", lambda: fake_home)
|
||||
monkeypatch.setenv("HERMES_HOME", str(hermes_home))
|
||||
monkeypatch.setenv("HERMES_HOME", str(profile_home))
|
||||
|
||||
result = resolve_config_path()
|
||||
|
||||
assert _get_default_hermes_home() == fake_home / ".hermes"
|
||||
assert _get_default_hermes_home() == default_home
|
||||
assert result == default_cfg
|
||||
|
||||
def test_falls_back_to_global_without_hermes_home_env(self, tmp_path):
|
||||
|
|
@ -390,19 +393,21 @@ class TestResolveConfigPath:
|
|||
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()
|
||||
# Profile mode: from_global_config() reads the default-profile honcho.json
|
||||
# via the HOME-anchored helper, not Path.home() / ".hermes".
|
||||
fake_home = tmp_path / "fakehome"
|
||||
fake_home.mkdir()
|
||||
default_cfg = fake_home / ".hermes" / "honcho.json"
|
||||
default_cfg.parent.mkdir(parents=True)
|
||||
default_home = fake_home / ".hermes"
|
||||
profile_home = default_home / "profiles" / "work"
|
||||
profile_home.mkdir(parents=True)
|
||||
default_cfg = default_home / "honcho.json"
|
||||
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))
|
||||
monkeypatch.setenv("HERMES_HOME", str(profile_home))
|
||||
|
||||
config = HonchoClientConfig.from_global_config()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue