Add stored-vector point search path

This commit is contained in:
2026-08-30 16:57:20 +02:00
parent 32ddf70e2f
commit 1e87431dd5
4 changed files with 136 additions and 1 deletions
+29
View File
@@ -0,0 +1,29 @@
from __future__ import annotations
import asyncio
import unittest
from unittest.mock import AsyncMock, patch
import gateway.main as module
class GatewayPointSearchTests(unittest.TestCase):
def test_point_search_proxies_to_qdrant_point_endpoint(self):
async def run():
with patch.object(module, "_post_json", new_callable=AsyncMock) as post:
post.return_value = {"results": []}
result = await module.vectors_search_point({"id": 1284, "limit": 5})
post.assert_awaited_once_with(
f"{module.QDRANT_SVC_URL}/search/point",
{"id": 1284, "limit": 5},
preserve_client_errors=True,
upstream_name="qdrant",
)
self.assertEqual(result, {"results": []})
asyncio.run(run())
if __name__ == "__main__":
unittest.main()
+37
View File
@@ -3,6 +3,7 @@ from __future__ import annotations
import asyncio
import logging
import unittest
from types import SimpleNamespace
from unittest.mock import patch
import httpx
@@ -75,5 +76,41 @@ class QdrantClipSemanticsTests(unittest.IsolatedAsyncioTestCase):
module.logger.removeHandler(handler)
class QdrantPointSearchTests(unittest.TestCase):
def test_point_search_retrieves_vector_then_queries(self):
point = SimpleNamespace(id=1284, vector=[0.1, 0.2], payload=None)
result = SimpleNamespace(points=[SimpleNamespace(id=59303, score=0.91, payload={"id": 59303})])
fake = SimpleNamespace()
fake.retrieve = lambda **kwargs: [point]
fake.query_points = lambda **kwargs: result
with patch.object(module, "client", fake):
response = module.search_point(module.SearchPointRequest(id=1284, limit=5))
self.assertEqual(response["count"], 1)
self.assertEqual(response["results"][0]["id"], 59303)
def test_missing_point_is_404_without_search(self):
calls = []
fake = SimpleNamespace(
retrieve=lambda **kwargs: calls.append(kwargs) or [],
query_points=lambda **kwargs: self.fail("query_points must not run"),
)
with patch.object(module, "client", fake):
with self.assertRaises(module.HTTPException) as raised:
module.search_point(module.SearchPointRequest(id=1284))
self.assertEqual(raised.exception.status_code, 404)
self.assertEqual(calls[0]["ids"], [1284])
def test_point_lookup_does_not_generate_an_id(self):
self.assertEqual(module._lookup_point_id("1284"), 1284)
self.assertEqual(module._lookup_point_id("0001284"), 1284)
with self.assertRaises(module.HTTPException) as raised:
module._lookup_point_id("not-a-point")
self.assertEqual(raised.exception.status_code, 400)
if __name__ == "__main__":
unittest.main()