test: Add checking of Networkx database deletion

Add test to check if networkx database has been cleaned properly

Test COG-488
This commit is contained in:
Igor Ilic 2024-11-21 16:09:50 +01:00
parent b815aeaa2a
commit ac3f988278
2 changed files with 11 additions and 3 deletions

View file

@ -57,15 +57,23 @@ async def main():
assert len(history) == 6, "Search history is not correct."
# Assert local data files are cleaned properly
await cognee.prune.prune_data()
assert not os.path.isdir(data_directory_path), "Local data files are not deleted"
# Assert relational, vector and graph databases have been cleaned properly
await cognee.prune.prune_system(metadata=True)
connection = await vector_engine.get_connection()
collection_names = await connection.table_names()
assert len(collection_names) == 0, "The vector database is not empty"
assert len(collection_names) == 0, "LanceDB vector database is not empty"
from cognee.infrastructure.databases.relational import get_relational_engine
assert not os.path.exists(get_relational_engine().db_path), "The relational database is not empty"
assert not os.path.exists(get_relational_engine().db_path), "SQLite relational database is not empty"
from cognee.infrastructure.databases.graph import get_graph_config
graph_config = get_graph_config()
assert not os.path.exists(graph_config.graph_file_path), "Networkx graph database is not empty"
if __name__ == "__main__":
import asyncio

View file

@ -94,7 +94,7 @@ async def main():
await cognee.prune.prune_system(metadata=True)
tables_in_database = await vector_engine.get_table_names()
assert len(tables_in_database) == 0, "The database is not empty"
assert len(tables_in_database) == 0, "PostgreSQL database is not empty"
if __name__ == "__main__":
import asyncio