Improve linking app tests

Signed-off-by: Roberto Rosario <roberto.rosario@mayan-edms.com>
This commit is contained in:
Roberto Rosario
2019-10-01 00:54:10 -04:00
parent 390e552c1f
commit 15c953815e
5 changed files with 300 additions and 263 deletions

View File

@@ -73,5 +73,3 @@ class TarGzArchiveClassTestCase(TarArchiveClassTestCase):
class TarBz2ArchiveClassTestCase(TarArchiveClassTestCase):
archive_path = TEST_TAR_BZ2_FILE_PATH
cls = TarArchive

View File

@@ -3,6 +3,7 @@ from __future__ import unicode_literals
from django import forms
from django.urls import reverse
from django.utils.html import format_html_join, mark_safe
from django.utils.translation import ugettext_lazy as _
def widget_transition_events(transition):

View File

@@ -10,6 +10,14 @@ from .literals import (
)
class SmartLinkDocumentViewTestMixin(object):
def _request_test_smart_link_document_instances_view(self):
return self.get(
viewname='linking:smart_link_instances_for_document',
kwargs={'pk': self.test_document.pk}
)
class SmartLinkTestMixin(object):
def _create_test_smart_link(self, add_test_document_type=False):
self.test_smart_link = SmartLink.objects.create(

File diff suppressed because it is too large Load Diff

View File

@@ -14,10 +14,15 @@ from .literals import (
TEST_SMART_LINK_DYNAMIC_LABEL, TEST_SMART_LINK_LABEL_EDITED,
TEST_SMART_LINK_LABEL
)
from .mixins import SmartLinkTestMixin, SmartLinkViewTestMixin
from .mixins import (
SmartLinkDocumentViewTestMixin, SmartLinkTestMixin,
SmartLinkViewTestMixin
)
class SmartLinkViewTestCase(SmartLinkTestMixin, SmartLinkViewTestMixin, GenericViewTestCase):
class SmartLinkViewTestCase(
SmartLinkTestMixin, SmartLinkViewTestMixin, GenericViewTestCase
):
def test_smart_link_create_view_no_permission(self):
response = self._request_test_smart_link_create_view()
self.assertEqual(response.status_code, 403)
@@ -74,10 +79,15 @@ class SmartLinkViewTestCase(SmartLinkTestMixin, SmartLinkViewTestMixin, GenericV
self.assertEqual(response.status_code, 302)
self.test_smart_link.refresh_from_db()
self.assertEqual(self.test_smart_link.label, TEST_SMART_LINK_LABEL_EDITED)
self.assertEqual(
self.test_smart_link.label, TEST_SMART_LINK_LABEL_EDITED
)
class SmartLinkDocumentViewTestCase(SmartLinkTestMixin, GenericDocumentViewTestCase):
class SmartLinkDocumentViewTestCase(
SmartLinkTestMixin, SmartLinkDocumentViewTestMixin,
GenericDocumentViewTestCase
):
def setUp(self):
super(SmartLinkDocumentViewTestCase, self).setUp()
self._create_test_smart_link()
@@ -89,12 +99,6 @@ class SmartLinkDocumentViewTestCase(SmartLinkTestMixin, GenericDocumentViewTestC
)
self.test_smart_link_2.document_types.add(self.test_document_type)
def _request_test_smart_link_document_instances_view(self):
return self.get(
viewname='linking:smart_link_instances_for_document',
kwargs={'pk': self.test_document.pk}
)
def test_document_smart_link_list_view_no_permission(self):
self.grant_access(
obj=self.test_document, permission=permission_document_view