From 1dcd79ef9658ec6009f8a334cb7d1ef48a81aff6 Mon Sep 17 00:00:00 2001 From: gramps Date: Mon, 6 Jul 2026 08:06:06 -0700 Subject: [PATCH] test: add maybe_evict all-pinned break test and stats admin check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - test_maybe_evict_all_pinned_breaks: above high water but only pinned points → eviction breaks with 0 deleted, no EVICTION_LOG entry - test_rag_stats_requires_admin: guest gets 403 on /api/rag/stats --- tests/test_rag_management.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_rag_management.py b/tests/test_rag_management.py index 9ab0dd3..418ba16 100644 --- a/tests/test_rag_management.py +++ b/tests/test_rag_management.py @@ -267,6 +267,23 @@ def test_maybe_evict_zero_config_disabled(monkeypatch): config.RAG_MAX_VECTORS = orig +def test_maybe_evict_all_pinned_breaks(monkeypatch): + """Above high water but only pinned points exist → eviction breaks with 0 deleted.""" + class AllPinnedClient(FakeAsyncClient): + async def get(self, url, **kw): + return FakeResponse(200, {"result": {"vectors_count": 45000}}) + async def post(self, url, **kw): + if "/points/scroll" in url: + return FakeResponse(200, {"result": {"points": []}}) + return FakeResponse(200) + + monkeypatch.setattr(httpx, "AsyncClient", lambda *a, **kw: AllPinnedClient()) + rag.EVICTION_LOG.clear() + evicted = asyncio.run(rag.maybe_evict()) + assert evicted == 0 + assert len(rag.EVICTION_LOG) == 0 + + # ---------- get_rag_operational_stats ---------- def test_rag_operational_stats_shape(monkeypatch):