Skip to content

Commit

Permalink
BUG: fix missing redis_url fixture in integration tests (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsbodden authored Nov 27, 2024
1 parent b954656 commit 56b2a54
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ docs/_build/
.venv
.env
coverage.xml
dist/
dist/
.vscode/settings.json
14 changes: 10 additions & 4 deletions tests/integration/test_llmcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -868,13 +868,19 @@ def test_create_cache_with_different_vector_types():
pytest.skip("Not using a late enough version of Redis")


def test_bad_dtype_connecting_to_existing_cache():
def test_bad_dtype_connecting_to_existing_cache(redis_url):
try:
cache = SemanticCache(name="float64_cache", dtype="float64")
same_type = SemanticCache(name="float64_cache", dtype="float64")
cache = SemanticCache(
name="float64_cache", dtype="float64", redis_url=redis_url
)
same_type = SemanticCache(
name="float64_cache", dtype="float64", redis_url=redis_url
)
# under the hood uses from_existing
except RedisModuleVersionError:
pytest.skip("Not using a late enough version of Redis")

with pytest.raises(ValueError):
bad_type = SemanticCache(name="float64_cache", dtype="float16")
bad_type = SemanticCache(
name="float64_cache", dtype="float16", redis_url=redis_url
)
11 changes: 9 additions & 2 deletions tests/integration/test_semantic_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,30 +241,34 @@ def test_bad_connection_info(routes):
)


def test_different_vector_dtypes(routes):
def test_different_vector_dtypes(redis_url, routes):
try:
bfloat_router = SemanticRouter(
name="bfloat_router",
routes=routes,
dtype="bfloat16",
redis_url=redis_url,
)

float16_router = SemanticRouter(
name="float16_router",
routes=routes,
dtype="float16",
redis_url=redis_url,
)

float32_router = SemanticRouter(
name="float32_router",
routes=routes,
dtype="float32",
redis_url=redis_url,
)

float64_router = SemanticRouter(
name="float64_router",
routes=routes,
dtype="float64",
redis_url=redis_url,
)

for router in [bfloat_router, float16_router, float32_router, float64_router]:
Expand All @@ -273,18 +277,20 @@ def test_different_vector_dtypes(routes):
pytest.skip("Not using a late enough version of Redis")


def test_bad_dtype_connecting_to_exiting_router(routes):
def test_bad_dtype_connecting_to_exiting_router(redis_url, routes):
try:
router = SemanticRouter(
name="float64 router",
routes=routes,
dtype="float64",
redis_url=redis_url,
)

same_type = SemanticRouter(
name="float64 router",
routes=routes,
dtype="float64",
redis_url=redis_url,
)
# under the hood uses from_existing
except RedisModuleVersionError:
Expand All @@ -295,4 +301,5 @@ def test_bad_dtype_connecting_to_exiting_router(routes):
name="float64 router",
routes=routes,
dtype="float16",
redis_url=redis_url,
)
14 changes: 10 additions & 4 deletions tests/integration/test_session_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,13 +563,19 @@ def test_different_vector_dtypes():
pytest.skip("Not using a late enough version of Redis")


def test_bad_dtype_connecting_to_exiting_session():
def test_bad_dtype_connecting_to_exiting_session(redis_url):
try:
session = SemanticSessionManager(name="float64 session", dtype="float64")
same_type = SemanticSessionManager(name="float64 session", dtype="float64")
session = SemanticSessionManager(
name="float64 session", dtype="float64", redis_url=redis_url
)
same_type = SemanticSessionManager(
name="float64 session", dtype="float64", redis_url=redis_url
)
# under the hood uses from_existing
except RedisModuleVersionError:
pytest.skip("Not using a late enough version of Redis")

with pytest.raises(ValueError):
bad_type = SemanticSessionManager(name="float64 session", dtype="float16")
bad_type = SemanticSessionManager(
name="float64 session", dtype="float16", redis_url=redis_url
)

0 comments on commit 56b2a54

Please sign in to comment.