mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-22 16:25:58 +00:00
test(cli): cover picker-path persist_global=True in #25106 regression tests
hermes-sweeper review on #60970 flagged that _apply_model_switch_result (the interactive-picker sibling of _handle_model_switch) was only ever tested with persist_global=False elsewhere, so the picker's global-switch base_url/api_mode persistence branch had no coverage.
This commit is contained in:
parent
398634eeda
commit
e7f208fd74
1 changed files with 40 additions and 0 deletions
|
|
@ -118,3 +118,43 @@ def test_session_only_switch_does_not_touch_config(monkeypatch):
|
|||
cli_mod.HermesCLI._handle_model_switch(_StubCLI(), "/model MiniMax-M3 --session")
|
||||
|
||||
assert save_calls == []
|
||||
|
||||
|
||||
def _run_apply(monkeypatch, result, persist_global=True):
|
||||
"""Drives `_apply_model_switch_result` directly — the interactive-picker
|
||||
sibling of `_handle_model_switch`. Unlike the tests above, and unlike
|
||||
`test_apply_model_switch_result_context.py` (which only ever calls this
|
||||
method with `persist_global=False`), this exercises the `persist_global=True`
|
||||
branch that actually writes to config.yaml."""
|
||||
import cli as cli_mod
|
||||
|
||||
monkeypatch.setattr(cli_mod, "_cprint", lambda *a, **k: None)
|
||||
saved: dict[str, object] = {}
|
||||
|
||||
def _fake_save(key, value):
|
||||
saved[key] = value
|
||||
|
||||
monkeypatch.setattr(cli_mod, "save_config_value", _fake_save)
|
||||
cli_mod.HermesCLI._apply_model_switch_result(_StubCLI(), result, persist_global)
|
||||
return saved
|
||||
|
||||
|
||||
def test_picker_global_switch_persists_base_url_and_api_mode(monkeypatch):
|
||||
"""Picker-path counterpart of `test_global_switch_persists_base_url_and_api_mode`:
|
||||
`_apply_model_switch_result(..., persist_global=True)` must sync base_url/api_mode
|
||||
too, not just default/provider."""
|
||||
saved = _run_apply(monkeypatch, _make_result())
|
||||
|
||||
assert saved["model.default"] == "MiniMax-M3"
|
||||
assert saved["model.provider"] == "custom:minimax"
|
||||
assert saved["model.base_url"] == "https://api.minimax.io/v1"
|
||||
assert saved["model.api_mode"] == "chat_completions"
|
||||
|
||||
|
||||
def test_picker_global_switch_clears_base_url_and_api_mode_when_unresolved(monkeypatch):
|
||||
"""Picker-path counterpart of `test_global_switch_clears_base_url_and_api_mode_when_unresolved`."""
|
||||
result = _make_result(base_url="", api_mode="")
|
||||
saved = _run_apply(monkeypatch, result)
|
||||
|
||||
assert saved["model.base_url"] is None
|
||||
assert saved["model.api_mode"] is None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue