Reorganize reusable test code
Extract test views and user code into their own separate test case mixins. Append TestCase to test case mixins with base test code to differentiate them from test mixins with reusable view calls. Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
TEST_ROLE_2_LABEL = 'test role 2'
|
||||
TEST_ROLE_LABEL = 'test role'
|
||||
TEST_CASE_ROLE_LABEL = 'test case role'
|
||||
TEST_ROLE_LABEL = 'test role 2'
|
||||
TEST_ROLE_LABEL_EDITED = 'test role label edited'
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from ..models import Role
|
||||
|
||||
from .literals import TEST_CASE_ROLE_LABEL, TEST_ROLE_LABEL
|
||||
|
||||
|
||||
class RoleTestCaseMixin(object):
|
||||
def setUp(self):
|
||||
super(RoleTestCaseMixin, self).setUp()
|
||||
if hasattr(self, '_test_case_group'):
|
||||
self.create_role()
|
||||
|
||||
def create_role(self):
|
||||
self._test_case_role = Role.objects.create(label=TEST_CASE_ROLE_LABEL)
|
||||
|
||||
def grant_permission(self, permission):
|
||||
self._test_case_role.grant(permission=permission)
|
||||
|
||||
|
||||
class RoleTestMixin(object):
|
||||
def _create_test_role(self):
|
||||
self.test_role = Role.objects.create(label=TEST_ROLE_LABEL)
|
||||
Reference in New Issue
Block a user