From 6c50d0793d5c6d38e873e9eba3bea2ae10a5ad67 Mon Sep 17 00:00:00 2001 From: Akita Noek Date: Sat, 16 Apr 2016 10:22:03 -0400 Subject: [PATCH] More test fixes --- awx/main/models/mixins.py | 2 +- awx/main/tests/old/inventory.py | 4 ++-- awx/main/tests/old/organizations.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/awx/main/models/mixins.py b/awx/main/models/mixins.py index a54f49dfd6..1e91333b4a 100644 --- a/awx/main/models/mixins.py +++ b/awx/main/models/mixins.py @@ -22,7 +22,7 @@ class ResourceMixin(models.Model): Use instead of `MyModel.objects` when you want to only consider resources that a user has specific permissions for. For example: - MyModel.accessible_objects(user, {'read': True}).filter(name__istartswith='bar'); + MyModel.accessible_objects(user, 'read_role').filter(name__istartswith='bar'); NOTE: This should only be used for list type things. If you have a specific resource you want to check permissions on, it is more diff --git a/awx/main/tests/old/inventory.py b/awx/main/tests/old/inventory.py index 6d167ad10a..150eb45a31 100644 --- a/awx/main/tests/old/inventory.py +++ b/awx/main/tests/old/inventory.py @@ -77,7 +77,7 @@ class InventoryTest(BaseTest): self.check_get_list(url, self.normal_django_user, normal_qs) # a user who is on a team who has a read permissions on an inventory can see filtered inventories - other_qs = Inventory.accessible_objects(self.other_django_user, {'read': True}).distinct() + other_qs = Inventory.accessible_objects(self.other_django_user, 'read_role').distinct() self.check_get_list(url, self.other_django_user, other_qs) # a regular user not part of anything cannot see any inventories @@ -401,7 +401,7 @@ class InventoryTest(BaseTest): del_children_url = reverse('api:group_children_list', args=(del_group.pk,)) nondel_url = reverse('api:group_detail', args=(Group.objects.get(name='nondel').pk,)) - assert(inv.accessible_by(self.normal_django_user, {'read': True})) + assert self.normal_django_user in inv.read_role del_group.delete() nondel_detail = self.get(nondel_url, expect=200, auth=self.get_normal_credentials()) self.post(del_children_url, data=nondel_detail, expect=400, auth=self.get_normal_credentials()) diff --git a/awx/main/tests/old/organizations.py b/awx/main/tests/old/organizations.py index 1ace31a340..136e2603cc 100644 --- a/awx/main/tests/old/organizations.py +++ b/awx/main/tests/old/organizations.py @@ -289,7 +289,7 @@ class OrganizationsTest(BaseTest): # post a completely new user to verify we can add users to the subcollection directly new_user = dict(username='NewUser9000', password='NewPassword9000') - which_org = Organization.accessible_objects(self.normal_django_user, {'read': True, 'write': True})[0] + which_org = Organization.accessible_objects(self.normal_django_user, 'admin_role')[0] url = reverse('api:organization_users_list', args=(which_org.pk,)) self.post(url, new_user, expect=201, auth=self.get_normal_credentials())