refactor(tools_config): extract provider selection cluster into tools_config_providers
This commit is contained in:
+45
-1407
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -23,7 +23,7 @@ from hermes_cli.tools_config import (
|
|||||||
|
|
||||||
|
|
||||||
def _quiet(monkeypatch):
|
def _quiet(monkeypatch):
|
||||||
import hermes_cli.tools_config as tc
|
import hermes_cli.tools_config_providers as tc
|
||||||
|
|
||||||
monkeypatch.setattr(tc, "_print_success", lambda *a, **k: None)
|
monkeypatch.setattr(tc, "_print_success", lambda *a, **k: None)
|
||||||
monkeypatch.setattr(tc, "_print_info", lambda *a, **k: None, raising=False)
|
monkeypatch.setattr(tc, "_print_info", lambda *a, **k: None, raising=False)
|
||||||
@@ -80,11 +80,13 @@ def test_image_and_video_selectors_share_the_selection_contract(monkeypatch):
|
|||||||
def _quiet_reconfigure(monkeypatch):
|
def _quiet_reconfigure(monkeypatch):
|
||||||
"""Silence prints + model pickers for _reconfigure_provider paths."""
|
"""Silence prints + model pickers for _reconfigure_provider paths."""
|
||||||
import hermes_cli.tools_config as tc
|
import hermes_cli.tools_config as tc
|
||||||
|
import hermes_cli.tools_config_providers as tcp
|
||||||
|
|
||||||
monkeypatch.setattr(tc, "_print_success", lambda *a, **k: None)
|
monkeypatch.setattr(tcp, "_print_success", lambda *a, **k: None)
|
||||||
monkeypatch.setattr(tc, "_print_info", lambda *a, **k: None, raising=False)
|
monkeypatch.setattr(tcp, "_print_info", lambda *a, **k: None, raising=False)
|
||||||
monkeypatch.setattr(tc, "_print_warning", lambda *a, **k: None, raising=False)
|
monkeypatch.setattr(tcp, "_print_warning", lambda *a, **k: None, raising=False)
|
||||||
monkeypatch.setattr(tc, "_configure_imagegen_model", lambda *a, **k: None)
|
monkeypatch.setattr(tcp, "_configure_imagegen_model", lambda *a, **k: None)
|
||||||
|
# _configure_provider resolves the post-setup hook lazily from tools_config.
|
||||||
monkeypatch.setattr(tc, "_run_post_setup", lambda *a, **k: None, raising=False)
|
monkeypatch.setattr(tc, "_run_post_setup", lambda *a, **k: None, raising=False)
|
||||||
# Managed rows gate on live Portal auth — stub it green.
|
# Managed rows gate on live Portal auth — stub it green.
|
||||||
import hermes_cli.nous_subscription as ns
|
import hermes_cli.nous_subscription as ns
|
||||||
|
|||||||
@@ -886,13 +886,14 @@ def test_vision_picker_custom_endpoint(tmp_path, monkeypatch):
|
|||||||
"""Custom endpoint writes base_url+model to config and the key to env."""
|
"""Custom endpoint writes base_url+model to config and the key to env."""
|
||||||
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
|
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
|
||||||
import hermes_cli.tools_config as tc
|
import hermes_cli.tools_config as tc
|
||||||
|
import hermes_cli.tools_config_providers as tcp
|
||||||
from hermes_cli.config import load_config
|
from hermes_cli.config import load_config
|
||||||
|
|
||||||
seq = iter([2]) # Custom OpenAI-compatible endpoint
|
seq = iter([2]) # Custom OpenAI-compatible endpoint
|
||||||
prompts = iter(["https://my.endpoint/v1", "sk-secret", "my-vision-model"])
|
prompts = iter(["https://my.endpoint/v1", "sk-secret", "my-vision-model"])
|
||||||
with patch.object(tc, "_prompt_choice", side_effect=lambda *a, **k: next(seq)), \
|
with patch.object(tc, "_prompt_choice", side_effect=lambda *a, **k: next(seq)), \
|
||||||
patch.object(tc, "_prompt", side_effect=lambda *a, **k: next(prompts)), \
|
patch.object(tcp, "_prompt", side_effect=lambda *a, **k: next(prompts)), \
|
||||||
patch.object(tc, "save_env_value") as save_env, \
|
patch.object(tcp, "save_env_value") as save_env, \
|
||||||
patch.object(tc, "_toolset_has_keys", return_value=False):
|
patch.object(tc, "_toolset_has_keys", return_value=False):
|
||||||
tc._configure_vision_backend()
|
tc._configure_vision_backend()
|
||||||
|
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ class TestReconfigureWritesProvider:
|
|||||||
):
|
):
|
||||||
"""Env vars present and user accepts current value → still writes
|
"""Env vars present and user accepts current value → still writes
|
||||||
video_gen.provider via the post-env-vars branch."""
|
video_gen.provider via the post-env-vars branch."""
|
||||||
from hermes_cli import tools_config
|
from hermes_cli import tools_config, tools_config_providers
|
||||||
|
|
||||||
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
|
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
|
||||||
video_gen_registry.register_provider(_FakeVideoProvider("xai_fake"))
|
video_gen_registry.register_provider(_FakeVideoProvider("xai_fake"))
|
||||||
@@ -93,11 +93,11 @@ class TestReconfigureWritesProvider:
|
|||||||
# Picker prompts replaced — no TTY in tests.
|
# Picker prompts replaced — no TTY in tests.
|
||||||
monkeypatch.setattr(tools_config, "_prompt_choice", lambda *a, **kw: 0)
|
monkeypatch.setattr(tools_config, "_prompt_choice", lambda *a, **kw: 0)
|
||||||
# User presses Enter to keep the existing key.
|
# User presses Enter to keep the existing key.
|
||||||
monkeypatch.setattr(tools_config, "_prompt", lambda *a, **kw: "")
|
monkeypatch.setattr(tools_config_providers, "_prompt", lambda *a, **kw: "")
|
||||||
# Pretend the env var is already set so the reconfigure path
|
# Pretend the env var is already set so the reconfigure path
|
||||||
# hits the "Kept current" branch.
|
# hits the "Kept current" branch.
|
||||||
monkeypatch.setattr(
|
monkeypatch.setattr(
|
||||||
tools_config,
|
tools_config_providers,
|
||||||
"get_env_value",
|
"get_env_value",
|
||||||
lambda key: "sk-fake" if key == "XAI_FAKE_API_KEY" else "",
|
lambda key: "sk-fake" if key == "XAI_FAKE_API_KEY" else "",
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user