NOTES:
- Tests should be written into
haystack/testing/document_store_async.py
- Use
async def for all test methods
- Decorate each test method with
@pytest.mark.asyncio
- Rely on an
async-compatible document_store fixture (to be provided by the concrete test class in each integration)
- Use
await on all *_async() calls
- Use
write_documents_async / count_documents_async in setup steps (not the sync variants), so the full async path is exercised end-to-end
- Open the PR to the async-mixin-tests feature branch
CountDocumentsAsyncTest
Mirrors: CountDocumentsTest
| Test |
Description |
test_count_empty_async |
await count_documents_async() returns 0 on empty store |
test_count_not_empty_async |
After writing 3 docs via write_documents_async, count_documents_async() returns 3 |
WriteDocumentsAsyncTest(AssertDocumentsEqualMixin)
Mirrors: WriteDocumentsTest
| Test |
Description |
test_write_documents_async |
Abstract — raise NotImplementedError with a message; concrete classes must override this |
test_write_documents_duplicate_fail_async |
Writing same doc twice with DuplicatePolicy.FAIL raises DuplicateDocumentError on second write |
test_write_documents_duplicate_skip_async |
Second write of same doc with DuplicatePolicy.SKIP returns 0 |
test_write_documents_duplicate_overwrite_async |
DuplicatePolicy.OVERWRITE updates content; verify via filter_documents_async |
test_write_documents_invalid_input_async |
Passing ["not a document"] or a plain string raises ValueError |
DeleteDocumentsAsyncTest
Mirrors: DeleteDocumentsTest
| Test |
Description |
test_delete_documents_async |
Write 1 doc, delete it by id, count_documents_async() returns 0 |
test_delete_documents_empty_document_store_async |
delete_documents_async(["non_existing_id"]) on empty store doesn't raise |
test_delete_documents_non_existing_document_async |
Delete non-existing id from a 1-doc store; count stays at 1 |
NOTES:
haystack/testing/document_store_async.pyasync deffor all test methods@pytest.mark.asyncioasync-compatibledocument_storefixture (to be provided by the concrete test class in each integration)awaiton all*_async()callswrite_documents_async/count_documents_asyncin setup steps (not the sync variants), so the full async path is exercised end-to-endCountDocumentsAsyncTestMirrors:
CountDocumentsTesttest_count_empty_asyncawait count_documents_async()returns 0 on empty storetest_count_not_empty_asyncwrite_documents_async,count_documents_async()returns 3WriteDocumentsAsyncTest(AssertDocumentsEqualMixin)Mirrors:
WriteDocumentsTesttest_write_documents_asyncNotImplementedErrorwith a message; concrete classes must override thistest_write_documents_duplicate_fail_asyncDuplicatePolicy.FAILraisesDuplicateDocumentErroron second writetest_write_documents_duplicate_skip_asyncDuplicatePolicy.SKIPreturns 0test_write_documents_duplicate_overwrite_asyncDuplicatePolicy.OVERWRITEupdates content; verify viafilter_documents_asynctest_write_documents_invalid_input_async["not a document"]or a plain string raisesValueErrorDeleteDocumentsAsyncTestMirrors:
DeleteDocumentsTesttest_delete_documents_asynccount_documents_async()returns 0test_delete_documents_empty_document_store_asyncdelete_documents_async(["non_existing_id"])on empty store doesn't raisetest_delete_documents_non_existing_document_async