test(tui): pin approval-mode fixtures to env HERMES_HOME for canonical resolver

_load_approval_mode now delegates to tools.approval._get_approval_mode,
which reads config via hermes_cli.config.load_config — that path resolves
HERMES_HOME from the environment, not the server module's _hermes_home
attribute. The four approval-mode tests only monkeypatched the module
attribute, so the resolver silently read the developer/CI real config
(default 'smart') instead of the temp fixture. Behavior assertions are
unchanged (invalid → manual fail-safe, YAML off-bool → 'off', three-way
persist + live emit); the fixtures now also set HERMES_HOME so the
canonical read path sees the same temp config.
This commit is contained in:
teknium1 2026-07-29 10:57:16 -07:00 committed by Teknium
parent eff3b11eb2
commit c5d37bb95c
1 changed files with 16 additions and 0 deletions

View File

@ -5313,6 +5313,10 @@ def test_config_get_approval_mode_uses_smart_default_when_key_is_missing(
import yaml
monkeypatch.setattr(server, "_hermes_home", tmp_path)
# Point the canonical resolver (load_config → env HERMES_HOME) at the
# temp home too, so the smart default is asserted against THIS config
# rather than whatever the developer's real ~/.hermes happens to hold.
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
(tmp_path / "config.yaml").write_text(
yaml.safe_dump({"approvals": {"timeout": 15}})
)
@ -5329,6 +5333,11 @@ def test_config_get_approval_mode_fails_safe_to_manual_for_invalid_explicit_valu
import yaml
monkeypatch.setattr(server, "_hermes_home", tmp_path)
# _load_approval_mode delegates to the canonical resolver in
# tools.approval, which reads via hermes_cli.config.load_config —
# that path resolves HERMES_HOME from the environment, not
# server._hermes_home.
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
(tmp_path / "config.yaml").write_text(
yaml.safe_dump({"approvals": {"mode": "sometimes"}})
)
@ -5343,6 +5352,9 @@ def test_config_get_approval_mode_normalizes_yaml_off(tmp_path, monkeypatch):
import yaml
monkeypatch.setattr(server, "_hermes_home", tmp_path)
# See fail-safe test above: the canonical resolver reads via
# load_config, which resolves HERMES_HOME from the environment.
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
(tmp_path / "config.yaml").write_text(
yaml.safe_dump({"approvals": {"mode": False}})
)
@ -5359,6 +5371,10 @@ def test_config_set_approval_mode_persists_three_way_value_and_emits_live_status
import yaml
monkeypatch.setattr(server, "_hermes_home", tmp_path)
# config.set writes via server._hermes_home, but the post-write
# session.info emit resolves the effective mode through the canonical
# tools.approval resolver (load_config → env HERMES_HOME).
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
emitted = []
monkeypatch.setattr(server, "_emit", lambda *args: emitted.append(args))
server._sessions["sid"] = {"agent": object(), "session_key": "profile-session"}