refactor(valkey): use async DocumentStore mixin tests#3060
refactor(valkey): use async DocumentStore mixin tests#3060SyedShahmeerAli12 wants to merge 15 commits intodeepset-ai:mainfrom
Conversation
|
▎ Hi @julian-risch and @davidsbatista , I've addressed the issue as described. The async test class now inherits
|
|
@SyedShahmeerAli12 you let other commits slip into this branch - there's much more stuff here - can you clean it up? |
Ok i will clean it up in a bit |
Inherit from async mixin classes introduced in deepset-ai/haystack#10975 to eliminate duplicate test code in TestValkeyDocumentStoreAsync. Mixins added (from haystack.testing.document_store and document_store_async): - CountDocumentsAsyncTest - WriteDocumentsAsyncTest - DeleteDocumentsAsyncTest - DeleteAllAsyncTest - DeleteByFilterAsyncTest - UpdateByFilterAsyncTest - CountDocumentsByFilterAsyncTest - CountUniqueMetadataByFilterAsyncTest - GetMetadataFieldMinMaxAsyncTest - GetMetadataFieldUniqueValuesAsyncTest Override WriteDocumentsAsyncTest methods that rely on DuplicatePolicy.FAIL and DuplicatePolicy.SKIP, which are not supported by ValkeyDocumentStore. Closes deepset-ai#3053 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Override test_update_by_filter_async: uses filterable_docs fixture with undeclared 'chapter' field. Use declared fields (category, priority) instead. - Override test_count_unique_metadata_by_filter_async_with_multiple_filters: uses undeclared 'year' field. Use declared fields (category, priority) instead. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Break long Document() lines to stay within 120-char limit - Remove @staticmethod from test_count_unique_metadata_by_filter_async_with_multiple_filters so pytest can inject the document_store fixture correctly Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The async test mixin classes (document_store_async module) were added in deepset-ai/haystack#10975 and are only available from haystack-ai>=2.27.0rc1. The previous constraint (>=2.26.1) caused a ModuleNotFoundError at test collection. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add rating (float), age (int), year (int) to the document_store fixture so inherited mixin tests that use these fields don't fail. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…rameter The mixin's test_count_not_empty_async in DeleteByFilterAsyncTest is missing `self`, causing pytest to bind the test class instance to `document_store` instead of injecting the fixture. Override it with the correct signature. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…lasses Revert main dependency to haystack-ai>=2.26.1 (fixes license checker). Override haystack in the test env with the main branch which contains the async mixin classes (document_store_async) not yet in a stable release. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ions Use pytest.importorskip so the test file is skipped instead of failing with ImportError when running with haystack < 2.27.0 (lowest-direct-deps step). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
95335c8 to
b40df0f
Compare
|
@davidsbatista Thanks for catching that cleaned up now. I rewrote the PR branch it only contains the Valkey async mixin test commits. Could you please take another look? |
b40df0f to
b676bb0
Compare
| import pytest_asyncio | ||
| from haystack.dataclasses import ByteStream, Document | ||
|
|
||
| pytest.importorskip("haystack.testing.document_store_async", reason="Requires haystack with async mixin test classes") |
There was a problem hiding this comment.
We can remove this since haystack-ai is already a dependency on the pyproject.toml
integrations/valkey/pyproject.toml
Outdated
| "pytest-asyncio", | ||
| "pytest-cov", | ||
| "pytest-rerunfailures", | ||
| "haystack-ai @ git+https://github.com/deepset-ai/haystack.git@main", |
There was a problem hiding this comment.
we can also remove this one
davidsbatista
left a comment
There was a problem hiding this comment.
looks good - left some minor comments
b676bb0 to
1330e40
Compare
…and fix import sorting
c77962f to
b823c4e
Compare
|
@davidsbatista Kept the importorskip guard CountDocumentsByFilterAsyncTest and the other async mixin class aren't in the released haystack-ai yet, so removing it causes an ImportError at collection time on older versions. Once these classes are part of a stable release we can drop it. |
|
Let's rather remove it. There's already an rc1 for |
|
just to confirm should I remove the importorskip guard now? |
|
yes please - thanks 👍🏽 |
haystack 2.27.0 is releasing imminently; the async mixin classes are now available in the release candidate.
03b075e to
2d745e6
Compare
|
@SyedShahmeerAli12 I will put this on hold for a while until this one is merged, and the release is done. |
Closes #3053
Refactors
integrations/valkey/tests/test_document_store_async.pyto inherit from the asyncmixin classes introduced in deepset-ai/haystack#10975.
WriteDocumentsAsyncTestmethods for unsupported duplicate policies (FAIL,SKIP) since ValkeyDocumentStore only supportsNONEandOVERWRITE