Skip to content

Commit

Permalink
ref: remove unused UserRole.permissions_for_user (#72801)
Browse files Browse the repository at this point in the history
- function contains a type error
- only called in tests
- last reference removed in 8bbc88d

<!-- Describe your PR here. -->
  • Loading branch information
asottile-sentry authored Jun 14, 2024
1 parent c136332 commit 12468e0
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 21 deletions.
11 changes: 0 additions & 11 deletions src/sentry/models/userrole.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,6 @@ def outboxes_for_update(self, shard_identifier: int | None = None) -> list[Contr
)
]

@classmethod
def permissions_for_user(cls, user_id: int) -> frozenset[str]:
"""
Return a set of permission for the given user ID scoped to roles.
"""
return frozenset(
i
for sl in cls.objects.filter(users=user_id).values_list("permissions", flat=True)
for i in sl
)


@control_silo_model
class UserRoleUser(ControlOutboxProducingModel):
Expand Down
10 changes: 0 additions & 10 deletions tests/sentry/models/test_userrole.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,6 @@ class UserRoleTest(TestCase):
def setUp(self) -> None:
manage_default_super_admin_role()

def test_permissions_for_user(self):
user = self.create_user(email="[email protected]")
user2 = self.create_user(email="[email protected]")
role = UserRole.objects.create(name="test", permissions=["test1", "test2"])
role.users.add(user)
role2 = UserRole.objects.create(name="test2", permissions=["test2", "test3"])
role2.users.add(user)
assert sorted(UserRole.permissions_for_user(user.id)) == ["test1", "test2", "test3"]
assert sorted(UserRole.permissions_for_user(user2.id)) == []

def test_creates_super_admin_role(self):
role = UserRole.objects.get(name="Super Admin")
assert sorted(role.permissions) == sorted(settings.SENTRY_USER_PERMISSIONS)

0 comments on commit 12468e0

Please sign in to comment.