Unify tests that use upload documents. Add explicit mode when opening a file.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2018-09-06 03:38:17 -04:00
parent 388b61ca7a
commit 4eab4670be
33 changed files with 245 additions and 423 deletions

View File

@@ -4,10 +4,7 @@ from django.test import override_settings
from rest_framework import status
from documents.models import DocumentType
from documents.tests.literals import (
TEST_DOCUMENT_TYPE_LABEL, TEST_SMALL_DOCUMENT_PATH
)
from documents.tests import DocumentTestMixin
from rest_api.tests import BaseAPITestCase
from ..models import Comment
@@ -20,23 +17,10 @@ from .literals import TEST_COMMENT_TEXT
@override_settings(OCR_AUTO_OCR=False)
class CommentAPITestCase(BaseAPITestCase):
class CommentAPITestCase(DocumentTestMixin, BaseAPITestCase):
def setUp(self):
super(CommentAPITestCase, self).setUp()
self.login_user()
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):
if hasattr(self, 'document_type'):
self.document_type.delete()
super(CommentAPITestCase, self).tearDown()
def _create_comment(self):
return self.document.comments.create(