Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 10 additions & 17 deletions tests/testapp/tests/test_permission_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,6 @@ def test_operator_none(self):
response = self.client.get(self.owner_url, **auth)
self.assertEqual(response.status_code, 403)

def test_operator_member(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you removing this test?

operator = self._get_operator()
self._create_org_user(user=operator)
token = self._obtain_auth_token()
auth = dict(HTTP_AUTHORIZATION=f"Bearer {token}")
with self.subTest("Organization Member"):
response = self.client.get(self.member_url, **auth)
self.assertEqual(response.status_code, 200)
with self.subTest("Organization Manager"):
response = self.client.get(self.manager_url, **auth)
self.assertEqual(response.status_code, 403)
with self.subTest("Organization Owner"):
response = self.client.get(self.owner_url, **auth)
self.assertEqual(response.status_code, 403)

def test_operator_manager(self):
operator = self._get_operator()
# First user is automatically owner, so created dummy
Expand All @@ -59,12 +44,20 @@ def test_operator_manager(self):
self._create_org_user(user=operator, is_admin=True)
token = self._obtain_auth_token()
auth = dict(HTTP_AUTHORIZATION=f"Bearer {token}")

with self.subTest("Organization Member"):
response = self.client.get(self.member_url, **auth)
self.assertEqual(response.status_code, 200)
with self.subTest("Organization Manager"):

# Organization Manager
# Query breakdown for IsOrganizationManager permission check:
# 1 query for IsOrganizationManager.has_permission() checking
# organizations_managed. Remaining queries are for object
# creation/get and object-level permission checks
with self.assertNumQueries(4):
response = self.client.get(self.manager_url, **auth)
self.assertEqual(response.status_code, 200)
self.assertEqual(response.status_code, 200)

with self.subTest("Organization Owner"):
response = self.client.get(self.owner_url, **auth)
self.assertEqual(response.status_code, 403)
Expand Down
Loading