@@ -174,16 +174,16 @@ class CountDocumentsByFilterAsyncTest:
174174
175175 @staticmethod
176176 @pytest .mark .asyncio
177- async def test_count_documents_by_filter_async_simple (document_store : DocumentStore ):
177+ async def test_count_documents_by_filter_async_simple (document_store : AsyncDocumentStore ):
178178 """Test count_documents_by_filter_async() with a simple equality filter."""
179179 docs = [
180180 Document (content = "Doc 1" , meta = {"category" : "A" , "status" : "active" }),
181181 Document (content = "Doc 2" , meta = {"category" : "B" , "status" : "active" }),
182182 Document (content = "Doc 3" , meta = {"category" : "A" , "status" : "inactive" }),
183183 Document (content = "Doc 4" , meta = {"category" : "A" , "status" : "active" }),
184184 ]
185- document_store .write_documents (docs )
186- assert document_store .count_documents () == 4
185+ await document_store .write_documents_async (docs )
186+ assert await document_store .count_documents_async () == 4
187187
188188 count = await document_store .count_documents_by_filter_async ( # type:ignore[attr-defined]
189189 filters = {"field" : "meta.category" , "operator" : "==" , "value" : "A" }
@@ -197,16 +197,16 @@ async def test_count_documents_by_filter_async_simple(document_store: DocumentSt
197197
198198 @staticmethod
199199 @pytest .mark .asyncio
200- async def test_count_documents_by_filter_async_compound (document_store : DocumentStore ):
200+ async def test_count_documents_by_filter_async_compound (document_store : AsyncDocumentStore ):
201201 """Test count_documents_by_filter_async() with AND filter."""
202202 docs = [
203203 Document (content = "Doc 1" , meta = {"category" : "A" , "status" : "active" }),
204204 Document (content = "Doc 2" , meta = {"category" : "B" , "status" : "active" }),
205205 Document (content = "Doc 3" , meta = {"category" : "A" , "status" : "inactive" }),
206206 Document (content = "Doc 4" , meta = {"category" : "A" , "status" : "active" }),
207207 ]
208- document_store .write_documents (docs )
209- assert document_store .count_documents () == 4
208+ await document_store .write_documents_async (docs )
209+ assert await document_store .count_documents_async () == 4
210210
211211 count = await document_store .count_documents_by_filter_async ( # type:ignore[attr-defined]
212212 filters = {
@@ -221,11 +221,11 @@ async def test_count_documents_by_filter_async_compound(document_store: Document
221221
222222 @staticmethod
223223 @pytest .mark .asyncio
224- async def test_count_documents_by_filter_async_no_matches (document_store : DocumentStore ):
224+ async def test_count_documents_by_filter_async_no_matches (document_store : AsyncDocumentStore ):
225225 """Test count_documents_by_filter_async() when filter matches no documents."""
226226 docs = [Document (content = "Doc 1" , meta = {"category" : "A" }), Document (content = "Doc 2" , meta = {"category" : "B" })]
227- document_store .write_documents (docs )
228- assert document_store .count_documents () == 2
227+ await document_store .write_documents_async (docs )
228+ assert await document_store .count_documents_async () == 2
229229
230230 count = await document_store .count_documents_by_filter_async ( # type:ignore[attr-defined]
231231 filters = {"field" : "meta.category" , "operator" : "==" , "value" : "Z" }
@@ -234,9 +234,9 @@ async def test_count_documents_by_filter_async_no_matches(document_store: Docume
234234
235235 @staticmethod
236236 @pytest .mark .asyncio
237- async def test_count_documents_by_filter_async_empty_collection (document_store : DocumentStore ):
237+ async def test_count_documents_by_filter_async_empty_collection (document_store : AsyncDocumentStore ):
238238 """Test count_documents_by_filter_async() on an empty store."""
239- assert document_store .count_documents () == 0
239+ assert await document_store .count_documents_async () == 0
240240
241241 count = await document_store .count_documents_by_filter_async ( # type:ignore[attr-defined]
242242 filters = {"field" : "meta.category" , "operator" : "==" , "value" : "A" }
@@ -253,7 +253,7 @@ class CountUniqueMetadataByFilterAsyncTest:
253253
254254 @staticmethod
255255 @pytest .mark .asyncio
256- async def test_count_unique_metadata_by_filter_async_all_documents (document_store : DocumentStore ):
256+ async def test_count_unique_metadata_by_filter_async_all_documents (document_store : AsyncDocumentStore ):
257257 """Test count_unique_metadata_by_filter_async() with no filter returns distinct counts for all docs."""
258258 docs = [
259259 Document (content = "Doc 1" , meta = {"category" : "A" , "status" : "active" , "priority" : 1 }),
@@ -262,8 +262,8 @@ async def test_count_unique_metadata_by_filter_async_all_documents(document_stor
262262 Document (content = "Doc 4" , meta = {"category" : "A" , "status" : "active" , "priority" : 3 }),
263263 Document (content = "Doc 5" , meta = {"category" : "C" , "status" : "active" , "priority" : 2 }),
264264 ]
265- document_store .write_documents (docs )
266- assert document_store .count_documents () == 5
265+ await document_store .write_documents_async (docs )
266+ assert await document_store .count_documents_async () == 5
267267
268268 counts = await document_store .count_unique_metadata_by_filter_async ( # type:ignore[attr-defined]
269269 filters = {}, metadata_fields = ["category" , "status" , "priority" ]
@@ -274,16 +274,16 @@ async def test_count_unique_metadata_by_filter_async_all_documents(document_stor
274274
275275 @staticmethod
276276 @pytest .mark .asyncio
277- async def test_count_unique_metadata_by_filter_async_with_filter (document_store : DocumentStore ):
277+ async def test_count_unique_metadata_by_filter_async_with_filter (document_store : AsyncDocumentStore ):
278278 """Test count_unique_metadata_by_filter_async() with a filter."""
279279 docs = [
280280 Document (content = "Doc 1" , meta = {"category" : "A" , "status" : "active" , "priority" : 1 }),
281281 Document (content = "Doc 2" , meta = {"category" : "B" , "status" : "active" , "priority" : 2 }),
282282 Document (content = "Doc 3" , meta = {"category" : "A" , "status" : "inactive" , "priority" : 1 }),
283283 Document (content = "Doc 4" , meta = {"category" : "A" , "status" : "active" , "priority" : 3 }),
284284 ]
285- document_store .write_documents (docs )
286- assert document_store .count_documents () == 4
285+ await document_store .write_documents_async (docs )
286+ assert await document_store .count_documents_async () == 4
287287
288288 counts = await document_store .count_unique_metadata_by_filter_async ( # type:ignore[attr-defined]
289289 filters = {"field" : "meta.category" , "operator" : "==" , "value" : "A" }, metadata_fields = ["status" , "priority" ]
@@ -293,15 +293,15 @@ async def test_count_unique_metadata_by_filter_async_with_filter(document_store:
293293
294294 @staticmethod
295295 @pytest .mark .asyncio
296- async def test_count_unique_metadata_by_filter_async_with_multiple_filters (document_store : DocumentStore ):
296+ async def test_count_unique_metadata_by_filter_async_with_multiple_filters (document_store : AsyncDocumentStore ):
297297 """Test counting unique metadata asynchronously with multiple filters."""
298298 docs = [
299299 Document (content = "Doc 1" , meta = {"category" : "A" , "year" : 2023 }),
300300 Document (content = "Doc 2" , meta = {"category" : "A" , "year" : 2024 }),
301301 Document (content = "Doc 3" , meta = {"category" : "B" , "year" : 2023 }),
302302 Document (content = "Doc 4" , meta = {"category" : "B" , "year" : 2024 }),
303303 ]
304- document_store .write_documents (docs )
304+ await document_store .write_documents_async (docs )
305305
306306 counts = await document_store .count_unique_metadata_by_filter_async ( # type:ignore[attr-defined]
307307 filters = {
@@ -409,6 +409,8 @@ async def test_delete_by_filter_advanced_filters_async(document_store: AsyncDocu
409409 assert deleted_count == 2
410410 assert await document_store .count_documents_async () == 0
411411
412+ @staticmethod
413+ @pytest .mark .asyncio
412414 async def test_count_not_empty_async (document_store : AsyncDocumentStore ):
413415 """Test count is greater than zero if the document store contains documents."""
414416 await document_store .write_documents_async (
@@ -426,11 +428,11 @@ class UpdateByFilterAsyncTest:
426428
427429 @staticmethod
428430 @pytest .mark .asyncio
429- async def test_update_by_filter_async (document_store : DocumentStore , filterable_docs : list [Document ]):
431+ async def test_update_by_filter_async (document_store : AsyncDocumentStore , filterable_docs : list [Document ]):
430432 """Update documents matching a filter asynchronously and verify count and meta changes."""
431- document_store .write_documents (filterable_docs )
433+ await document_store .write_documents_async (filterable_docs )
432434 expected_count = len ([d for d in filterable_docs if d .meta .get ("chapter" ) == "intro" ])
433- assert document_store .count_documents () == len (filterable_docs )
435+ assert await document_store .count_documents_async () == len (filterable_docs )
434436
435437 sig = inspect .signature (document_store .update_by_filter_async ) # type:ignore[attr-defined]
436438 params = {"refresh" : True } if "refresh" in sig .parameters else {}
@@ -439,15 +441,15 @@ async def test_update_by_filter_async(document_store: DocumentStore, filterable_
439441 )
440442 assert updated_count == expected_count
441443
442- updated_docs = document_store .filter_documents (
444+ updated_docs = await document_store .filter_documents_async (
443445 filters = {"field" : "meta.updated" , "operator" : "==" , "value" : True }
444446 )
445447 assert len (updated_docs ) == expected_count
446448 for doc in updated_docs :
447449 assert doc .meta ["chapter" ] == "intro"
448450 assert doc .meta ["updated" ] is True
449451
450- not_updated_docs = document_store .filter_documents (
452+ not_updated_docs = await document_store .filter_documents_async (
451453 filters = {"field" : "meta.chapter" , "operator" : "==" , "value" : "abstract" }
452454 )
453455 for doc in not_updated_docs :
0 commit comments