Add initial organization view tests for the documents app.
This commit is contained in:
@@ -21,10 +21,13 @@ __all__ = (
|
||||
# Filenames
|
||||
TEST_COMPRESSED_DOCUMENTS_FILENAME = 'compressed_documents.zip'
|
||||
TEST_DEU_DOCUMENT_FILENAME = 'deu_website.png'
|
||||
|
||||
TEST_DOCUMENT_DESCRIPTION = 'test description'
|
||||
TEST_DOCUMENT_FILENAME = 'mayan_11_1.pdf'
|
||||
TEST_DOCUMENT_TYPE = 'test_document_type'
|
||||
TEST_DOCUMENT_TYPE_2 = 'test document type 2'
|
||||
TEST_DOCUMENT_TYPE_EDITED_LABEL = 'test document type edited label'
|
||||
TEST_DOCUMENT_TYPE_2_LABEL = 'test document type 2 label'
|
||||
TEST_HYBRID_DOCUMENT = 'hybrid_text_and_image.pdf'
|
||||
TEST_MULTI_PAGE_TIFF = 'multi_page.tiff'
|
||||
TEST_NON_ASCII_COMPRESSED_DOCUMENT_FILENAME = 'I18N_title_áéíóúüñÑ.png.zip'
|
||||
@@ -70,3 +73,5 @@ TEST_SMALL_DOCUMENT_PATH = os.path.join(
|
||||
settings.BASE_DIR, 'contrib', 'sample_documents',
|
||||
TEST_SMALL_DOCUMENT_FILENAME
|
||||
)
|
||||
TEST_TRANSFORMATION_NAME = 'rotate'
|
||||
TEST_TRANSFORMATION_ARGUMENT = 'degrees: 180'
|
||||
|
||||
62
mayan/apps/documents/tests/test_organization_views.py
Normal file
62
mayan/apps/documents/tests/test_organization_views.py
Normal file
@@ -0,0 +1,62 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from organizations.tests.test_organization_views import OrganizationViewTestCase
|
||||
|
||||
from ..models import Document,DocumentType
|
||||
|
||||
from .literals import (
|
||||
TEST_DOCUMENT_TYPE, TEST_DOCUMENT_TYPE_2_LABEL,
|
||||
TEST_DOCUMENT_TYPE_QUICK_LABEL, TEST_SMALL_DOCUMENT_CHECKSUM,
|
||||
TEST_SMALL_DOCUMENT_PATH
|
||||
)
|
||||
|
||||
|
||||
class DocumentOrganizationViewTestCase(OrganizationViewTestCase):
|
||||
def setUp(self):
|
||||
super(DocumentOrganizationViewTestCase, self).setUp()
|
||||
|
||||
# Create a document for organization A
|
||||
with self.settings(ORGANIZATION_ID=self.organization_a.pk):
|
||||
self.document_type = DocumentType.on_organization.create(
|
||||
label=TEST_DOCUMENT_TYPE
|
||||
)
|
||||
|
||||
with open(TEST_SMALL_DOCUMENT_PATH) as file_object:
|
||||
self.document = self.document_type.new_document(
|
||||
file_object=file_object
|
||||
)
|
||||
|
||||
def tearDown(self):
|
||||
super(DocumentOrganizationViewTestCase, self).tearDown()
|
||||
if self.document_type.pk:
|
||||
self.document_type.delete()
|
||||
|
||||
def test_document_delete_view(self):
|
||||
with self.settings(ORGANIZATION_ID=self.organization_b.pk):
|
||||
response = self.post(
|
||||
'documents:document_delete', args=(self.document.pk,)
|
||||
)
|
||||
self.assertEqual(response.status_code, 404)
|
||||
|
||||
def test_document_view_view(self):
|
||||
with self.settings(ORGANIZATION_ID=self.organization_b.pk):
|
||||
# Make sure admin for organization B cannot find the document for
|
||||
# organization A
|
||||
response = self.get(
|
||||
'documents:document_properties', args=(self.document.pk,),
|
||||
)
|
||||
self.assertEqual(response.status_code, 404)
|
||||
|
||||
def test_document_document_type_change_view(self):
|
||||
with self.settings(ORGANIZATION_ID=self.organization_b.pk):
|
||||
document_type = DocumentType.objects.create(
|
||||
label=TEST_DOCUMENT_TYPE_2_LABEL
|
||||
)
|
||||
|
||||
response = self.post(
|
||||
'documents:document_document_type_edit',
|
||||
args=(self.document.pk,),
|
||||
data={'document_type': document_type.pk}
|
||||
)
|
||||
|
||||
self.assertEqual(response.status_code, 403)
|
||||
@@ -28,17 +28,13 @@ from ..permissions import (
|
||||
)
|
||||
|
||||
from .literals import (
|
||||
TEST_DOCUMENT_TYPE, TEST_DOCUMENT_TYPE_QUICK_LABEL,
|
||||
TEST_SMALL_DOCUMENT_CHECKSUM, TEST_SMALL_DOCUMENT_PATH
|
||||
TEST_DOCUMENT_TYPE, TEST_DOCUMENT_TYPE_EDITED_LABEL,
|
||||
TEST_DOCUMENT_TYPE_2_LABEL, TEST_DOCUMENT_TYPE_QUICK_LABEL,
|
||||
TEST_SMALL_DOCUMENT_CHECKSUM, TEST_SMALL_DOCUMENT_PATH,
|
||||
TEST_TRANSFORMATION_ARGUMENT, TEST_TRANSFORMATION_NAME
|
||||
)
|
||||
|
||||
|
||||
TEST_DOCUMENT_TYPE_EDITED_LABEL = 'test document type edited label'
|
||||
TEST_DOCUMENT_TYPE_2_LABEL = 'test document type 2 label'
|
||||
TEST_TRANSFORMATION_NAME = 'rotate'
|
||||
TEST_TRANSFORMATION_ARGUMENT = 'degrees: 180'
|
||||
|
||||
|
||||
@override_settings(OCR_AUTO_OCR=False)
|
||||
class GenericDocumentViewTestCase(GenericViewTestCase):
|
||||
def setUp(self):
|
||||
|
||||
Reference in New Issue
Block a user