Skip to content

The agent that grows with you

test: seed owner database for dashboard parameter validation

Teknium2af3bfd471ba
diff --git a/tests/hermes_cli/test_dashboard_param_clamps.py b/tests/hermes_cli/test_dashboard_param_clamps.py
index 96c9dfb9be8..311c54c09ff 100644
--- a/tests/hermes_cli/test_dashboard_param_clamps.py
+++ b/tests/hermes_cli/test_dashboard_param_clamps.py
@@ -9,6 +9,8 @@ unbounded/inverted ``days`` forces full-history InsightsEngine work.
from __future__ import annotations
+from contextlib import closing
+
import pytest
fastapi = pytest.importorskip("fastapi")
@@ -20,8 +22,14 @@ def client(tmp_path, monkeypatch):
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
monkeypatch.setenv("HERMES_DASHBOARD_SESSION_TOKEN", "clamp-test-token")
from hermes_cli import web_server
+ import hermes_state
+
+ monkeypatch.setattr(hermes_state, "DEFAULT_DB_PATH", tmp_path / "state.db")
+ # The owner initializes storage, not GET requests or an unrelated lifespan.
+ with closing(hermes_state.SessionDB()) as db:
+ db.create_session("clamp-session", source="cli")
- with TestClient(web_server.app, raise_server_exceptions=False) as c:
+ with closing(TestClient(web_server.app, raise_server_exceptions=False)) as c:
c.headers["Authorization"] = "Bearer clamp-test-token"
yield c
@@ -49,6 +57,8 @@ class TestSessionPaginationClamps:
def test_in_range_limit_accepted(self, client):
r = client.get("/api/sessions", params={"limit": 50})
assert r.status_code == 200
+ assert r.json()["limit"] == 50
+ assert [row["id"] for row in r.json()["sessions"]] == ["clamp-session"]
class TestAnalyticsDaysClamps: