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:
Roberto Rosario
2019-01-03 14:49:48 -04:00
parent c6aab93f98
commit 65ccbd3b7b
9 changed files with 268 additions and 232 deletions
+2 -2
View File
@@ -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'
+23
View File
@@ -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)