The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tests): make dashboard-auth and FTS5 tests stateless
ethernet47b1fd11ea21
diff --git a/tests/hermes_cli/test_dashboard_auth_gate.py b/tests/hermes_cli/test_dashboard_auth_gate.pyindex 40f1c000897..de324065767 100644--- a/tests/hermes_cli/test_dashboard_auth_gate.py+++ b/tests/hermes_cli/test_dashboard_auth_gate.py@@ -161,7 +161,7 @@ def test_start_server_loopback_sets_auth_required_false(monkeypatch):# Force a fresh state to detect that start_server actually set it.web_server.app.state.auth_required = Noneweb_server.start_server(- host="127.0.0.1", port=9119,+ host="127.0.0.1", port=0,open_browser=False, allow_public=False,)assert web_server.app.state.auth_required is False@@ -179,7 +179,7 @@ def test_start_server_insecure_public_no_longer_bypasses_gate(monkeypatch):web_server.app.state.auth_required = Nonewith pytest.raises(SystemExit):web_server.start_server(- host="0.0.0.0", port=9119,+ host="0.0.0.0", port=0,open_browser=False, allow_public=True,)assert web_server.app.state.auth_required is True@@ -198,7 +198,7 @@ def test_start_server_public_without_insecure_records_auth_required(monkeypatch)web_server.app.state.auth_required = Nonewith pytest.raises(SystemExit):web_server.start_server(- host="0.0.0.0", port=9119,+ host="0.0.0.0", port=0,open_browser=False, allow_public=False,)assert web_server.app.state.auth_required is True@@ -226,7 +226,7 @@ def test_start_server_gate_with_provider_proceeds_and_sets_proxy_headers(monkeyptry:web_server.app.state.auth_required = Noneweb_server.start_server(- host="0.0.0.0", port=9119,+ host="0.0.0.0", port=0,open_browser=False, allow_public=False,)assert web_server.app.state.auth_required is True@@ -371,7 +371,7 @@ def test_start_server_loopback_public_url_enables_gate(monkeypatch):)try:web_server.start_server(- host="127.0.0.1", port=9119,+ host="127.0.0.1", port=0,open_browser=False, allow_public=False,)assert web_server.app.state.auth_required is True@@ -404,7 +404,7 @@ def test_start_server_loopback_public_url_without_provider_fails_closed(monkeypawith pytest.raises(SystemExit, match=r"no auth providers"):web_server.start_server(- host="127.0.0.1", port=9119,+ host="127.0.0.1", port=0,open_browser=False, allow_public=False,)assert web_server.app.state.auth_required is True@@ -435,7 +435,7 @@ def test_loopback_public_url_fail_closed_message_is_actionable(monkeypatch):with pytest.raises(SystemExit) as exc:web_server.start_server(- host="127.0.0.1", port=9119,+ host="127.0.0.1", port=0,open_browser=False, allow_public=False,)msg = str(exc.value)diff --git a/tests/hermes_cli/test_dashboard_unified_launch.py b/tests/hermes_cli/test_dashboard_unified_launch.pyindex 3bb122136ff..faeee95da4e 100644--- a/tests/hermes_cli/test_dashboard_unified_launch.py+++ b/tests/hermes_cli/test_dashboard_unified_launch.py@@ -35,20 +35,42 @@ class TestUnifiedDashboardRouting:"hermes_cli.profiles.get_active_profile_name", lambda: "worker_x")monkeypatch.setattr(main_mod, "_dashboard_listening", lambda host, port: False)- execs = []-- def fake_exec(exe, argv, env):- execs.append((exe, argv, env))- raise SystemExit(0) # execvpe never returns- monkeypatch.setattr(main_mod.os, "execvpe", fake_exec)-- with pytest.raises(SystemExit):- main_mod.cmd_dashboard(_args())+ if sys.platform == "win32":+ # Windows cannot truly replace the process, so cmd_dashboard+ # re-execs via subprocess.Popen + sys.exit(code) instead of+ # os.execvpe (which doesn't exist on Windows).+ spawns = []++ class _Done:+ def wait(self):+ return 0++ monkeypatch.setattr(+ main_mod.subprocess,+ "Popen",+ lambda argv, env=None, **kw: spawns.append((argv, env)) or _Done(),+ )+ with pytest.raises(SystemExit):+ main_mod.cmd_dashboard(_args())+ assert len(spawns) == 1+ argv, env = spawns[0]+ else:+ execs = []++ def fake_exec(exe, argv, env):+ execs.append((exe, argv, env))+ raise SystemExit(0) # execvpe never returns++ monkeypatch.setattr(main_mod.os, "execvpe", fake_exec)++ with pytest.raises(SystemExit):+ main_mod.cmd_dashboard(_args())++ assert len(execs) == 1+ exe, argv, env = execs[0]+ assert exe == sys.executable- assert len(execs) == 1- exe, argv, env = execs[0]- assert exe == sys.executable# Pinned to the default profile + launching profile preselected.assert "-p" in argv and argv[argv.index("-p") + 1] == "default"assert "--open-profile" in argvdiff --git a/tests/test_hermes_state.py b/tests/test_hermes_state.pyindex 28480c1d154..bfc0c776299 100644--- a/tests/test_hermes_state.py+++ b/tests/test_hermes_state.py@@ -813,17 +813,20 @@ class TestFTS5Search:]assert all("context" in row and row["context"] for row in default)- def test_search_projection_skips_context_enrichment_queries(self, db):+ def test_search_projection_skips_context_enrichment_queries(self, db, monkeypatch):+ # Force the single-connection (non-WAL) read path so the trace callback+ # on db._conn observes every statement. Under WAL the read pool hands a+ # *different* pooled connection to each _read_ctx() checkout, so the+ # enrichment query would run on a connection this test never traces —+ # the assertion only holds when reads fall back to the writer conn.+ monkeypatch.setattr(db, "_wal_active", False)db.create_session(session_id="s1", source="cli")db.append_message("s1", role="user", content="before")db.append_message("s1", role="assistant", content="projectionneedle")db.append_message("s1", role="user", content="after")statements = []- read_conn = db._get_read_conn() or db._conntraced_connections = [db._conn]- if read_conn is not db._conn:- traced_connections.append(read_conn)for conn in traced_connections:conn.set_trace_callback(statements.append)