Add OCR test
This commit is contained in:
@@ -8,7 +8,7 @@ before_install:
|
||||
install:
|
||||
- "pip install -r requirements/testing.txt"
|
||||
script:
|
||||
- coverage run --source=documents,document_signatures,lock_manager,folders,tags manage.py test documents lock_manager document_signatures folders tags
|
||||
- coverage run --source=documents,document_signatures,lock_manager,folders,ocr,tags manage.py test documents lock_manager document_signatures folders ocr tags
|
||||
after_success:
|
||||
- coveralls
|
||||
branches:
|
||||
|
||||
BIN
contrib/sample_documents/title_page.png
Normal file
BIN
contrib/sample_documents/title_page.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
45
mayan/apps/ocr/tests.py
Normal file
45
mayan/apps/ocr/tests.py
Normal file
@@ -0,0 +1,45 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
import os
|
||||
import time
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.files.base import File
|
||||
from django.utils import unittest
|
||||
|
||||
from documents.models import Document, DocumentType
|
||||
|
||||
from .literals import (QUEUEDOCUMENT_STATE_PROCESSING,
|
||||
DOCUMENTQUEUE_STATE_STOPPED, DOCUMENTQUEUE_STATE_ACTIVE)
|
||||
from .models import DocumentQueue
|
||||
from .api import do_document_ocr
|
||||
|
||||
|
||||
class DocumentSearchTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
# Start the OCR queue
|
||||
self.default_queue = DocumentQueue.objects.get(name='default')
|
||||
|
||||
def test_do_document_ocr(self):
|
||||
self.document_type = DocumentType(name='test doc type')
|
||||
self.document_type.save()
|
||||
|
||||
self.document = Document(
|
||||
document_type=self.document_type,
|
||||
description='description',
|
||||
)
|
||||
self.document.save()
|
||||
|
||||
file_object = open(os.path.join(settings.SITE_ROOT, 'contrib', 'sample_documents', 'title_page.png'))
|
||||
new_version = self.document.new_version(file=File(file_object, name='title_page.png'))
|
||||
file_object.close()
|
||||
|
||||
self.failUnlessEqual(self.default_queue.queuedocument_set.count(), 1)
|
||||
|
||||
do_document_ocr(self.default_queue.queuedocument_set.all()[0])
|
||||
|
||||
self.assertTrue(u'Mayan EDMS' in self.document.pages.all()[0].content)
|
||||
|
||||
def tearDown(self):
|
||||
self.document.delete()
|
||||
self.document_type.delete()
|
||||
Reference in New Issue
Block a user