Update test_search_db.py
This commit is contained in:
parent
b2d2fd971d
commit
41a3d75ed8
1 changed files with 18 additions and 14 deletions
|
|
@ -26,26 +26,28 @@ logger = get_logger()
|
|||
async def setup_test_environment():
|
||||
"""Helper function to set up test environment with data, cognify, and triplet embeddings."""
|
||||
# This test runs for multiple db settings, to run this locally set the corresponding db envs
|
||||
|
||||
|
||||
# Dispose of existing engines and clear caches to ensure fresh instances for each test
|
||||
# This prevents event loop issues when using deployed databases (Neo4j, PostgreSQL)
|
||||
try:
|
||||
from cognee.infrastructure.databases.vector import get_vector_engine
|
||||
|
||||
vector_engine = get_vector_engine()
|
||||
# Dispose SQLAlchemy engine connection pool if it exists
|
||||
if hasattr(vector_engine, 'engine') and hasattr(vector_engine.engine, 'dispose'):
|
||||
if hasattr(vector_engine, "engine") and hasattr(vector_engine.engine, "dispose"):
|
||||
await vector_engine.engine.dispose(close=True)
|
||||
except Exception:
|
||||
pass # Engine might not exist yet
|
||||
|
||||
pass
|
||||
|
||||
from cognee.infrastructure.databases.graph.get_graph_engine import create_graph_engine
|
||||
from cognee.infrastructure.databases.vector.create_vector_engine import create_vector_engine
|
||||
from cognee.infrastructure.databases.relational.create_relational_engine import create_relational_engine
|
||||
|
||||
from cognee.infrastructure.databases.relational.create_relational_engine import (
|
||||
create_relational_engine,
|
||||
)
|
||||
|
||||
create_graph_engine.cache_clear()
|
||||
create_vector_engine.cache_clear()
|
||||
create_relational_engine.cache_clear()
|
||||
|
||||
|
||||
logger.info("Starting test setup: pruning data and system")
|
||||
await cognee.prune.prune_data()
|
||||
await cognee.prune.prune_system(metadata=True)
|
||||
|
|
@ -95,21 +97,24 @@ async def setup_test_environment_for_feedback():
|
|||
# This prevents event loop issues when using deployed databases (Neo4j, PostgreSQL)
|
||||
try:
|
||||
from cognee.infrastructure.databases.vector import get_vector_engine
|
||||
|
||||
vector_engine = get_vector_engine()
|
||||
# Dispose SQLAlchemy engine connection pool if it exists
|
||||
if hasattr(vector_engine, 'engine') and hasattr(vector_engine.engine, 'dispose'):
|
||||
if hasattr(vector_engine, "engine") and hasattr(vector_engine.engine, "dispose"):
|
||||
await vector_engine.engine.dispose(close=True)
|
||||
except Exception:
|
||||
pass # Engine might not exist yet
|
||||
|
||||
|
||||
from cognee.infrastructure.databases.graph.get_graph_engine import create_graph_engine
|
||||
from cognee.infrastructure.databases.vector.create_vector_engine import create_vector_engine
|
||||
from cognee.infrastructure.databases.relational.create_relational_engine import create_relational_engine
|
||||
|
||||
from cognee.infrastructure.databases.relational.create_relational_engine import (
|
||||
create_relational_engine,
|
||||
)
|
||||
|
||||
create_graph_engine.cache_clear()
|
||||
create_vector_engine.cache_clear()
|
||||
create_relational_engine.cache_clear()
|
||||
|
||||
|
||||
await cognee.prune.prune_data()
|
||||
await cognee.prune.prune_system(metadata=True)
|
||||
|
||||
|
|
@ -151,7 +156,6 @@ async def test_graph_vector_engine_consistency():
|
|||
)
|
||||
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_retriever_contexts():
|
||||
"""Test that all retrievers return valid contexts with expected content."""
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue