diff --git a/mayan/apps/documents/tests/mixins.py b/mayan/apps/documents/tests/mixins.py index 220453529a..1fcf9c744d 100644 --- a/mayan/apps/documents/tests/mixins.py +++ b/mayan/apps/documents/tests/mixins.py @@ -4,6 +4,8 @@ import os from django.conf import settings +from mayan.apps.converter.classes import Layer + from ..literals import PAGE_RANGE_ALL from ..models import DocumentType @@ -30,6 +32,30 @@ class DocumentTestMixin(object): ) self.test_document_type = self.test_document_type + def _calculate_test_document_path(self): + if not self.test_document_path: + self.test_document_path = os.path.join( + settings.BASE_DIR, 'apps', 'documents', 'tests', 'contrib', + 'sample_documents', self.test_document_filename + ) + + def setUp(self): + super(DocumentTestMixin, self).setUp() + Layer.invalidate_cache() + + self.test_documents = [] + + if self.auto_create_document_type: + self._create_document_type() + + if self.auto_upload_document: + self.upload_document() + + def tearDown(self): + for document_type in DocumentType.objects.all(): + document_type.delete() + super(DocumentTestMixin, self).tearDown() + def upload_document(self, label=None): self._calculate_test_document_path() @@ -44,28 +70,6 @@ class DocumentTestMixin(object): self.test_document = document self.test_documents.append(document) - def _calculate_test_document_path(self): - if not self.test_document_path: - self.test_document_path = os.path.join( - settings.BASE_DIR, 'apps', 'documents', 'tests', 'contrib', - 'sample_documents', self.test_document_filename - ) - - def setUp(self): - super(DocumentTestMixin, self).setUp() - self.test_documents = [] - - if self.auto_create_document_type: - self._create_document_type() - - if self.auto_upload_document: - self.upload_document() - - def tearDown(self): - for document_type in DocumentType.objects.all(): - document_type.delete() - super(DocumentTestMixin, self).tearDown() - class DocumentTypeViewTestMixin(object): def _request_test_document_type_create_view(self): diff --git a/mayan/apps/documents/tests/test_api.py b/mayan/apps/documents/tests/test_api.py index 217907c19b..1f610d2fc5 100644 --- a/mayan/apps/documents/tests/test_api.py +++ b/mayan/apps/documents/tests/test_api.py @@ -30,7 +30,7 @@ from .literals import ( from .mixins import DocumentTestMixin -class DocumentTypeAPITestCase(LayerTestMixin, DocumentTestMixin, BaseAPITestCase): +class DocumentTypeAPITestCase(DocumentTestMixin, BaseAPITestCase): auto_upload_document = False auto_create_document_type = False diff --git a/mayan/apps/documents/tests/test_document_views.py b/mayan/apps/documents/tests/test_document_views.py index 367b2e0728..381a71211d 100644 --- a/mayan/apps/documents/tests/test_document_views.py +++ b/mayan/apps/documents/tests/test_document_views.py @@ -25,6 +25,13 @@ from .mixins import DocumentViewTestMixin class DocumentsViewsTestCase( LayerTestMixin, DocumentViewTestMixin, GenericDocumentViewTestCase ): + def _create_document_transformation(self): + layer_saved_transformations.add_transformation_to( + obj=self.test_document.pages.first(), + transformation_class=TEST_TRANSFORMATION_CLASS, + arguments=TEST_TRANSFORMATION_ARGUMENT + ) + def test_document_view_no_permissions(self): response = self._request_document_properties_view() self.assertEqual(response.status_code, 404) @@ -329,13 +336,6 @@ class DocumentsViewsTestCase( self.assertEqual(self.test_document.pages.count(), page_count) - def _create_document_transformation(self): - layer_saved_transformations.add_transformation_to( - obj=self.test_document.pages.first(), - transformation_class=TEST_TRANSFORMATION_CLASS, - arguments=TEST_TRANSFORMATION_ARGUMENT - ) - def test_document_clear_transformations_view_no_permission(self): self._create_document_transformation()