Instead of inserting the path of the apps into the Python app, the apps are now referenced by their full import path. This solves name clashes with external or native Python libraries. Example: Mayan statistics app vs. Python new statistics library. Every app reference is now prepended with 'mayan.apps'. Existing config.yml files need to be updated manually. Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
32 lines
992 B
Python
32 lines
992 B
Python
from __future__ import unicode_literals
|
|
|
|
from django.core.exceptions import PermissionDenied
|
|
|
|
from mayan.apps.common.tests import BaseTestCase
|
|
|
|
from ..classes import Permission
|
|
from ..permissions import permission_role_view
|
|
|
|
|
|
class PermissionTestCase(BaseTestCase):
|
|
def setUp(self):
|
|
super(PermissionTestCase, self).setUp()
|
|
|
|
def test_no_permissions(self):
|
|
with self.assertRaises(PermissionDenied):
|
|
Permission.check_permissions(
|
|
requester=self.user, permissions=(permission_role_view,)
|
|
)
|
|
|
|
def test_with_permissions(self):
|
|
self.group.user_set.add(self.user)
|
|
self.role.permissions.add(permission_role_view.stored_permission)
|
|
self.role.groups.add(self.group)
|
|
|
|
try:
|
|
Permission.check_permissions(
|
|
requester=self.user, permissions=(permission_role_view,)
|
|
)
|
|
except PermissionDenied:
|
|
self.fail('PermissionDenied exception was not expected.')
|