Documents now have their own dedicated DocumentPage submodel. The old DocumentPage is now called DocumentVersionPage. This allows mappings between document pages and document version pages, allowing renumbering, appending pages. DocumentPages have a content_object to map them to any other object. For now they only map to DocumentVersionPages. New option added to the version upload form to append the pages of the new version. A new view was added to just append new pages with wraps the new document version upload form and hides the append pages checkbox set to True. Add a new action, reset_pages to reset the pages of the document to those of the latest version. Missing: appending tests, checks for proper content_object in OCR and document parsing. Author: Roberto Rosario <roberto.rosario@mayan-edms.com> Date: Thu Oct 11 12:00:25 2019 -0400
51 lines
1.7 KiB
Python
51 lines
1.7 KiB
Python
from __future__ import unicode_literals
|
|
|
|
from django.test import override_settings
|
|
|
|
from mayan.apps.common.tests.base import BaseTestCase
|
|
from mayan.apps.documents.tests.mixins import DocumentTestMixin
|
|
from mayan.apps.documents.tests.literals import TEST_DEU_DOCUMENT_PATH
|
|
|
|
from .literals import (
|
|
TEST_DOCUMENT_CONTENT, TEST_DOCUMENT_CONTENT_DEU_1,
|
|
TEST_DOCUMENT_CONTENT_DEU_2
|
|
)
|
|
|
|
|
|
@override_settings(OCR_AUTO_OCR=True)
|
|
class DocumentOCRTestCase(DocumentTestMixin, BaseTestCase):
|
|
# PyOCR's leak descriptor in get_available_languages and image_to_string
|
|
# Disable descriptor leak test until fixed in upstream
|
|
_skip_file_descriptor_test = True
|
|
|
|
def test_ocr_language_backends_end(self):
|
|
content = self.test_document.pages.first().content_object.ocr_content.content
|
|
self.assertTrue(TEST_DOCUMENT_CONTENT in content)
|
|
|
|
|
|
@override_settings(OCR_AUTO_OCR=True)
|
|
class GermanOCRSupportTestCase(DocumentTestMixin, BaseTestCase):
|
|
# PyOCR's leak descriptor in get_available_languages and image_to_string
|
|
# Disable descriptor leak test until fixed in upstream
|
|
_skip_file_descriptor_test = True
|
|
|
|
auto_upload_document = False
|
|
|
|
def setUp(self):
|
|
super(GermanOCRSupportTestCase, self).setUp()
|
|
|
|
with open(TEST_DEU_DOCUMENT_PATH, mode='rb') as file_object:
|
|
self.test_document = self.test_document_type.new_document(
|
|
file_object=file_object, language='deu'
|
|
)
|
|
|
|
def test_ocr_language_backends_end(self):
|
|
content = self.test_document.pages.first().content_object.ocr_content.content
|
|
|
|
self.assertTrue(
|
|
TEST_DOCUMENT_CONTENT_DEU_1 in content
|
|
)
|
|
self.assertTrue(
|
|
TEST_DOCUMENT_CONTENT_DEU_2 in content
|
|
)
|