Skip to content

The agent that grows with you

test(dashboard): the Nous recommended-default test uses the hermetic home fixture (#124283, salvage #124284)

teknium1a3ad3c0c5889
diff --git a/tests/hermes_cli/test_web_recommended_default_profile.py b/tests/hermes_cli/test_web_recommended_default_profile.py
index 1e92ec1e286..3b57cb5f19b 100644
--- a/tests/hermes_cli/test_web_recommended_default_profile.py
+++ b/tests/hermes_cli/test_web_recommended_default_profile.py
@@ -14,8 +14,7 @@ from fastapi.testclient import TestClient # noqa: E402
@pytest.fixture()
-def client(tmp_path, monkeypatch):
- monkeypatch.setenv("HERMES_HOME", str(tmp_path))
+def client(_isolate_hermes_home, monkeypatch):
from hermes_cli import profiles as profiles_mod
freebie = profiles_mod.get_profile_dir("freebie")
@@ -29,26 +28,22 @@ def client(tmp_path, monkeypatch):
monkeypatch.setattr(nous_account, "get_nous_portal_account_info", lambda **_k: SimpleNamespace(
is_free_tier=get_hermes_home().name == "freebie"))
- from hermes_cli import web_server
+ from hermes_cli.web_server import app, _SESSION_HEADER_NAME, _SESSION_TOKEN
- with TestClient(web_server.app, raise_server_exceptions=False) as c:
- c.headers["Authorization"] = f"Bearer {web_server._SESSION_TOKEN}"
- yield c
+ c = TestClient(app, raise_server_exceptions=False)
+ c.headers[_SESSION_HEADER_NAME] = _SESSION_TOKEN
+ return c
def test_nous_recommendation_reads_the_requested_profile(client):
launch = client.get("/api/model/recommended-default", params={"provider": "nous"})
named = client.get("/api/model/recommended-default",
params={"provider": "nous", "profile": "freebie"})
+ unknown = client.get("/api/model/recommended-default",
+ params={"provider": "nous", "profile": "no-such-profile"})
assert launch.status_code == named.status_code == 200
assert launch.json()["free_tier"] is False
assert named.json()["free_tier"] is True
-
-
-def test_nous_recommendation_unknown_profile_is_404(client):
- resp = client.get("/api/model/recommended-default",
- params={"provider": "nous", "profile": "no-such-profile"})
-
- assert resp.status_code == 404, resp.text
- assert "no-such-profile" in resp.json()["detail"]
+ assert unknown.status_code == 404, unknown.text
+ assert "no-such-profile" in unknown.json()["detail"]