diff --git a/tests/hermes_cli/test_25106_global_switch_persists_base_url_api_mode.py b/tests/hermes_cli/test_25106_global_switch_persists_base_url_api_mode.py index 6a1e2642f5ef..35b316a677bb 100644 --- a/tests/hermes_cli/test_25106_global_switch_persists_base_url_api_mode.py +++ b/tests/hermes_cli/test_25106_global_switch_persists_base_url_api_mode.py @@ -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