@@ -110,6 +110,43 @@ async def test_set_up_collection_with_distance_mismatch_async(self):
110110 with pytest .raises (ValueError , match = "different similarity" ):
111111 await document_store ._set_up_collection_async ("test_collection" , 768 , False , "cosine" , False , False )
112112
113+ async def test_query_by_sparse_async_raises_when_sparse_disabled (self ):
114+ document_store = QdrantDocumentStore (location = ":memory:" , use_sparse_embeddings = False )
115+ sparse_embedding = SparseEmbedding (indices = [0 , 1 ], values = [0.1 , 0.2 ])
116+ with pytest .raises (QdrantStoreError , match = "use_sparse_embeddings=False" ):
117+ await document_store ._query_by_sparse_async (query_sparse_embedding = sparse_embedding )
118+
119+ async def test_delete_documents_async_invokes_client_and_handles_key_error (self ):
120+ document_store = QdrantDocumentStore (location = ":memory:" )
121+ await document_store ._initialize_async_client ()
122+ with patch .object (document_store ._async_client , "delete" ) as mock_delete :
123+ await document_store .delete_documents_async (["doc-1" , "doc-2" ])
124+ mock_delete .assert_awaited_once ()
125+ with patch .object (document_store ._async_client , "delete" , side_effect = KeyError ("missing" )):
126+ await document_store .delete_documents_async (["doc-1" ])
127+
128+ @pytest .mark .parametrize (
129+ ("method_name" , "args" , "expected" ),
130+ [
131+ ("count_documents_async" , (), 0 ),
132+ ("count_documents_by_filter_async" , ({},), 0 ),
133+ ("get_metadata_fields_info_async" , (), {}),
134+ ("get_metadata_field_min_max_async" , ("score" ,), {}),
135+ ("count_unique_metadata_by_filter_async" , ({}, ["category" ]), {"category" : 0 }),
136+ ("get_metadata_field_unique_values_async" , ("category" ,), []),
137+ ],
138+ )
139+ async def test_metadata_methods_async_absorb_client_errors (self , method_name , args , expected ):
140+ document_store = QdrantDocumentStore (location = ":memory:" )
141+ await document_store ._initialize_async_client ()
142+ err = ValueError ("boom" )
143+ with (
144+ patch .object (document_store ._async_client , "count" , side_effect = err ),
145+ patch .object (document_store ._async_client , "scroll" , side_effect = err ),
146+ patch .object (document_store ._async_client , "get_collection" , side_effect = err ),
147+ ):
148+ assert await getattr (document_store , method_name )(* args ) == expected
149+
113150
114151@pytest .mark .integration
115152@pytest .mark .asyncio
0 commit comments