Skip to content

Commit

Permalink
dropped parameter used only in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Neagu committed Aug 21, 2024
1 parent 00e7ece commit f7c9fc1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,6 @@ async def _get_resolved_access_rights(
gid: _GroupID,
*,
permissions: _FolderPermissions | None,
only_enabled_permissions: bool = True,
) -> _ResolvedAccessRights | None:

# Define the anchor CTE
Expand Down Expand Up @@ -377,20 +376,7 @@ async def _get_resolved_access_rights(
)

# Combine anchor and recursive CTE
folder_hierarchy = access_rights_cte.union_all(recursive)

def _get_permissions_filter() -> ColumnElement | bool:
if not permissions:
return True
return (
_get_filter_for_enabled_permissions(permissions, folder_hierarchy)
if only_enabled_permissions
else sa.and_(
folder_hierarchy.c.read.is_(permissions.read),
folder_hierarchy.c.write.is_(permissions.write),
folder_hierarchy.c.delete.is_(permissions.delete),
)
)
folder_hierarchy: CTE = access_rights_cte.union_all(recursive)

# Final query to filter and order results
query = (
Expand All @@ -404,7 +390,11 @@ def _get_permissions_filter() -> ColumnElement | bool:
folder_hierarchy.c.delete,
folder_hierarchy.c.level,
)
.where(_get_permissions_filter())
.where(
True
if not permissions
else _get_filter_for_enabled_permissions(permissions, folder_hierarchy)
)
.where(folder_hierarchy.c.original_parent_id.is_(None))
.where(folder_hierarchy.c.gid == gid)
.order_by(folder_hierarchy.c.level.asc())
Expand Down
4 changes: 0 additions & 4 deletions packages/postgres-database/tests/test_utils_folders.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,10 +604,6 @@ async def _assert_resolves_to(
target_folder_id,
gid,
permissions=permissions,
# NOTE: this is the more restricitve case
# and we test against exact user roles,
# the APIs use only a subset of the permissions set to True
only_enabled_permissions=False,
)
assert resolved_parent
assert resolved_parent.folder_id == expected_folder_id
Expand Down

0 comments on commit f7c9fc1

Please sign in to comment.