Fix remaining tests

Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
This commit is contained in:
Roberto Rosario
2019-08-20 16:42:31 -04:00
parent e7734def58
commit 6503d9474d
3 changed files with 34 additions and 30 deletions

View File

@@ -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):

View File

@@ -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

View File

@@ -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()