The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(local-models): assert _assign_default reaches the real assignment body
kshitijk4poor5a0b1ba76695
diff --git a/hermes_cli/web_routers/local_models.py b/hermes_cli/web_routers/local_models.pyindex c07fee82ca9..c5dcf47f5f2 100644--- a/hermes_cli/web_routers/local_models.py+++ b/hermes_cli/web_routers/local_models.py@@ -268,7 +268,7 @@ def _ensure_server(job: Dict[str, Any], config: dict, model_id: str, *, fail_detdef _assign_default(job: Dict[str, Any], model_id: str) -> None:- """Make ``model_id`` the main model via the same machinery as /api/model/set (late-bound: tests stub web_deps.late)."""+ """Make ``model_id`` the main model via the same machinery as /api/model/set."""_step(job, "setting-default", "Making it your default")web_deps.late("_apply_model_assignment_sync", "hermes_cli.web_server_config")("main", "llamacpp", model_id, "", "", "")diff --git a/tests/hermes_cli/test_local_quickstart.py b/tests/hermes_cli/test_local_quickstart.pyindex e78360306e2..aa82247cc40 100644--- a/tests/hermes_cli/test_local_quickstart.py+++ b/tests/hermes_cli/test_local_quickstart.py@@ -80,11 +80,9 @@ def test_quickstart_runs_all_three_legs(client, monkeypatch, tmp_path):monkeypatch.setattr("hermes_cli.web_routers.local_models._state_endpoint",lambda: {"base_url": "http://127.0.0.1:1/v1", "api_key": "k"})- from hermes_cli import web_deps-monkeypatch.setattr(- web_deps, "late",- lambda name, module="hermes_cli.web_server": (lambda *a, **k: calls.append("assign")))+ "hermes_cli.web_server_config._apply_model_assignment_sync",+ lambda *a, **k: calls.append("assign"))r = client.post("/api/local-models/quickstart", json={})assert r.status_code == 200@@ -133,11 +131,9 @@ def test_quickstart_skips_satisfied_legs(client, monkeypatch):monkeypatch.setattr("hermes_cli.web_routers.local_models._state_endpoint",lambda: {"base_url": "http://127.0.0.1:1/v1", "api_key": "k"})- from hermes_cli import web_deps-monkeypatch.setattr(- web_deps, "late",- lambda name, module="hermes_cli.web_server": (lambda *a, **k: calls.append("assign")))+ "hermes_cli.web_server_config._apply_model_assignment_sync",+ lambda *a, **k: calls.append("assign"))r = client.post("/api/local-models/quickstart", json={})assert r.status_code == 200@@ -185,3 +181,17 @@ def test_quickstart_is_single_flight(client, quickstart_ready, monkeypatch):assert "already running" in r.json()["detail"].lower()finally:lm._QUICKSTART_LOCK.release()+++def test_assign_default_reaches_model_assignment(monkeypatch):+ """late() must resolve _apply_model_assignment_sync on web_server_config, the+ sibling that defines it. Only the leaf is stubbed; the default web_server lookup+ raised AttributeError at the quickstart's 'making it your default' step."""+ import hermes_cli.web_routers.local_models as lm++ seen: list[tuple] = []+ monkeypatch.setattr(+ "hermes_cli.web_server_config._apply_model_assignment_sync",+ lambda *a, **k: seen.append(a))+ lm._assign_default({}, "some-model")+ assert seen == [("main", "llamacpp", "some-model", "", "", "")]