mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-15 14:22:43 +00:00
test(model): isolate custom provider discovery
This commit is contained in:
parent
7628f2770a
commit
69f1460c3d
1 changed files with 66 additions and 0 deletions
|
|
@ -22,6 +22,7 @@ def test_list_authenticated_providers_includes_custom_providers(monkeypatch):
|
|||
"""No-args /model menus should include saved custom_providers entries."""
|
||||
monkeypatch.setattr("agent.models_dev.fetch_models_dev", lambda: {})
|
||||
monkeypatch.setattr(providers_mod, "HERMES_OVERLAYS", {})
|
||||
monkeypatch.setattr("hermes_cli.models.fetch_api_models", lambda *a, **k: [])
|
||||
|
||||
providers = list_authenticated_providers(
|
||||
current_provider="openai-codex",
|
||||
|
|
@ -313,6 +314,7 @@ def test_list_deduplicates_same_model_in_group(monkeypatch):
|
|||
duplicate entries in the models list."""
|
||||
monkeypatch.setattr("agent.models_dev.fetch_models_dev", lambda: {})
|
||||
monkeypatch.setattr(providers_mod, "HERMES_OVERLAYS", {})
|
||||
monkeypatch.setattr("hermes_cli.models.fetch_api_models", lambda *a, **k: [])
|
||||
|
||||
providers = list_authenticated_providers(
|
||||
current_provider="openrouter",
|
||||
|
|
@ -476,6 +478,70 @@ def test_custom_provider_current_only_probe_respects_explicit_catalog(monkeypatc
|
|||
assert rows["Static"]["models"] == ["only"]
|
||||
|
||||
|
||||
def test_custom_provider_current_explicit_catalog_skips_probe(monkeypatch):
|
||||
"""Current-only GUI probing must still honor an explicit catalog."""
|
||||
monkeypatch.setattr("agent.models_dev.fetch_models_dev", lambda: {})
|
||||
monkeypatch.setattr(providers_mod, "HERMES_OVERLAYS", {})
|
||||
calls = []
|
||||
|
||||
def fetch(*args, **kwargs):
|
||||
calls.append((args, kwargs))
|
||||
return ["unexpected-live-model"]
|
||||
|
||||
monkeypatch.setattr("hermes_cli.models.fetch_api_models", fetch)
|
||||
|
||||
providers = list_authenticated_providers(
|
||||
current_provider="custom:static",
|
||||
current_base_url="http://static.local/v1",
|
||||
user_providers={},
|
||||
custom_providers=[
|
||||
{
|
||||
"name": "Static",
|
||||
"base_url": "http://static.local/v1",
|
||||
"model": "only",
|
||||
"models": ["only"],
|
||||
}
|
||||
],
|
||||
probe_custom_providers=False,
|
||||
probe_current_custom_provider=True,
|
||||
)
|
||||
|
||||
assert calls == []
|
||||
row = next(p for p in providers if p["name"] == "Static")
|
||||
assert row["is_current"] is True
|
||||
assert row["models"] == ["only"]
|
||||
|
||||
|
||||
def test_custom_provider_empty_explicit_list_allows_probe(monkeypatch):
|
||||
"""An empty ``models:`` declaration is not an explicit catalog."""
|
||||
monkeypatch.setattr("agent.models_dev.fetch_models_dev", lambda: {})
|
||||
monkeypatch.setattr(providers_mod, "HERMES_OVERLAYS", {})
|
||||
calls = []
|
||||
|
||||
def fetch(api_key, base_url, **kwargs):
|
||||
calls.append((api_key, base_url, kwargs))
|
||||
return ["live-a", "live-b"]
|
||||
|
||||
monkeypatch.setattr("hermes_cli.models.fetch_api_models", fetch)
|
||||
|
||||
providers = list_authenticated_providers(
|
||||
current_provider="custom:local",
|
||||
user_providers={},
|
||||
custom_providers=[
|
||||
{
|
||||
"name": "Local",
|
||||
"base_url": "http://local.test/v1",
|
||||
"model": "seed",
|
||||
"models": [],
|
||||
}
|
||||
],
|
||||
)
|
||||
|
||||
assert calls == [("", "http://local.test/v1", {"headers": None})]
|
||||
row = next(p for p in providers if p["name"] == "Local")
|
||||
assert row["models"] == ["live-a", "live-b"]
|
||||
|
||||
|
||||
def test_list_enumerates_dict_format_models_alongside_default(monkeypatch):
|
||||
"""custom_providers entry with dict-format ``models:`` plus singular
|
||||
``model:`` should surface the default and every dict key.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue