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>
49 lines
1.7 KiB
Python
49 lines
1.7 KiB
Python
from __future__ import unicode_literals
|
|
|
|
from django.contrib.contenttypes.models import ContentType
|
|
|
|
from mayan.apps.document_states.tests.test_actions import ActionTestCase
|
|
from mayan.apps.documents.permissions import permission_document_view
|
|
|
|
from ..workflow_actions import GrantAccessAction, RevokeAccessAction
|
|
|
|
|
|
class ACLActionTestCase(ActionTestCase):
|
|
def setUp(self):
|
|
super(ACLActionTestCase, self).setUp()
|
|
|
|
def test_grant_access_action(self):
|
|
action = GrantAccessAction(
|
|
form_data={
|
|
'content_type': ContentType.objects.get_for_model(model=self.document).pk,
|
|
'object_id': self.document.pk,
|
|
'roles': [self.role.pk],
|
|
'permissions': [permission_document_view.uuid],
|
|
}
|
|
)
|
|
action.execute(context={'entry_log': self.entry_log})
|
|
|
|
self.assertEqual(self.document.acls.count(), 1)
|
|
self.assertEqual(
|
|
list(self.document.acls.first().permissions.all()),
|
|
[permission_document_view.stored_permission]
|
|
)
|
|
self.assertEqual(self.document.acls.first().role, self.role)
|
|
|
|
def test_revoke_access_action(self):
|
|
self.grant_access(
|
|
obj=self.document, permission=permission_document_view
|
|
)
|
|
|
|
action = RevokeAccessAction(
|
|
form_data={
|
|
'content_type': ContentType.objects.get_for_model(model=self.document).pk,
|
|
'object_id': self.document.pk,
|
|
'roles': [self.role.pk],
|
|
'permissions': [permission_document_view.uuid],
|
|
}
|
|
)
|
|
action.execute(context={'entry_log': self.entry_log})
|
|
|
|
self.assertEqual(self.document.acls.count(), 0)
|