Skip to content

Commit

Permalink
Replace method of accessing user permission
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaberetta committed Jan 21, 2021
1 parent 24d41e0 commit b12ef8f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions kpi/tests/api/v2/test_api_permissions.py
Expand Up @@ -5,7 +5,7 @@

from kpi.constants import PERM_VIEW_ASSET, PERM_CHANGE_ASSET, \
PERM_SHARE_ASSET
from kpi.models.object_permission import get_anonymous_user
from kpi.models.object_permission import get_anonymous_user, ObjectPermission
from kpi.tests.kpi_test_case import KpiTestCase
from kpi.urls.router_api_v2 import URL_NAMESPACE as ROUTER_URL_NAMESPACE

Expand Down Expand Up @@ -286,9 +286,10 @@ def test_shared_asset_non_owner_remove_owners_permissions_not_allowed(self):
name='a new asset',
owner=self.someuser,
)
# someuser obviously has `PERM_VIEW_ASSET` set, but this seems to be
# the only way to access the uid of that permission to pass into `kwargs`
perm = new_asset.assign_perm(self.someuser, PERM_VIEW_ASSET)
# Getting existing permission for the owner of the asset
perm = ObjectPermission.objects.filter(asset=new_asset).get(
user=self.someuser, permission__codename=PERM_VIEW_ASSET
)
new_asset.assign_perm(self.anotheruser, PERM_VIEW_ASSET)
kwargs = {
'parent_lookup_asset': new_asset.uid,
Expand Down

0 comments on commit b12ef8f

Please sign in to comment.