Skip to content

Commit

Permalink
FIX: PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
dalmia committed Jun 19, 2021
1 parent 22a6f38 commit 6057e30
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions users/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,13 @@ def test_user_cannot_get_other_user_config(self):
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)

def test_update_config_no_config_provided(self):
"""Updating config without passing the config to use should fail"""
# update config
response = self.client.patch(f"/api/v1/users/{self.user.id}/config/", {})
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)

def test_update_config_extra_params(self):
"""Passing params other than config while updating config should fail"""
# update config
response = self.client.patch(
f"/api/v1/users/{self.user.id}/config/",
Expand Down Expand Up @@ -180,7 +182,7 @@ def setUp(self):
organization=self.organization_2, user=self.user, role=self.org_view_role
)

def test_superuser_can_list_all_organization_users(self):
def test_superuser_can_list_all_org_users(self):
# make the current user as superuser
self.user.is_superuser = True
self.user.save()
Expand All @@ -194,13 +196,13 @@ def test_superuser_can_list_all_organization_users(self):
self.assertEqual(response.json()[0]["organization"], self.organization.id)
self.assertEqual(response.json()[1]["organization"], self.organization_2.id)

def test_normal_user_cannot_list_organization_users(self):
def test_normal_user_only_sees_empty_list_of_org_users(self):
# get organization users
response = self.client.get(reverse("organization-users-list"))
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(len(response.json()), 0)

def test_org_admin_can_list_only_their_organization_users(self):
def test_org_admin_can_list_only_their_org_users(self):
# make user 2 org-admin for org 1
org_admin_role = Role.objects.filter(name="org-admin").first()
OrganizationUser.objects.create(
Expand All @@ -221,7 +223,7 @@ def test_org_admin_can_list_only_their_organization_users(self):
self.assertEqual(response.json()[1]["user"], self.user_2.id)
self.assertEqual(response.json()[1]["organization"], self.organization.id)

def test_normal_user_cannot_create_organization_user(self):
def test_normal_user_cannot_create_org_user(self):
# add organization_user to the organization
response = self.client.post(
reverse("organization-users-list"),
Expand All @@ -233,7 +235,7 @@ def test_normal_user_cannot_create_organization_user(self):
)
self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)

def test_superuser_can_create_organization_user(self):
def test_superuser_can_create_org_user(self):
# make the current user as superuser
self.user.is_superuser = True
self.user.save()
Expand Down

0 comments on commit 6057e30

Please sign in to comment.