Files
hermes-agent/tests/hermes_cli/test_setup_agent_settings.py
kshitijk4poor 680fa8a92d test(config): one parametrized every-seeder test + template parity, drop duplicates
The stack's regression tests pasted the same platform-parity loop into four
files and added eight cases for one invariant ("a seeded config must not
pin a global display key"), over the AGENTS.md invariant-test budget.

- assert_keeps_platform_display_defaults() in test_display_config.py is the
  single parity helper.
- test_shipped_template_keeps_every_platform_default moves out of
  TestYAMLNormalisation (it was attached there only by indentation) into
  TestInstallerSeededConfigThroughGatewayResolver, reuses _seed_like_installer
  and absorbs the _resolve_gateway_display_bool qqbot hop.
- test_config_edit_seed's test becomes the one parametrized every-seeder test:
  config edit (template / no template), `hermes setup agent` with Enter (the
  W1 leak fixed in this stack), _apply_default_agent_settings and blank slate.
  The per-file copies in test_setup_agent_settings / test_setup_blank_slate
  are removed.
- Dropped test_template_seeded_home_keeps_qqbot_reasoning_off (duplicate; its
  dead HERMES_HOME set + raising=False patch went with it) and
  test_show_reasoning_stays_a_known_config_key (change-detector for the
  rejected #121232 approach). The explicit opt-in control (#7148) stays.

On origin/main's production files the template test and all five seeder
cases fail; the control passes.
2026-09-24 17:59:37 +05:30

49 lines
1.8 KiB
Python

"""Tests for agent-settings copy in the interactive setup wizard."""
from hermes_cli.setup import setup_agent_settings
def test_setup_agent_settings_prefers_config_over_stale_env(tmp_path, monkeypatch, capsys):
"""Config.yaml wins even when a stale .env value disagrees.
Regression guard for the bug where `.env HERMES_MAX_ITERATIONS=60`
from an old `hermes setup` run shadowed `agent.max_turns: 500` in
config.yaml. The wizard must now display the config value.
"""
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
config = {
"agent": {"max_turns": 500}, # user bumped this in config.yaml
"display": {"tool_progress": "all"},
"compression": {"threshold": 0.50},
}
prompt_answers = iter(["500", "all", "0.5"])
# Simulate stale .env value — the wizard must ignore this.
monkeypatch.setattr(
"hermes_cli.setup.get_env_value",
lambda key: "60" if key == "HERMES_MAX_ITERATIONS" else "",
)
monkeypatch.setattr("hermes_cli.setup.prompt", lambda *args, **kwargs: next(prompt_answers))
monkeypatch.setattr("hermes_cli.setup.prompt_choice", lambda *args, **kwargs: 4)
monkeypatch.setattr("hermes_cli.setup.save_env_value", lambda *args, **kwargs: None)
removed_keys: list[str] = []
monkeypatch.setattr(
"hermes_cli.setup.remove_env_value",
lambda key: (removed_keys.append(key), True)[1],
)
monkeypatch.setattr("hermes_cli.setup.save_config", lambda *args, **kwargs: None)
setup_agent_settings(config)
out = capsys.readouterr().out
# Config value wins
assert "Press Enter to keep 500." in out
assert "Press Enter to keep 60." not in out
# And the stale .env entry gets cleaned up
assert "HERMES_MAX_ITERATIONS" in removed_keys