@@ -50,6 +50,7 @@ async def test_query_hybrid_search_batch_failure_async(self):
5050 async def test_set_up_collection_with_dimension_mismatch_async (self ):
5151 document_store = QdrantDocumentStore (location = ":memory:" , use_sparse_embeddings = False , similarity = "cosine" )
5252 await document_store ._initialize_async_client ()
53+ # Mock collection info with different vector size
5354 mock_collection_info = MagicMock ()
5455 mock_collection_info .config .params .vectors = MagicMock ()
5556 mock_collection_info .config .params .vectors .distance = rest .Distance .COSINE
@@ -65,6 +66,7 @@ async def test_set_up_collection_with_dimension_mismatch_async(self):
6566 async def test_set_up_collection_with_existing_incompatible_collection_async (self ):
6667 document_store = QdrantDocumentStore (location = ":memory:" , use_sparse_embeddings = True )
6768 await document_store ._initialize_async_client ()
69+ # Mock collection info with named vectors but missing DENSE_VECTORS_NAME
6870 mock_collection_info = MagicMock ()
6971 mock_collection_info .config .params .vectors = {"some_other_vector" : MagicMock ()}
7072
@@ -79,6 +81,8 @@ async def test_set_up_collection_use_sparse_embeddings_true_without_named_vector
7981 """Test that an error is raised when use_sparse_embeddings is True but collection doesn't have named vectors"""
8082 document_store = QdrantDocumentStore (location = ":memory:" , use_sparse_embeddings = True )
8183 await document_store ._initialize_async_client ()
84+
85+ # Mock collection info without named vectors
8286 mock_collection_info = MagicMock ()
8387 mock_collection_info .config .params .vectors = MagicMock (spec = rest .VectorsConfig )
8488
@@ -93,6 +97,7 @@ async def test_set_up_collection_use_sparse_embeddings_false_with_named_vectors_
9397 """Test that an error is raised when use_sparse_embeddings is False but collection has named vectors"""
9498 document_store = QdrantDocumentStore (location = ":memory:" , use_sparse_embeddings = False )
9599 await document_store ._initialize_async_client ()
100+ # Mock collection info with named vectors
96101 mock_collection_info = MagicMock ()
97102 mock_collection_info .config .params .vectors = {DENSE_VECTORS_NAME : MagicMock ()}
98103
@@ -106,6 +111,8 @@ async def test_set_up_collection_use_sparse_embeddings_false_with_named_vectors_
106111 async def test_set_up_collection_with_distance_mismatch_async (self ):
107112 document_store = QdrantDocumentStore (location = ":memory:" , use_sparse_embeddings = False , similarity = "cosine" )
108113 await document_store ._initialize_async_client ()
114+
115+ # Mock collection info with different distance
109116 mock_collection_info = MagicMock ()
110117 mock_collection_info .config .params .vectors = MagicMock ()
111118 mock_collection_info .config .params .vectors .distance = rest .Distance .DOT
@@ -216,6 +223,7 @@ async def test_sparse_configuration_async(self):
216223 sparse_config = collection .config .params .sparse_vectors
217224
218225 assert SPARSE_VECTORS_NAME in sparse_config
226+ # check that the `sparse_idf` parameter takes effect
219227 assert hasattr (sparse_config [SPARSE_VECTORS_NAME ], "modifier" )
220228 assert sparse_config [SPARSE_VECTORS_NAME ].modifier == rest .Modifier .IDF
221229
@@ -294,11 +302,13 @@ async def test_update_by_filter_async_preserves_vectors(self, document_store: Qd
294302 ]
295303 await document_store .write_documents_async (docs )
296304
305+ # Update metadata
297306 updated_count = await document_store .update_by_filter_async (
298307 filters = {"field" : "meta.category" , "operator" : "==" , "value" : "A" }, meta = {"status" : "published" }
299308 )
300309 assert updated_count == 1
301310
311+ # Verify embedding is preserved
302312 updated_docs = []
303313 async for doc in document_store ._get_documents_generator_async (
304314 filters = {"field" : "meta.status" , "operator" : "==" , "value" : "published" }
0 commit comments