Skip to content

Commit 96262c9

Browse files
fix(qdrant): override mixin tests incompatible with Qdrant behavior
- Override assert_documents_are_equal to compare by ID set (Qdrant returns embedding vectors on all docs and doesn't guarantee order) - Override test_write_documents_async (base raises NotImplementedError by design, requires store-specific implementation) - Override test_count_not_empty_async to add missing self parameter (bug in haystack mixin causes fixture injection to fail)
1 parent 66513c8 commit 96262c9

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

integrations/qdrant/tests/test_document_store_async.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import pytest_asyncio
55
from haystack import Document
66
from haystack.dataclasses import SparseEmbedding
7+
from haystack.document_stores.errors import DuplicateDocumentError
8+
from haystack.document_stores.types import DuplicatePolicy
79
from haystack.testing.document_store import (
810
CountDocumentsByFilterAsyncTest,
911
CountUniqueMetadataByFilterAsyncTest,
@@ -182,6 +184,25 @@ async def document_store(self):
182184
)
183185
yield store
184186

187+
def assert_documents_are_equal(self, received: list[Document], expected: list[Document]):
188+
assert len(received) == len(expected)
189+
assert {doc.id for doc in received} == {doc.id for doc in expected}
190+
191+
@pytest.mark.asyncio
192+
async def test_write_documents_async(self, document_store: QdrantDocumentStore):
193+
docs = [Document(id="1")]
194+
assert await document_store.write_documents_async(docs) == 1
195+
with pytest.raises(DuplicateDocumentError):
196+
await document_store.write_documents_async(docs, DuplicatePolicy.FAIL)
197+
198+
@pytest.mark.asyncio
199+
async def test_count_not_empty_async(self, document_store: QdrantDocumentStore):
200+
# Override needed: base class mixin is missing `self`, causing fixture injection failure
201+
await document_store.write_documents_async(
202+
[Document(content="test doc 1"), Document(content="test doc 2"), Document(content="test doc 3")]
203+
)
204+
assert await document_store.count_documents_async() == 3
205+
185206
async def test_sparse_configuration_async(self):
186207
document_store = QdrantDocumentStore(
187208
":memory:",

0 commit comments

Comments
 (0)