test: Update test regarding message
Update assertion message, add veryfing of file existence
This commit is contained in:
parent
1406b6f078
commit
d7195f9786
2 changed files with 9 additions and 2 deletions
|
|
@ -132,11 +132,17 @@ class SQLAlchemyAdapter():
|
|||
|
||||
# Don't delete local file unless this is the only reference to the file in the database
|
||||
if len(raw_data_location_entities) == 1:
|
||||
|
||||
# delete local file only if it's created by cognee
|
||||
from cognee.base_config import get_base_config
|
||||
config = get_base_config()
|
||||
|
||||
if config.data_root_directory in raw_data_location_entities[0].raw_data_location:
|
||||
os.remove(raw_data_location_entities[0].raw_data_location)
|
||||
if os.path.exists(raw_data_location_entities[0].raw_data_location):
|
||||
os.remove(raw_data_location_entities[0].raw_data_location)
|
||||
else:
|
||||
# Report bug as file should exist
|
||||
pass
|
||||
|
||||
await session.execute(delete(Data).where(Data.id == data_id))
|
||||
await session.commit()
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ async def test_local_file_deletion(data_text, file_location):
|
|||
assert os.path.isfile(data.raw_data_location), f"Data location doesn't exist: {data.raw_data_location}"
|
||||
# Test deletion of data along with local files created by cognee
|
||||
await engine.delete_data_entity(data.id)
|
||||
assert not os.path.exists(data.raw_data_location), f"Data location exists: {data.raw_data_location}"
|
||||
assert not os.path.exists(
|
||||
data.raw_data_location), f"Data location still exists after deletion: {data.raw_data_location}"
|
||||
|
||||
async with engine.get_async_session() as session:
|
||||
# Get data entry from database based on file path
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue