Skip to content

Commit 5c73b72

Browse files
committed
Update tests for new incompatible import logic
1 parent 0020ab1 commit 5c73b72

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

tests/integration/test_hybrid.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import pytest
22
from packaging.version import Version
33
from redis import ResponseError
4+
from redis import __version__ as redis_version
45

56
from redisvl.index import AsyncSearchIndex, SearchIndex
67
from redisvl.query.filter import Geo, GeoRadius, Num, Tag, Text
8+
from redisvl.query.hybrid import HybridQuery
79
from redisvl.redis.utils import array_to_buffer
810
from redisvl.schema import IndexSchema
911
from tests.conftest import (
@@ -12,15 +14,8 @@
1214
skip_if_redis_version_below_async,
1315
)
1416

15-
try:
16-
from redisvl.query.hybrid import HybridQuery
17-
18-
REDIS_HYBRID_AVAILABLE = True
19-
SKIP_REASON = ""
20-
except (ImportError, ModuleNotFoundError):
21-
REDIS_HYBRID_AVAILABLE = False
22-
SKIP_REASON = "Requires redis>=8.4.0 and redis-py>=7.1.0"
23-
# HybridQuery = None # type: ignore
17+
REDIS_HYBRID_AVAILABLE = Version(redis_version) >= Version("7.1.0")
18+
SKIP_REASON = "Requires Redis >= 8.4.0 and redis-py>=7.1.0"
2419

2520

2621
@pytest.fixture
@@ -496,9 +491,21 @@ def test_hybrid_search_not_available_in_server(index):
496491
@pytest.mark.skipif(
497492
REDIS_HYBRID_AVAILABLE, reason="Requires hybrid search to NOT be available"
498493
)
499-
def test_hybrid_query_not_available():
494+
def test_hybrid_query_not_available(index):
495+
hybrid_query = HybridQuery(
496+
text="a medical professional with expertise in lung cancer",
497+
text_field_name="description",
498+
yield_text_score_as="text_score",
499+
vector=[0.1, 0.1, 0.5],
500+
vector_field_name="user_embedding",
501+
yield_vsim_score_as="vsim_score",
502+
combination_method="RRF",
503+
yield_combined_score_as="hybrid_score",
504+
return_fields=["user", "credit_score", "age", "job", "location", "description"],
505+
)
506+
500507
with pytest.raises(ImportError):
501-
from redisvl.query.hybrid import HybridQuery # noqa: F401
508+
index.query(hybrid_query)
502509

503510

504511
@pytest.mark.skipif(

0 commit comments

Comments
 (0)