fixes tests

This commit is contained in:
hajdul88 2025-10-10 14:32:58 +02:00
parent 9018367724
commit 06a97f633a
2 changed files with 12 additions and 12 deletions

View file

@ -10,7 +10,7 @@ from cognee.infrastructure.databases.cache.cache_db_interface import CacheDBInte
@pytest.fixture
def mock_redis():
"""Fixture to mock redis.Redis client."""
with patch("redis.Redis") as mock:
with patch("cognee.infrastructure.databases.cache.redis.RedisAdapter.redis.Redis") as mock:
yield mock
@ -207,7 +207,7 @@ def test_multiple_acquire_release_cycles(redis_adapter):
def test_redis_adapter_redis_client_initialization():
"""Test that Redis client is initialized with correct connection parameters."""
with patch("redis.Redis") as mock_redis_class:
with patch("cognee.infrastructure.databases.cache.redis.RedisAdapter.redis.Redis") as mock_redis_class:
mock_redis_instance = MagicMock()
mock_redis_class.return_value = mock_redis_instance
@ -226,7 +226,7 @@ def test_redis_adapter_redis_client_initialization():
def test_lock_name_vs_lock_key_parameter():
"""Test that lock_name parameter is correctly assigned to lock_key attribute."""
with patch("redis.Redis"):
with patch("cognee.infrastructure.databases.cache.redis.RedisAdapter.redis.Redis"):
adapter = RedisAdapter(
host="localhost",
port=6379,
@ -238,7 +238,7 @@ def test_lock_name_vs_lock_key_parameter():
def test_default_timeout_parameters():
"""Test default timeout parameters."""
with patch("redis.Redis"):
with patch("cognee.infrastructure.databases.cache.redis.RedisAdapter.redis.Redis"):
adapter = RedisAdapter(
host="localhost",
port=6379,

View file

@ -36,7 +36,7 @@ def test_create_cache_engine_with_caching_enabled(mock_cache_config):
with patch("cognee.infrastructure.databases.cache.get_cache_engine.config") as mock_config:
mock_config.caching = True
with patch("redis.Redis"):
with patch("cognee.infrastructure.databases.cache.redis.RedisAdapter.redis.Redis"):
engine = create_cache_engine(
cache_host="localhost",
cache_port=6379,
@ -73,7 +73,7 @@ def test_create_cache_engine_caching():
with patch("cognee.infrastructure.databases.cache.get_cache_engine.config") as mock_config:
mock_config.caching = True
with patch("redis.Redis"):
with patch("cognee.infrastructure.databases.cache.redis.RedisAdapter.redis.Redis"):
engine1 = create_cache_engine(
cache_host="localhost",
cache_port=6379,
@ -94,7 +94,7 @@ def test_create_cache_engine_different_params():
with patch("cognee.infrastructure.databases.cache.get_cache_engine.config") as mock_config:
mock_config.caching = True
with patch("redis.Redis"):
with patch("cognee.infrastructure.databases.cache.redis.RedisAdapter.redis.Redis"):
engine1 = create_cache_engine(
cache_host="localhost",
cache_port=6379,
@ -117,7 +117,7 @@ def test_create_cache_engine_custom_timeouts():
with patch("cognee.infrastructure.databases.cache.get_cache_engine.config") as mock_config:
mock_config.caching = True
with patch("redis.Redis"):
with patch("cognee.infrastructure.databases.cache.redis.RedisAdapter.redis.Redis"):
engine = create_cache_engine(
cache_host="redis.example.com",
cache_port=6380,
@ -138,7 +138,7 @@ def test_get_cache_engine_uses_config(mock_cache_config):
with patch("cognee.infrastructure.databases.cache.get_cache_engine.config", mock_cache_config):
mock_cache_config.caching = True
with patch("redis.Redis"):
with patch("cognee.infrastructure.databases.cache.redis.RedisAdapter.redis.Redis"):
with patch(
"cognee.infrastructure.databases.cache.get_cache_engine.create_cache_engine"
) as mock_create:
@ -164,7 +164,7 @@ def test_get_cache_engine_with_custom_config():
mock_config.agentic_lock_expire = 100
mock_config.agentic_lock_timeout = 200
with patch("redis.Redis"):
with patch("cognee.infrastructure.databases.cache.redis.RedisAdapter.redis.Redis"):
engine = get_cache_engine("test-key")
assert isinstance(engine, RedisAdapter)
@ -190,7 +190,7 @@ def test_create_cache_engine_default_timeout_values():
with patch("cognee.infrastructure.databases.cache.get_cache_engine.config") as mock_config:
mock_config.caching = True
with patch("redis.Redis"):
with patch("cognee.infrastructure.databases.cache.redis.RedisAdapter.redis.Redis"):
engine = create_cache_engine(
cache_host="localhost",
cache_port=6379,
@ -211,7 +211,7 @@ def test_full_workflow_with_context_manager():
mock_config.agentic_lock_expire = 240
mock_config.agentic_lock_timeout = 300
with patch("redis.Redis") as mock_redis_class:
with patch("cognee.infrastructure.databases.cache.redis.RedisAdapter.redis.Redis") as mock_redis_class:
mock_redis_instance = MagicMock()
mock_redis_class.return_value = mock_redis_instance