From b15146772b085232c057cb84e5b75a8ad04e5b5c Mon Sep 17 00:00:00 2001 From: Sami Jaghouar Date: Wed, 1 Jun 2022 16:28:39 +0200 Subject: [PATCH 1/2] feat: add assert on len of results in filter test --- tests/unit/array/mixins/test_find.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/unit/array/mixins/test_find.py b/tests/unit/array/mixins/test_find.py index b77c2122b7c..202118c5ee4 100644 --- a/tests/unit/array/mixins/test_find.py +++ b/tests/unit/array/mixins/test_find.py @@ -305,6 +305,8 @@ def test_search_pre_filtering( results = da.find(np.random.rand(n_dim), filter=filter) + assert len(results) > 0 + assert all( [numeric_operators[operator](r.tags['price'], threshold) for r in results] ) From dfabcb63c18bff04201cd25edea43c5e78f02190 Mon Sep 17 00:00:00 2001 From: Sami Jaghouar Date: Wed, 1 Jun 2022 17:18:42 +0200 Subject: [PATCH 2/2] fix(tests): use the correct notation for eq and neq qdrant --- tests/unit/array/mixins/test_find.py | 33 +++++++++++++++---------- tests/unit/array/mixins/test_match.py | 35 +++++++++++++++++---------- 2 files changed, 42 insertions(+), 26 deletions(-) diff --git a/tests/unit/array/mixins/test_find.py b/tests/unit/array/mixins/test_find.py index 202118c5ee4..dbcf9f64ac3 100644 --- a/tests/unit/array/mixins/test_find.py +++ b/tests/unit/array/mixins/test_find.py @@ -257,19 +257,26 @@ def test_find_by_tag(storage, config, start_storage): ) for operator in ['gte', 'gt', 'lte', 'lt'] ], - *[ - tuple( - [ - 'qdrant', - lambda operator, threshold: { - 'must': [{'key': 'price', 'value': {operator: threshold}}] - }, - numeric_operators_qdrant, - operator, - ] - ) - for operator in ['eq', 'neq'] - ], + tuple( + [ + 'qdrant', + lambda operator, threshold: { + 'must': [{'key': 'price', 'match': {'value': threshold}}] + }, + numeric_operators_qdrant, + 'eq', + ] + ), + tuple( + [ + 'qdrant', + lambda operator, threshold: { + 'must_not': [{'key': 'price', 'match': {'value': threshold}}] + }, + numeric_operators_qdrant, + 'neq', + ] + ), *[ tuple( [ diff --git a/tests/unit/array/mixins/test_match.py b/tests/unit/array/mixins/test_match.py index 5408b8ab35e..24b5f360240 100644 --- a/tests/unit/array/mixins/test_match.py +++ b/tests/unit/array/mixins/test_match.py @@ -639,19 +639,26 @@ def test_match_ensure_scores_unique(): ) for operator in ['gte', 'gt', 'lte', 'lt'] ], - *[ - tuple( - [ - 'qdrant', - lambda operator, threshold: { - 'must': [{'key': 'price', 'value': {operator: threshold}}] - }, - numeric_operators_qdrant, - operator, - ] - ) - for operator in ['eq', 'neq'] - ], + tuple( + [ + 'qdrant', + lambda operator, threshold: { + 'must': [{'key': 'price', 'match': {'value': threshold}}] + }, + numeric_operators_qdrant, + 'eq', + ] + ), + tuple( + [ + 'qdrant', + lambda operator, threshold: { + 'must_not': [{'key': 'price', 'match': {'value': threshold}}] + }, + numeric_operators_qdrant, + 'neq', + ] + ), *[ tuple( [ @@ -688,6 +695,8 @@ def test_match_pre_filtering( doc = Document(embedding=np.random.rand(n_dim)) doc.match(da, filter=filter) + assert len(doc.matches) > 0 + assert all( [ numeric_operators[operator](r.tags['price'], threshold)