Files
mayan-edms/mayan/apps/permissions/tests/test_models.py
Roberto Rosario 8e69178e07 Project: Switch to full app paths
Instead of inserting the path of the apps into the Python app,
the apps are now referenced by their full import path.

This app name claves 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>
2018-12-05 02:04:20 -04:00

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.')