Unify and improve linking app tests for Python 3.
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -6,6 +6,7 @@ from rest_framework import status
|
||||
|
||||
from documents.models import DocumentType
|
||||
from documents.permissions import permission_document_view
|
||||
from documents.tests import DocumentTestMixin
|
||||
from documents.tests.literals import (
|
||||
TEST_DOCUMENT_TYPE_LABEL, TEST_SMALL_DOCUMENT_PATH
|
||||
)
|
||||
@@ -27,27 +28,14 @@ from .literals import (
|
||||
|
||||
|
||||
@override_settings(OCR_AUTO_OCR=False)
|
||||
class SmartLinkAPITestCase(BaseAPITestCase):
|
||||
class SmartLinkAPITestCase(DocumentTestMixin, BaseAPITestCase):
|
||||
auto_create_document_type = False
|
||||
auto_upload_document = False
|
||||
|
||||
def setUp(self):
|
||||
super(SmartLinkAPITestCase, self).setUp()
|
||||
self.login_user()
|
||||
|
||||
def tearDown(self):
|
||||
if hasattr(self, 'document_type'):
|
||||
self.document_type.delete()
|
||||
super(SmartLinkAPITestCase, self).tearDown()
|
||||
|
||||
def _create_document_type(self):
|
||||
self.document_type = DocumentType.objects.create(
|
||||
label=TEST_DOCUMENT_TYPE_LABEL
|
||||
)
|
||||
|
||||
def _create_document(self):
|
||||
with open(TEST_SMALL_DOCUMENT_PATH) as file_object:
|
||||
self.document = self.document_type.new_document(
|
||||
file_object=file_object
|
||||
)
|
||||
|
||||
def _create_smart_link(self):
|
||||
return SmartLink.objects.create(
|
||||
label=TEST_SMART_LINK_LABEL,
|
||||
@@ -219,7 +207,7 @@ class SmartLinkConditionAPITestCase(BaseAPITestCase):
|
||||
)
|
||||
|
||||
def _create_document(self):
|
||||
with open(TEST_SMALL_DOCUMENT_PATH) as file_object:
|
||||
with open(TEST_SMALL_DOCUMENT_PATH, 'rb') as file_object:
|
||||
self.document = self.document_type.new_document(
|
||||
file_object=file_object
|
||||
)
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.test import override_settings
|
||||
|
||||
from common.tests import BaseTestCase
|
||||
from documents.models import DocumentType
|
||||
from documents.tests import TEST_SMALL_DOCUMENT_PATH, TEST_DOCUMENT_TYPE_LABEL
|
||||
from documents.tests import GenericDocumentTestCase
|
||||
|
||||
from ..models import SmartLink
|
||||
|
||||
@@ -14,22 +10,7 @@ from .literals import TEST_SMART_LINK_LABEL, TEST_SMART_LINK_DYNAMIC_LABEL
|
||||
|
||||
|
||||
@override_settings(OCR_AUTO_OCR=False)
|
||||
class SmartLinkTestCase(BaseTestCase):
|
||||
def setUp(self):
|
||||
super(SmartLinkTestCase, self).setUp()
|
||||
self.document_type = DocumentType.objects.create(
|
||||
label=TEST_DOCUMENT_TYPE_LABEL
|
||||
)
|
||||
|
||||
with open(TEST_SMALL_DOCUMENT_PATH) as file_object:
|
||||
self.document = self.document_type.new_document(
|
||||
file_object=file_object
|
||||
)
|
||||
|
||||
def tearDown(self):
|
||||
self.document_type.delete()
|
||||
super(SmartLinkTestCase, self).tearDown()
|
||||
|
||||
class SmartLinkTestCase(GenericDocumentTestCase):
|
||||
def test_dynamic_label(self):
|
||||
smart_link = SmartLink.objects.create(
|
||||
label=TEST_SMART_LINK_LABEL,
|
||||
|
||||
Reference in New Issue
Block a user