2015-01-22 18:29:12 +01:00
|
|
|
from unittest import TestCase
|
2015-02-12 20:57:05 +01:00
|
|
|
from unittest.mock import patch
|
2015-01-22 18:29:12 +01:00
|
|
|
|
2015-02-12 20:57:05 +01:00
|
|
|
from openslides.users.api import get_protected_perm
|
2015-01-22 18:29:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
@patch('openslides.users.api.Permission')
|
|
|
|
class GetProtectedPerm(TestCase):
|
|
|
|
def test_normal(self, mock_permission):
|
|
|
|
mock_permission.objects.get_by_natural_key.return_value = 'test_permission'
|
|
|
|
|
|
|
|
value = get_protected_perm()
|
|
|
|
|
|
|
|
mock_permission.objects.get_by_natural_key.assert_called_once_with(
|
|
|
|
app_label='users', model='user', codename='can_manage')
|
|
|
|
self.assertEqual(
|
|
|
|
value,
|
|
|
|
'test_permission',
|
|
|
|
"The function should return the user.can_manage permission")
|