fix: failing tests

This commit is contained in:
Boris Arzentar 2025-10-13 17:29:44 +02:00
parent dc64dd5ffa
commit 4d1cf5393c
No known key found for this signature in database
GPG key ID: D5CC274C784807B7
4 changed files with 17 additions and 9 deletions

View file

@ -174,8 +174,8 @@ jobs:
cd dist
pip install *.whl
run-soft-deletion-test:
name: Soft Delete test ${{ matrix.python-version }} on ${{ matrix.os }}
run-deletion-on-default-graph-test:
name: Delete default graph data test ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
@ -193,7 +193,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Run Soft Deletion Tests
- name: Run Deletion on Default Graph Tests
env:
ENV: 'dev'
LLM_API_KEY: ${{ secrets.OPENAI_API_KEY }} # Test needs OpenAI endpoint to handle multimedia
@ -202,10 +202,10 @@ jobs:
EMBEDDING_ENDPOINT: ${{ secrets.EMBEDDING_ENDPOINT }}
EMBEDDING_API_KEY: ${{ secrets.EMBEDDING_API_KEY }}
EMBEDDING_API_VERSION: ${{ secrets.EMBEDDING_API_VERSION }}
run: uv run python ./cognee/tests/test_delete_soft.py
run: uv run python ./cognee/tests/test_delete_default_graph.py
run-hard-deletion-test:
name: Hard Delete test ${{ matrix.python-version }} on ${{ matrix.os }}
run-deletion-on-custom-graph-test:
name: Delete custom graph data test ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
@ -232,4 +232,4 @@ jobs:
EMBEDDING_ENDPOINT: ${{ secrets.EMBEDDING_ENDPOINT }}
EMBEDDING_API_KEY: ${{ secrets.EMBEDDING_API_KEY }}
EMBEDDING_API_VERSION: ${{ secrets.EMBEDDING_API_VERSION }}
run: uv run python ./cognee/tests/test_delete_hard.py
run: uv run python ./cognee/tests/test_delete_custom_graph.py

View file

@ -2,6 +2,7 @@ from uuid import UUID
from typing import Union, BinaryIO, List, Optional
from cognee.modules.users.models import User
from cognee.modules.users.methods import get_default_user
from cognee.api.v1.add import add
from cognee.api.v1.cognify import cognify
from cognee.api.v1.datasets import datasets
@ -72,6 +73,9 @@ async def update(
- Processing status and any errors
- Execution timestamps and metadata
"""
if not user:
user = get_default_user()
await datasets.delete_data(
dataset_id=dataset_id,
data_id=data_id,

View file

@ -2,6 +2,7 @@ import os
import cognee
import pathlib
from cognee.modules.data.exceptions.exceptions import UnauthorizedDataAccessError
from cognee.modules.users.exceptions import PermissionDeniedError
from cognee.shared.logging_utils import get_logger
from cognee.modules.search.types import SearchType
@ -193,10 +194,12 @@ async def main():
data_id=text_data_id,
user_id=default_user.id,
)
except PermissionDeniedError:
except UnauthorizedDataAccessError:
delete_error = True
assert delete_error, "PermissionDeniedError was not raised during delete operation as expected"
assert delete_error, (
"UnauthorizedDataAccessError was not raised during delete operation as expected"
)
# Try deleting data from test_user dataset with test_user
# Get the dataset data to find the ID of the first data item (text)

View file

@ -13,6 +13,7 @@ from cognee.infrastructure.databases.graph import get_graph_engine
from cognee.low_level import setup, DataPoint
from cognee.modules.data.models import Dataset
from cognee.modules.users.methods import get_default_user
from cognee.modules.users.models import User
from cognee.pipelines import run_tasks, Task
from cognee.tasks.storage import add_data_points