Update the acls, common and documents tests to use OrganizationTestCase class.
This commit is contained in:
@@ -7,7 +7,7 @@ from django.test import TestCase, override_settings
|
||||
from documents.models import Document, DocumentType
|
||||
from documents.permissions import permission_document_view
|
||||
from documents.tests import TEST_SMALL_DOCUMENT_PATH, TEST_DOCUMENT_TYPE
|
||||
from organizations.utils import create_default_organization
|
||||
from organizations.tests.base import OrganizationTestCase
|
||||
from permissions.classes import Permission
|
||||
from permissions.models import Role
|
||||
from permissions.tests.literals import TEST_ROLE_LABEL
|
||||
@@ -20,9 +20,9 @@ TEST_DOCUMENT_TYPE_2 = 'test document type 2'
|
||||
|
||||
|
||||
@override_settings(OCR_AUTO_OCR=False)
|
||||
class PermissionTestCase(TestCase):
|
||||
class PermissionTestCase(OrganizationTestCase):
|
||||
def setUp(self):
|
||||
create_default_organization()
|
||||
super(PermissionTestCase, self).setUp()
|
||||
|
||||
self.document_type_1 = DocumentType.on_organization.create(
|
||||
label=TEST_DOCUMENT_TYPE
|
||||
@@ -62,6 +62,8 @@ class PermissionTestCase(TestCase):
|
||||
for document_type in DocumentType.on_organization.all():
|
||||
document_type.delete()
|
||||
|
||||
super(PermissionTestCase, self).tearDown()
|
||||
|
||||
def test_check_access_without_permissions(self):
|
||||
with self.assertRaises(PermissionDenied):
|
||||
AccessControlList.objects.check_access(
|
||||
|
||||
@@ -7,8 +7,7 @@ from django.http import HttpResponse
|
||||
from django.template import Context, Template
|
||||
from django.test import TestCase
|
||||
|
||||
from organizations.models import Organization
|
||||
from organizations.utils import create_default_organization
|
||||
from organizations.tests.base import OrganizationTestCase
|
||||
from permissions import Permission
|
||||
from permissions.models import Role
|
||||
from permissions.tests.literals import TEST_ROLE_LABEL
|
||||
@@ -21,9 +20,9 @@ from user_management.tests import (
|
||||
from .literals import TEST_VIEW_NAME, TEST_VIEW_URL
|
||||
|
||||
|
||||
class GenericViewTestCase(TestCase):
|
||||
class GenericViewTestCase(OrganizationTestCase):
|
||||
def setUp(self):
|
||||
create_default_organization()
|
||||
super(GenericViewTestCase, self).setUp()
|
||||
self.has_test_view = False
|
||||
self.admin_user = get_user_model().on_organization.create_superuser(
|
||||
username=TEST_ADMIN_USERNAME, email=TEST_ADMIN_EMAIL,
|
||||
@@ -47,8 +46,8 @@ class GenericViewTestCase(TestCase):
|
||||
self.client.logout()
|
||||
if self.has_test_view:
|
||||
urlpatterns.pop(0)
|
||||
Organization.objects.all().delete()
|
||||
Organization.objects.clear_cache()
|
||||
|
||||
super(GenericViewTestCase, self).tearDown()
|
||||
|
||||
def add_test_view(self, test_object):
|
||||
from mayan.urls import urlpatterns
|
||||
|
||||
@@ -5,7 +5,7 @@ import time
|
||||
|
||||
from django.test import TestCase, override_settings
|
||||
|
||||
from organizations.utils import create_default_organization
|
||||
from organizations.tests.base import OrganizationTestCase
|
||||
|
||||
from ..exceptions import NewDocumentVersionNotAllowed
|
||||
from ..literals import STUB_EXPIRATION_INTERVAL
|
||||
@@ -18,9 +18,9 @@ from .literals import (
|
||||
|
||||
|
||||
@override_settings(OCR_AUTO_OCR=False)
|
||||
class DocumentTestCase(TestCase):
|
||||
class DocumentTestCase(OrganizationTestCase):
|
||||
def setUp(self):
|
||||
create_default_organization()
|
||||
super(DocumentTestCase, self).setUp()
|
||||
self.document_type = DocumentType.on_organization.create(
|
||||
label=TEST_DOCUMENT_TYPE
|
||||
)
|
||||
@@ -32,6 +32,7 @@ class DocumentTestCase(TestCase):
|
||||
|
||||
def tearDown(self):
|
||||
self.document_type.delete()
|
||||
super(DocumentTestCase, self).tearDown()
|
||||
|
||||
def test_document_creation(self):
|
||||
self.assertEqual(self.document_type.label, TEST_DOCUMENT_TYPE)
|
||||
@@ -138,9 +139,10 @@ class DocumentTestCase(TestCase):
|
||||
|
||||
|
||||
@override_settings(OCR_AUTO_OCR=False)
|
||||
class OfficeDocumentTestCase(TestCase):
|
||||
class OfficeDocumentTestCase(OrganizationTestCase):
|
||||
def setUp(self):
|
||||
create_default_organization()
|
||||
super(OfficeDocumentTestCase, self).setUp()
|
||||
|
||||
self.document_type = DocumentType.on_organization.create(
|
||||
label=TEST_DOCUMENT_TYPE
|
||||
)
|
||||
@@ -152,6 +154,7 @@ class OfficeDocumentTestCase(TestCase):
|
||||
|
||||
def tearDown(self):
|
||||
self.document_type.delete()
|
||||
super(OfficeDocumentTestCase, self).tearDown()
|
||||
|
||||
def test_document_creation(self):
|
||||
self.assertEqual(self.document.file_mimetype, 'application/msword')
|
||||
@@ -166,9 +169,10 @@ class OfficeDocumentTestCase(TestCase):
|
||||
|
||||
|
||||
@override_settings(OCR_AUTO_OCR=False)
|
||||
class MultiPageTiffTestCase(TestCase):
|
||||
class MultiPageTiffTestCase(OrganizationTestCase):
|
||||
def setUp(self):
|
||||
create_default_organization()
|
||||
super(MultiPageTiffTestCase, self).setUp()
|
||||
|
||||
self.document_type = DocumentType.on_organization.create(
|
||||
label=TEST_DOCUMENT_TYPE
|
||||
)
|
||||
@@ -180,6 +184,7 @@ class MultiPageTiffTestCase(TestCase):
|
||||
|
||||
def tearDown(self):
|
||||
self.document_type.delete()
|
||||
super(MultiPageTiffTestCase, self).tearDown()
|
||||
|
||||
def test_document_creation(self):
|
||||
self.assertEqual(self.document.file_mimetype, 'image/tiff')
|
||||
@@ -192,9 +197,10 @@ class MultiPageTiffTestCase(TestCase):
|
||||
|
||||
|
||||
@override_settings(OCR_AUTO_OCR=False)
|
||||
class DocumentVersionTestCase(TestCase):
|
||||
class DocumentVersionTestCase(OrganizationTestCase):
|
||||
def setUp(self):
|
||||
create_default_organization()
|
||||
super(DocumentVersionTestCase, self).setUp()
|
||||
|
||||
self.document_type = DocumentType.on_organization.create(
|
||||
label=TEST_DOCUMENT_TYPE
|
||||
)
|
||||
@@ -206,6 +212,7 @@ class DocumentVersionTestCase(TestCase):
|
||||
|
||||
def tearDown(self):
|
||||
self.document_type.delete()
|
||||
super(DocumentVersionTestCase, self).tearDown()
|
||||
|
||||
def test_add_new_version(self):
|
||||
self.assertEqual(self.document.versions.count(), 1)
|
||||
@@ -242,15 +249,16 @@ class DocumentVersionTestCase(TestCase):
|
||||
|
||||
|
||||
@override_settings(OCR_AUTO_OCR=False)
|
||||
class DocumentManagerTestCase(TestCase):
|
||||
class DocumentManagerTestCase(OrganizationTestCase):
|
||||
def setUp(self):
|
||||
create_default_organization()
|
||||
super(DocumentManagerTestCase, self).setUp()
|
||||
self.document_type = DocumentType.on_organization.create(
|
||||
label=TEST_DOCUMENT_TYPE
|
||||
)
|
||||
|
||||
def tearDown(self):
|
||||
self.document_type.delete()
|
||||
super(DocumentManagerTestCase, self).tearDown()
|
||||
|
||||
def test_document_stubs_deletion(self):
|
||||
document_stub = Document.on_organization.create(
|
||||
@@ -272,9 +280,9 @@ class DocumentManagerTestCase(TestCase):
|
||||
|
||||
|
||||
@override_settings(OCR_AUTO_OCR=False)
|
||||
class NewVersionBlockTestCase(TestCase):
|
||||
class NewVersionBlockTestCase(OrganizationTestCase):
|
||||
def setUp(self):
|
||||
create_default_organization()
|
||||
super(NewVersionBlockTestCase, self).setUp()
|
||||
self.document_type = DocumentType.on_organization.create(
|
||||
label=TEST_DOCUMENT_TYPE
|
||||
)
|
||||
@@ -287,6 +295,7 @@ class NewVersionBlockTestCase(TestCase):
|
||||
def tearDown(self):
|
||||
self.document.delete()
|
||||
self.document_type.delete()
|
||||
super(NewVersionBlockTestCase, self).tearDown()
|
||||
|
||||
def test_blocking(self):
|
||||
NewVersionBlock.objects.block(document=self.document)
|
||||
|
||||
Reference in New Issue
Block a user