Add stored-vector point search path
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user