Code style improvement. Test code consolidation. PEP8 cleanups.
Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
@@ -5,19 +5,18 @@ from django.urls import reverse
|
||||
|
||||
from rest_framework import status
|
||||
|
||||
from documents.models import DocumentType
|
||||
from documents.search import document_search
|
||||
from documents.permissions import permission_document_view
|
||||
from documents.tests import (
|
||||
TEST_DOCUMENT_TYPE_LABEL, TEST_SMALL_DOCUMENT_PATH
|
||||
)
|
||||
from documents.tests import DocumentTestMixin
|
||||
from rest_api.tests import BaseAPITestCase
|
||||
|
||||
from ..classes import SearchModel
|
||||
|
||||
|
||||
@override_settings(OCR_AUTO_OCR=False)
|
||||
class SearchAPITestCase(BaseAPITestCase):
|
||||
class SearchAPITestCase(DocumentTestMixin, BaseAPITestCase):
|
||||
auto_upload_document = False
|
||||
|
||||
def setUp(self):
|
||||
super(SearchAPITestCase, self).setUp()
|
||||
self.login_user()
|
||||
@@ -33,24 +32,14 @@ class SearchAPITestCase(BaseAPITestCase):
|
||||
)
|
||||
)
|
||||
|
||||
def _create_document(self):
|
||||
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 test_search_no_access(self):
|
||||
self._create_document()
|
||||
self.document = self.upload_document()
|
||||
response = self._request_search_view()
|
||||
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||
self.assertEqual(response.data['count'], 0)
|
||||
|
||||
def test_search_with_access(self):
|
||||
self._create_document()
|
||||
self.document = self.upload_document()
|
||||
self.grant_access(
|
||||
permission=permission_document_view, obj=self.document
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user