From 12468e03587d8cdab715604e94e4996e791eea5a Mon Sep 17 00:00:00 2001 From: anthony sottile <103459774+asottile-sentry@users.noreply.github.com> Date: Fri, 14 Jun 2024 15:19:22 -0400 Subject: [PATCH] ref: remove unused UserRole.permissions_for_user (#72801) - function contains a type error - only called in tests - last reference removed in 8bbc88dafb32c04f22066a30247c9c357a62f20b --- src/sentry/models/userrole.py | 11 ----------- tests/sentry/models/test_userrole.py | 10 ---------- 2 files changed, 21 deletions(-) diff --git a/src/sentry/models/userrole.py b/src/sentry/models/userrole.py index 6e32685eefbd70..1f061c71ddc0ae 100644 --- a/src/sentry/models/userrole.py +++ b/src/sentry/models/userrole.py @@ -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): diff --git a/tests/sentry/models/test_userrole.py b/tests/sentry/models/test_userrole.py index 90506f09c3cdb7..e51e932690eea5 100644 --- a/tests/sentry/models/test_userrole.py +++ b/tests/sentry/models/test_userrole.py @@ -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="a@example.com") - user2 = self.create_user(email="b@example.com") - 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)