From cd8b952ca8ee325d75802bc9d3b4935f8ca0564d Mon Sep 17 00:00:00 2001 From: Boris Arzentar Date: Thu, 16 Oct 2025 18:27:43 +0200 Subject: [PATCH] fix: unit tests --- cognee/api/v1/cognify/cognify.py | 1 - cognee/api/v1/datasets/datasets.py | 2 +- cognee/cli/commands/delete_command.py | 8 +++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cognee/api/v1/cognify/cognify.py b/cognee/api/v1/cognify/cognify.py index ac33f7ffe..c3045f00a 100644 --- a/cognee/api/v1/cognify/cognify.py +++ b/cognee/api/v1/cognify/cognify.py @@ -17,7 +17,6 @@ from cognee.modules.ontology.get_default_ontology_resolver import ( get_ontology_resolver_from_env, ) from cognee.modules.users.models import User -from cognee.modules.users.methods import get_default_user from cognee.tasks.documents import ( check_permissions_on_dataset, diff --git a/cognee/api/v1/datasets/datasets.py b/cognee/api/v1/datasets/datasets.py index 14979df87..eafe7468e 100644 --- a/cognee/api/v1/datasets/datasets.py +++ b/cognee/api/v1/datasets/datasets.py @@ -13,7 +13,7 @@ from cognee.modules.users.models import User class datasets: @staticmethod async def list_datasets(user: Optional[User] = None): - if user == None: + if user is None: user = await get_default_user() return await get_authorized_existing_datasets([], "read", user) diff --git a/cognee/cli/commands/delete_command.py b/cognee/cli/commands/delete_command.py index 37fd5736d..b2873748e 100644 --- a/cognee/cli/commands/delete_command.py +++ b/cognee/cli/commands/delete_command.py @@ -8,6 +8,7 @@ from cognee.cli.exceptions import CliCommandException, CliCommandInnerException from cognee.api.v1.datasets.datasets import datasets as cognee_datasets from cognee.modules.data.methods import get_datasets_by_name from cognee.modules.data.methods.get_deletion_counts import get_deletion_counts +from cognee.modules.users.methods import get_default_user, get_user class DeleteCommand(SupportsCliCommand): @@ -127,7 +128,12 @@ Be careful with deletion operations as they are irreversible. "No user ID provided for deletion. Please specify using --user-id param." ) - await cognee_datasets.delete_dataset(dataset_id=dataset_id, user=args.user) + if not args.user_id: + user = await get_default_user() + else: + user = await get_user(args.user_id) + + await cognee_datasets.delete_dataset(dataset_id=dataset_id, user=user) elif hasattr(args, "dataset_id") and hasattr(args, "data_id"): await cognee_datasets.delete_data(args.dataset_id, args.data_id) except Exception as e: