Skip to content

Commit e97481a

Browse files
test: ValkeyDocumentStore using Mixin Test (#3019)
* adding Mixin tests * adding Mixin tests + overriding and fixing to pass tests * chore: update haystack-ai dependency to >=2.26.1 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent c18e60d commit e97481a

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

integrations/valkey/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ classifiers = [
2525
"Programming Language :: Python :: Implementation :: CPython",
2626
"Programming Language :: Python :: Implementation :: PyPy",
2727
]
28-
dependencies = ["haystack-ai>=2.24.0", "valkey-glide>=2.1.0", "valkey-glide-sync>=2.1.0"]
28+
dependencies = ["haystack-ai>=2.26.1", "valkey-glide>=2.1.0", "valkey-glide-sync>=2.1.0"]
2929

3030
[project.urls]
3131
Documentation = "https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/valkey#readme"

integrations/valkey/src/haystack_integrations/document_stores/valkey/document_store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1544,7 +1544,7 @@ def _validate_and_normalize_metadata_fields(metadata_fields: dict[str, type[str]
15441544
msg = "metadata_fields must be a dictionary"
15451545
raise ValueError(msg)
15461546

1547-
type_mapping = {str: "tag", int: "numeric"}
1547+
type_mapping = {str: "tag", int: "numeric", float: "numeric"}
15481548

15491549
normalized = {}
15501550
for field_name, field_type in metadata_fields.items():

integrations/valkey/tests/test_document_store.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,16 @@
1414
from haystack.dataclasses.byte_stream import ByteStream
1515
from haystack.document_stores.types import DuplicatePolicy
1616
from haystack.testing.document_store import (
17+
CountDocumentsByFilterTest,
1718
CountDocumentsTest,
19+
CountUniqueMetadataByFilterTest,
1820
DeleteAllTest,
1921
DeleteByFilterTest,
2022
DeleteDocumentsTest,
2123
FilterableDocsFixtureMixin,
24+
GetMetadataFieldMinMaxTest,
25+
GetMetadataFieldsInfoTest,
26+
GetMetadataFieldUniqueValuesTest,
2227
UpdateByFilterTest,
2328
WriteDocumentsTest,
2429
create_filterable_docs,
@@ -49,6 +54,11 @@ class TestValkeyDocumentStore(
4954
DeleteDocumentsTest,
5055
FilterableDocsFixtureMixin,
5156
UpdateByFilterTest,
57+
CountDocumentsByFilterTest,
58+
CountUniqueMetadataByFilterTest,
59+
GetMetadataFieldsInfoTest,
60+
GetMetadataFieldMinMaxTest,
61+
GetMetadataFieldUniqueValuesTest,
5262
):
5363
@pytest.fixture
5464
def document_store(self):
@@ -64,6 +74,8 @@ def document_store(self):
6474
"quality": str,
6575
"year": int,
6676
"featured": int, # for base-class test_update_by_filter_advanced_filters (meta.featured)
77+
"rating": float, # for GetMetadataFieldMinMaxTest (float field)
78+
"age": int, # for GetMetadataFieldMinMaxTest meta_prefix test
6779
# for base-class UpdateByFilterTest.filterable_docs and filter tests:
6880
"name": str,
6981
"page": str,
@@ -94,6 +106,10 @@ def test_write_documents(self, document_store):
94106
assert document_store.write_documents(docs) == 1
95107
assert document_store.count_documents() == 1
96108

109+
def test_get_metadata_fields_info_empty_collection(self, document_store):
110+
"""Valkey pre-configures metadata fields at init, so they're always present even when empty."""
111+
pytest.skip("Valkey metadata fields are pre-configured at init, not discovered from documents")
112+
97113
def test_write_documents_duplicate_fail(self, document_store):
98114
"""Valkey only supports OVERWRITE policy, skip FAIL test."""
99115
pytest.skip("Valkey only supports DuplicatePolicy.OVERWRITE")

0 commit comments

Comments
 (0)