fixes tests
This commit is contained in:
parent
9018367724
commit
06a97f633a
2 changed files with 12 additions and 12 deletions
|
|
@ -10,7 +10,7 @@ from cognee.infrastructure.databases.cache.cache_db_interface import CacheDBInte
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def mock_redis():
|
def mock_redis():
|
||||||
"""Fixture to mock redis.Redis client."""
|
"""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
|
yield mock
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -207,7 +207,7 @@ def test_multiple_acquire_release_cycles(redis_adapter):
|
||||||
|
|
||||||
def test_redis_adapter_redis_client_initialization():
|
def test_redis_adapter_redis_client_initialization():
|
||||||
"""Test that Redis client is initialized with correct connection parameters."""
|
"""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_instance = MagicMock()
|
||||||
mock_redis_class.return_value = mock_redis_instance
|
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():
|
def test_lock_name_vs_lock_key_parameter():
|
||||||
"""Test that lock_name parameter is correctly assigned to lock_key attribute."""
|
"""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(
|
adapter = RedisAdapter(
|
||||||
host="localhost",
|
host="localhost",
|
||||||
port=6379,
|
port=6379,
|
||||||
|
|
@ -238,7 +238,7 @@ def test_lock_name_vs_lock_key_parameter():
|
||||||
|
|
||||||
def test_default_timeout_parameters():
|
def test_default_timeout_parameters():
|
||||||
"""Test default timeout parameters."""
|
"""Test default timeout parameters."""
|
||||||
with patch("redis.Redis"):
|
with patch("cognee.infrastructure.databases.cache.redis.RedisAdapter.redis.Redis"):
|
||||||
adapter = RedisAdapter(
|
adapter = RedisAdapter(
|
||||||
host="localhost",
|
host="localhost",
|
||||||
port=6379,
|
port=6379,
|
||||||
|
|
|
||||||
|
|
@ -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:
|
with patch("cognee.infrastructure.databases.cache.get_cache_engine.config") as mock_config:
|
||||||
mock_config.caching = True
|
mock_config.caching = True
|
||||||
|
|
||||||
with patch("redis.Redis"):
|
with patch("cognee.infrastructure.databases.cache.redis.RedisAdapter.redis.Redis"):
|
||||||
engine = create_cache_engine(
|
engine = create_cache_engine(
|
||||||
cache_host="localhost",
|
cache_host="localhost",
|
||||||
cache_port=6379,
|
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:
|
with patch("cognee.infrastructure.databases.cache.get_cache_engine.config") as mock_config:
|
||||||
mock_config.caching = True
|
mock_config.caching = True
|
||||||
|
|
||||||
with patch("redis.Redis"):
|
with patch("cognee.infrastructure.databases.cache.redis.RedisAdapter.redis.Redis"):
|
||||||
engine1 = create_cache_engine(
|
engine1 = create_cache_engine(
|
||||||
cache_host="localhost",
|
cache_host="localhost",
|
||||||
cache_port=6379,
|
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:
|
with patch("cognee.infrastructure.databases.cache.get_cache_engine.config") as mock_config:
|
||||||
mock_config.caching = True
|
mock_config.caching = True
|
||||||
|
|
||||||
with patch("redis.Redis"):
|
with patch("cognee.infrastructure.databases.cache.redis.RedisAdapter.redis.Redis"):
|
||||||
engine1 = create_cache_engine(
|
engine1 = create_cache_engine(
|
||||||
cache_host="localhost",
|
cache_host="localhost",
|
||||||
cache_port=6379,
|
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:
|
with patch("cognee.infrastructure.databases.cache.get_cache_engine.config") as mock_config:
|
||||||
mock_config.caching = True
|
mock_config.caching = True
|
||||||
|
|
||||||
with patch("redis.Redis"):
|
with patch("cognee.infrastructure.databases.cache.redis.RedisAdapter.redis.Redis"):
|
||||||
engine = create_cache_engine(
|
engine = create_cache_engine(
|
||||||
cache_host="redis.example.com",
|
cache_host="redis.example.com",
|
||||||
cache_port=6380,
|
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):
|
with patch("cognee.infrastructure.databases.cache.get_cache_engine.config", mock_cache_config):
|
||||||
mock_cache_config.caching = True
|
mock_cache_config.caching = True
|
||||||
|
|
||||||
with patch("redis.Redis"):
|
with patch("cognee.infrastructure.databases.cache.redis.RedisAdapter.redis.Redis"):
|
||||||
with patch(
|
with patch(
|
||||||
"cognee.infrastructure.databases.cache.get_cache_engine.create_cache_engine"
|
"cognee.infrastructure.databases.cache.get_cache_engine.create_cache_engine"
|
||||||
) as mock_create:
|
) 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_expire = 100
|
||||||
mock_config.agentic_lock_timeout = 200
|
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")
|
engine = get_cache_engine("test-key")
|
||||||
|
|
||||||
assert isinstance(engine, RedisAdapter)
|
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:
|
with patch("cognee.infrastructure.databases.cache.get_cache_engine.config") as mock_config:
|
||||||
mock_config.caching = True
|
mock_config.caching = True
|
||||||
|
|
||||||
with patch("redis.Redis"):
|
with patch("cognee.infrastructure.databases.cache.redis.RedisAdapter.redis.Redis"):
|
||||||
engine = create_cache_engine(
|
engine = create_cache_engine(
|
||||||
cache_host="localhost",
|
cache_host="localhost",
|
||||||
cache_port=6379,
|
cache_port=6379,
|
||||||
|
|
@ -211,7 +211,7 @@ def test_full_workflow_with_context_manager():
|
||||||
mock_config.agentic_lock_expire = 240
|
mock_config.agentic_lock_expire = 240
|
||||||
mock_config.agentic_lock_timeout = 300
|
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_instance = MagicMock()
|
||||||
mock_redis_class.return_value = mock_redis_instance
|
mock_redis_class.return_value = mock_redis_instance
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue