Improve tag app test organization
Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from mayan.apps.documents.tests.literals import TEST_SMALL_DOCUMENT_PATH
|
||||
|
||||
from ..models import Tag
|
||||
|
||||
from .literals import (
|
||||
@@ -158,3 +160,17 @@ class TagViewTestMixin(object):
|
||||
'pk': self.test_document.pk
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
class TaggedDocumentUploadViewTestMixin(object):
|
||||
def _request_upload_interactive_document_create_view(self):
|
||||
with open(TEST_SMALL_DOCUMENT_PATH, mode='rb') as file_object:
|
||||
return self.post(
|
||||
viewname='sources:document_upload_interactive', kwargs={
|
||||
'source_id': self.test_source.pk
|
||||
}, data={
|
||||
'document_type_id': self.test_document_type.pk,
|
||||
'source-file': file_object,
|
||||
'tags': Tag.objects.values_list('pk', flat=True)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -115,7 +115,9 @@ class TagAPIViewTestCase(TagAPIViewTestMixin, TagTestMixin, BaseAPITestCase):
|
||||
self.assertNotEqual(self.test_tag.color, tag_color)
|
||||
|
||||
|
||||
class TagDocumentAPIViewTestCase(DocumentTestMixin, TagAPIViewTestMixin, TagTestMixin, BaseAPITestCase):
|
||||
class TagDocumentAPIViewTestCase(
|
||||
DocumentTestMixin, TagAPIViewTestMixin, TagTestMixin, BaseAPITestCase
|
||||
):
|
||||
auto_upload_document = False
|
||||
|
||||
def test_tag_document_list_view_no_access(self):
|
||||
|
||||
@@ -120,7 +120,9 @@ class TagViewTestCase(TagTestMixin, TagViewTestMixin, GenericViewTestCase):
|
||||
)
|
||||
|
||||
|
||||
class TagDocumentViewTestCase(TagTestMixin, TagViewTestMixin, GenericDocumentViewTestCase):
|
||||
class TagDocumentViewTestCase(
|
||||
TagTestMixin, TagViewTestMixin, GenericDocumentViewTestCase
|
||||
):
|
||||
def test_document_tags_list_no_permissions(self):
|
||||
self._create_test_tag()
|
||||
|
||||
|
||||
@@ -11,7 +11,9 @@ from ..permissions import permission_tag_view
|
||||
from .mixins import TagTestMixin
|
||||
|
||||
|
||||
class DocumentTagHTMLWidgetTestCase(DocumentViewTestMixin, TagTestMixin, GenericDocumentViewTestCase):
|
||||
class DocumentTagHTMLWidgetTestCase(
|
||||
DocumentViewTestMixin, TagTestMixin, GenericDocumentViewTestCase
|
||||
):
|
||||
def test_document_tags_widget_no_permissions(self):
|
||||
self._create_test_tag()
|
||||
|
||||
|
||||
@@ -3,39 +3,27 @@ from __future__ import unicode_literals
|
||||
from mayan.apps.documents.models import Document
|
||||
from mayan.apps.documents.permissions import permission_document_create
|
||||
from mayan.apps.documents.tests.base import GenericDocumentViewTestCase
|
||||
from mayan.apps.documents.tests.literals import TEST_SMALL_DOCUMENT_PATH
|
||||
from mayan.apps.sources.models import WebFormSource
|
||||
from mayan.apps.sources.tests.literals import (
|
||||
TEST_SOURCE_LABEL, TEST_SOURCE_UNCOMPRESS_N
|
||||
)
|
||||
|
||||
from ..models import Tag
|
||||
|
||||
from .mixins import TagTestMixin
|
||||
from .mixins import TagTestMixin, TaggedDocumentUploadViewTestMixin
|
||||
|
||||
|
||||
class TaggedDocumentUploadTestCase(TagTestMixin, GenericDocumentViewTestCase):
|
||||
class TaggedDocumentUploadViewTestCase(
|
||||
TaggedDocumentUploadViewTestMixin, TagTestMixin,
|
||||
GenericDocumentViewTestCase
|
||||
):
|
||||
auto_upload_document = False
|
||||
|
||||
def setUp(self):
|
||||
super(TaggedDocumentUploadTestCase, self).setUp()
|
||||
super(TaggedDocumentUploadViewTestCase, self).setUp()
|
||||
self.test_source = WebFormSource.objects.create(
|
||||
enabled=True, label=TEST_SOURCE_LABEL,
|
||||
uncompress=TEST_SOURCE_UNCOMPRESS_N
|
||||
)
|
||||
|
||||
def _request_upload_interactive_document_create_view(self):
|
||||
with open(TEST_SMALL_DOCUMENT_PATH, mode='rb') as file_object:
|
||||
return self.post(
|
||||
viewname='sources:document_upload_interactive', kwargs={
|
||||
'source_id': self.test_source.pk
|
||||
}, data={
|
||||
'document_type_id': self.test_document_type.pk,
|
||||
'source-file': file_object,
|
||||
'tags': Tag.objects.values_list('pk', flat=True)
|
||||
}
|
||||
)
|
||||
|
||||
def test_upload_interactive_view_with_access(self):
|
||||
self._create_test_tag()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user