Fix base test class mixin inheritance
Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
This commit is contained in:
@@ -14,7 +14,6 @@ from django.utils.http import urlunquote_plus
|
||||
from mayan.apps.common.tests import GenericViewTestCase
|
||||
from mayan.apps.smart_settings.classes import Namespace
|
||||
from mayan.apps.user_management.permissions import permission_user_edit
|
||||
from mayan.apps.user_management.tests.mixins import UserTestMixin
|
||||
from mayan.apps.user_management.tests.literals import TEST_USER_PASSWORD_EDITED
|
||||
|
||||
from ..settings import setting_maximum_session_length
|
||||
@@ -39,7 +38,9 @@ class CurrentUserViewTestCase(GenericViewTestCase):
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
self._test_case_user.refresh_from_db()
|
||||
self.assertTrue(self._test_case_user.check_password(raw_password=new_password))
|
||||
self.assertTrue(
|
||||
self._test_case_user.check_password(raw_password=new_password)
|
||||
)
|
||||
|
||||
|
||||
class UserLoginTestCase(GenericViewTestCase):
|
||||
@@ -262,7 +263,7 @@ class UserLoginTestCase(GenericViewTestCase):
|
||||
self.assertEqual(response.redirect_chain, [(TEST_REDIRECT_URL, 302)])
|
||||
|
||||
|
||||
class UserViewTestCase(UserTestMixin, UserPasswordViewTestMixin, GenericViewTestCase):
|
||||
class UserViewTestCase(UserPasswordViewTestMixin, GenericViewTestCase):
|
||||
def test_user_set_password_view_no_access(self):
|
||||
self._create_test_user()
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ from django.contrib.auth import get_user_model
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
|
||||
from mayan.apps.acls.classes import ModelPermission
|
||||
from mayan.apps.user_management.tests.mixins import UserTestMixin
|
||||
|
||||
from ..models import ErrorLogEntry
|
||||
from ..permissions_runtime import permission_error_log_view
|
||||
@@ -13,7 +12,7 @@ from .base import GenericViewTestCase
|
||||
from .literals import TEST_ERROR_LOG_ENTRY_RESULT
|
||||
|
||||
|
||||
class CommonViewTestCase(UserTestMixin, GenericViewTestCase):
|
||||
class CommonViewTestCase(GenericViewTestCase):
|
||||
def _request_about_view(self):
|
||||
return self.get(viewname='common:about_view')
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ from __future__ import unicode_literals
|
||||
from django.core.exceptions import PermissionDenied
|
||||
|
||||
from mayan.apps.common.tests import BaseTestCase
|
||||
from mayan.apps.user_management.tests.mixins import GroupTestMixin, UserTestMixin
|
||||
from mayan.apps.user_management.tests.mixins import GroupTestMixin
|
||||
|
||||
from ..classes import Permission, PermissionNamespace
|
||||
from ..models import StoredPermission
|
||||
@@ -16,7 +16,9 @@ from .literals import (
|
||||
from .mixins import PermissionTestMixin, RoleTestMixin
|
||||
|
||||
|
||||
class PermissionTestCase(GroupTestMixin, PermissionTestMixin, RoleTestMixin, UserTestMixin, BaseTestCase):
|
||||
class PermissionTestCase(
|
||||
GroupTestMixin, PermissionTestMixin, RoleTestMixin, BaseTestCase
|
||||
):
|
||||
def setUp(self):
|
||||
super(PermissionTestCase, self).setUp()
|
||||
self._create_test_user()
|
||||
|
||||
@@ -14,9 +14,7 @@ from ..permissions import (
|
||||
permission_user_edit, permission_user_view
|
||||
)
|
||||
|
||||
from .mixins import (
|
||||
GroupAPITestMixin, GroupTestMixin, UserAPITestMixin, UserTestMixin
|
||||
)
|
||||
from .mixins import GroupAPITestMixin, GroupTestMixin, UserAPITestMixin
|
||||
|
||||
|
||||
class GroupAPITestCase(GroupAPITestMixin, GroupTestMixin, BaseAPITestCase):
|
||||
@@ -50,7 +48,9 @@ class GroupAPITestCase(GroupAPITestMixin, GroupTestMixin, BaseAPITestCase):
|
||||
|
||||
def test_group_delete_with_access(self):
|
||||
self._create_test_group()
|
||||
self.grant_access(obj=self.test_group, permission=permission_group_delete)
|
||||
self.grant_access(
|
||||
obj=self.test_group, permission=permission_group_delete
|
||||
)
|
||||
group_count = Group.objects.count()
|
||||
|
||||
response = self._request_test_group_delete_api_view()
|
||||
@@ -72,7 +72,9 @@ class GroupAPITestCase(GroupAPITestMixin, GroupTestMixin, BaseAPITestCase):
|
||||
def test_group_edit_via_patch_with_access(self):
|
||||
self._create_test_group()
|
||||
|
||||
self.grant_access(obj=self.test_group, permission=permission_group_edit)
|
||||
self.grant_access(
|
||||
obj=self.test_group, permission=permission_group_edit
|
||||
)
|
||||
|
||||
group_name = self.test_group.name
|
||||
|
||||
@@ -96,7 +98,9 @@ class GroupAPITestCase(GroupAPITestMixin, GroupTestMixin, BaseAPITestCase):
|
||||
def test_group_edit_via_put_with_access(self):
|
||||
self._create_test_group()
|
||||
|
||||
self.grant_access(obj=self.test_group, permission=permission_group_edit)
|
||||
self.grant_access(
|
||||
obj=self.test_group, permission=permission_group_edit
|
||||
)
|
||||
|
||||
group_name = self.test_group.name
|
||||
|
||||
@@ -107,7 +111,7 @@ class GroupAPITestCase(GroupAPITestMixin, GroupTestMixin, BaseAPITestCase):
|
||||
self.assertNotEqual(self.test_group.name, group_name)
|
||||
|
||||
|
||||
class UserAPITestCase(UserAPITestMixin, UserTestMixin, BaseAPITestCase):
|
||||
class UserAPITestCase(UserAPITestMixin, BaseAPITestCase):
|
||||
def test_user_create_api_view_no_permission(self):
|
||||
user_count = get_user_model().objects.count()
|
||||
|
||||
@@ -138,7 +142,9 @@ class UserAPITestCase(UserAPITestMixin, UserTestMixin, BaseAPITestCase):
|
||||
|
||||
def test_user_delete_with_access(self):
|
||||
self._create_test_user()
|
||||
self.grant_access(obj=self.test_user, permission=permission_user_delete)
|
||||
self.grant_access(
|
||||
obj=self.test_user, permission=permission_user_delete
|
||||
)
|
||||
|
||||
user_count = get_user_model().objects.count()
|
||||
|
||||
@@ -194,7 +200,7 @@ class UserAPITestCase(UserAPITestMixin, UserTestMixin, BaseAPITestCase):
|
||||
self.assertNotEqual(self.test_user.username, user_username)
|
||||
|
||||
|
||||
class UserGroupAPITestCase(GroupTestMixin, UserAPITestMixin, UserTestMixin, BaseAPITestCase):
|
||||
class UserGroupAPITestCase(GroupTestMixin, UserAPITestMixin, BaseAPITestCase):
|
||||
def test_user_create_with_group_api_view_no_permission(self):
|
||||
self._create_test_group()
|
||||
|
||||
|
||||
@@ -17,11 +17,13 @@ from ..events import (
|
||||
|
||||
from .mixins import (
|
||||
GroupAPITestMixin, GroupTestMixin, GroupViewTestMixin, UserAPITestMixin,
|
||||
UserTestMixin, UserViewTestMixin
|
||||
UserViewTestMixin
|
||||
)
|
||||
|
||||
|
||||
class GroupEventsViewTestCase(GroupTestMixin, GroupViewTestMixin, UserTestMixin, GenericViewTestCase):
|
||||
class GroupEventsViewTestCase(
|
||||
GroupTestMixin, GroupViewTestMixin, GenericViewTestCase
|
||||
):
|
||||
def test_group_create_event(self):
|
||||
self.grant_permission(
|
||||
permission=permission_group_create
|
||||
@@ -53,7 +55,9 @@ class GroupEventsViewTestCase(GroupTestMixin, GroupViewTestMixin, UserTestMixin,
|
||||
self.assertEqual(action.verb, event_group_edited.id)
|
||||
|
||||
|
||||
class GroupEventsAPITestCase(GroupAPITestMixin, GroupTestMixin, GroupViewTestMixin, BaseAPITestCase):
|
||||
class GroupEventsAPITestCase(
|
||||
GroupAPITestMixin, GroupTestMixin, GroupViewTestMixin, BaseAPITestCase
|
||||
):
|
||||
def test_group_create_event_from_api_view(self):
|
||||
self.grant_permission(
|
||||
permission=permission_group_create
|
||||
@@ -91,7 +95,7 @@ class GroupEventsAPITestCase(GroupAPITestMixin, GroupTestMixin, GroupViewTestMix
|
||||
self.assertEqual(action.verb, event_group_edited.id)
|
||||
|
||||
|
||||
class UserEventsTestCase(UserTestMixin, GenericViewTestCase):
|
||||
class UserEventsTestCase(GenericViewTestCase):
|
||||
auto_login_user = False
|
||||
create_test_case_user = False
|
||||
|
||||
@@ -130,7 +134,9 @@ class UserEventsTestCase(UserTestMixin, GenericViewTestCase):
|
||||
self.assertEqual(action.verb, event_user_logged_out.id)
|
||||
|
||||
|
||||
class UserEventsViewTestCase(UserAPITestMixin, UserTestMixin, UserViewTestMixin, GenericViewTestCase):
|
||||
class UserEventsViewTestCase(
|
||||
UserAPITestMixin, UserViewTestMixin, GenericViewTestCase
|
||||
):
|
||||
def test_user_create_event_from_view(self):
|
||||
self.grant_permission(
|
||||
permission=permission_user_create
|
||||
@@ -164,7 +170,9 @@ class UserEventsViewTestCase(UserAPITestMixin, UserTestMixin, UserViewTestMixin,
|
||||
self.assertEqual(action.verb, event_user_edited.id)
|
||||
|
||||
|
||||
class UserEventsAPITestCase(UserAPITestMixin, UserTestMixin, UserViewTestMixin, BaseAPITestCase):
|
||||
class UserEventsAPITestCase(
|
||||
UserAPITestMixin, UserViewTestMixin, BaseAPITestCase
|
||||
):
|
||||
def test_user_create_event_from_api_view(self):
|
||||
self.grant_permission(
|
||||
permission=permission_user_create
|
||||
|
||||
@@ -14,12 +14,12 @@ from ..permissions import (
|
||||
permission_user_edit, permission_user_view
|
||||
)
|
||||
|
||||
from .mixins import (
|
||||
GroupTestMixin, GroupViewTestMixin, UserTestMixin, UserViewTestMixin
|
||||
)
|
||||
from .mixins import GroupTestMixin, GroupViewTestMixin, UserViewTestMixin
|
||||
|
||||
|
||||
class GroupViewsTestCase(GroupTestMixin, GroupViewTestMixin, UserTestMixin, GenericViewTestCase):
|
||||
class GroupViewsTestCase(
|
||||
GroupTestMixin, GroupViewTestMixin, GenericViewTestCase
|
||||
):
|
||||
def test_group_create_view_no_permission(self):
|
||||
group_count = Group.objects.count()
|
||||
|
||||
@@ -158,13 +158,15 @@ class GroupViewsTestCase(GroupTestMixin, GroupViewTestMixin, UserTestMixin, Gene
|
||||
)
|
||||
|
||||
|
||||
class SuperUserViewTestCase(UserTestMixin, UserViewTestMixin, GenericViewTestCase):
|
||||
class SuperUserViewTestCase(UserViewTestMixin, GenericViewTestCase):
|
||||
def setUp(self):
|
||||
super(SuperUserViewTestCase, self).setUp()
|
||||
self._create_test_superuser()
|
||||
|
||||
def test_superuser_delete_view_with_access(self):
|
||||
superuser_count = get_user_model().objects.filter(is_superuser=True).count()
|
||||
superuser_count = get_user_model().objects.filter(
|
||||
is_superuser=True
|
||||
).count()
|
||||
self.grant_access(
|
||||
obj=self.test_superuser, permission=permission_user_delete
|
||||
)
|
||||
@@ -199,7 +201,7 @@ class SuperUserViewTestCase(UserTestMixin, UserViewTestMixin, GenericViewTestCas
|
||||
self.assertEqual(response.status_code, 404)
|
||||
|
||||
|
||||
class UserViewTestCase(UserTestMixin, UserViewTestMixin, GenericViewTestCase):
|
||||
class UserViewTestCase(UserViewTestMixin, GenericViewTestCase):
|
||||
def test_user_create_view_no_permission(self):
|
||||
user_count = get_user_model().objects.count()
|
||||
|
||||
@@ -263,7 +265,9 @@ class UserViewTestCase(UserTestMixin, UserViewTestMixin, GenericViewTestCase):
|
||||
self.assertEqual(get_user_model().objects.count(), user_count - 1)
|
||||
|
||||
|
||||
class UserGroupViewTestCase(GroupTestMixin, UserTestMixin, UserViewTestMixin, GenericViewTestCase):
|
||||
class UserGroupViewTestCase(
|
||||
GroupTestMixin, UserViewTestMixin, GenericViewTestCase
|
||||
):
|
||||
def test_user_groups_view_no_permission(self):
|
||||
self._create_test_user()
|
||||
self._create_test_group()
|
||||
@@ -334,7 +338,8 @@ class MetadataLookupIntegrationTestCase(
|
||||
metadata_type=self.test_metadata_type
|
||||
)
|
||||
self.grant_access(
|
||||
obj=self.test_document, permission=permission_document_metadata_edit
|
||||
obj=self.test_document,
|
||||
permission=permission_document_metadata_edit
|
||||
)
|
||||
|
||||
response = self.get(
|
||||
@@ -355,7 +360,8 @@ class MetadataLookupIntegrationTestCase(
|
||||
metadata_type=self.test_metadata_type
|
||||
)
|
||||
self.grant_access(
|
||||
obj=self.test_document, permission=permission_document_metadata_edit
|
||||
obj=self.test_document,
|
||||
permission=permission_document_metadata_edit
|
||||
)
|
||||
|
||||
response = self.get(
|
||||
|
||||
Reference in New Issue
Block a user