Merge branch 'feature/testing' into development
This commit is contained in:
@@ -1,23 +1,85 @@
|
||||
"""
|
||||
This file demonstrates two different styles of tests (one doctest and one
|
||||
unittest). These will both pass when you run "manage.py test".
|
||||
import os
|
||||
|
||||
Replace these with more appropriate tests for your application.
|
||||
"""
|
||||
from django.utils import unittest
|
||||
from django.test.client import Client
|
||||
from django.conf import settings
|
||||
from django.core.files.base import File
|
||||
|
||||
from django.test import TestCase
|
||||
from django_gpg.api import SIGNATURE_STATE_VALID
|
||||
|
||||
class SimpleTest(TestCase):
|
||||
def test_basic_addition(self):
|
||||
"""
|
||||
Tests that 1 + 1 always equals 2.
|
||||
"""
|
||||
self.failUnlessEqual(1 + 1, 2)
|
||||
from .models import Document, DocumentType
|
||||
from .literals import VERSION_UPDATE_MAJOR, RELEASE_LEVEL_FINAL
|
||||
|
||||
__test__ = {"doctest": """
|
||||
Another way to test that 1 + 1 is equal to 2.
|
||||
|
||||
>>> 1 + 1 == 2
|
||||
True
|
||||
"""}
|
||||
class DocumentTestCase(unittest.TestCase):
|
||||
def setUp(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()
|
||||
#return File(file(self.filepath, 'rb'), name=self.filename)
|
||||
|
||||
file_object = open(os.path.join(settings.PROJECT_ROOT, 'contrib', 'mayan_11_1.pdf'))
|
||||
new_version = self.document.new_version(file=File(file_object, name='mayan_11_1.pdf'))
|
||||
file_object.close()
|
||||
|
||||
def runTest(self):
|
||||
self.failUnlessEqual(self.document_type.name, 'test doc type')
|
||||
|
||||
self.failUnlessEqual(self.document.exists(), True)
|
||||
self.failUnlessEqual(self.document.size, 272213)
|
||||
|
||||
self.failUnlessEqual(self.document.file_mimetype, 'application/pdf')
|
||||
self.failUnlessEqual(self.document.file_mime_encoding, 'binary')
|
||||
self.failUnlessEqual(self.document.file_filename, 'mayan_11_1.pdf')
|
||||
self.failUnlessEqual(self.document.checksum, 'c637ffab6b8bb026ed3784afdb07663fddc60099853fae2be93890852a69ecf3')
|
||||
self.failUnlessEqual(self.document.page_count, 47)
|
||||
|
||||
self.failUnlessEqual(self.document.latest_version.get_formated_version(), '1.0')
|
||||
self.failUnlessEqual(self.document.has_detached_signature(), False)
|
||||
|
||||
file_object = open(os.path.join(settings.PROJECT_ROOT, 'contrib', 'mayan_11_1.pdf.gpg'))
|
||||
new_version_data = {
|
||||
'comment': 'test comment 1',
|
||||
'version_update': VERSION_UPDATE_MAJOR,
|
||||
'release_level': RELEASE_LEVEL_FINAL,
|
||||
'serial': 0,
|
||||
}
|
||||
|
||||
new_version = self.document.new_version(file=File(file_object, name='mayan_11_1.pdf.gpg'), **new_version_data)
|
||||
file_object.close()
|
||||
|
||||
self.failUnlessEqual(self.document.latest_version.get_formated_version(), '2.0')
|
||||
self.failUnlessEqual(self.document.has_detached_signature(), False)
|
||||
|
||||
self.failUnlessEqual(self.document.verify_signature().status, SIGNATURE_STATE_VALID)
|
||||
|
||||
new_version_data = {
|
||||
'comment': 'test comment 2',
|
||||
'version_update': VERSION_UPDATE_MAJOR,
|
||||
'release_level': RELEASE_LEVEL_FINAL,
|
||||
'serial': 0,
|
||||
}
|
||||
file_object = open(os.path.join(settings.PROJECT_ROOT, 'contrib', 'mayan_11_1.pdf'))
|
||||
new_version = self.document.new_version(file=File(file_object), **new_version_data)
|
||||
file_object.close()
|
||||
|
||||
self.failUnlessEqual(self.document.latest_version.get_formated_version(), '3.0')
|
||||
|
||||
#GPGVerificationError
|
||||
self.failUnlessEqual(self.document.verify_signature(), None)
|
||||
|
||||
file_object = open(os.path.join(settings.PROJECT_ROOT, 'contrib', 'mayan_11_1.pdf.sig'), 'rb')
|
||||
new_version = self.document.add_detached_signature(File(file_object))
|
||||
file_object.close()
|
||||
|
||||
self.failUnlessEqual(self.document.has_detached_signature(), True)
|
||||
self.failUnlessEqual(self.document.verify_signature().status, SIGNATURE_STATE_VALID)
|
||||
|
||||
|
||||
def tearDown(self):
|
||||
self.document.delete()
|
||||
|
||||
@@ -96,7 +96,7 @@ def do_document_ocr(queue_document):
|
||||
# Fall back to doing visual OCR
|
||||
ocr_transformations, warnings = queue_document.get_transformation_list()
|
||||
|
||||
document_filepath = document_page.document.get_image_cache_name(page=document_page.page_number)
|
||||
document_filepath = document_page.document.get_image_cache_name(page=document_page.page_number, version=document_page.document_version.pk)
|
||||
unpaper_output_filename = u'%s_unpaper_out_page_%s%s%s' % (document_page.document.uuid, document_page.page_number, os.extsep, UNPAPER_FILE_FORMAT)
|
||||
unpaper_output_filepath = os.path.join(TEMPORARY_DIRECTORY, unpaper_output_filename)
|
||||
|
||||
|
||||
@@ -1,23 +1,15 @@
|
||||
"""
|
||||
This file demonstrates two different styles of tests (one doctest and one
|
||||
unittest). These will both pass when you run "manage.py test".
|
||||
from django.utils import unittest
|
||||
|
||||
Replace these with more appropriate tests for your application.
|
||||
"""
|
||||
from .models import Tag, TagProperties, COLOR_RED
|
||||
|
||||
from django.test import TestCase
|
||||
|
||||
class SimpleTest(TestCase):
|
||||
def test_basic_addition(self):
|
||||
"""
|
||||
Tests that 1 + 1 always equals 2.
|
||||
"""
|
||||
self.failUnlessEqual(1 + 1, 2)
|
||||
|
||||
__test__ = {"doctest": """
|
||||
Another way to test that 1 + 1 is equal to 2.
|
||||
|
||||
>>> 1 + 1 == 2
|
||||
True
|
||||
"""}
|
||||
class TagTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tag = Tag(name='test')
|
||||
self.tag.save()
|
||||
self.tp = TagProperties(tag=self.tag, color=COLOR_RED)
|
||||
self.tp.save()
|
||||
|
||||
def runTest(self):
|
||||
self.failUnlessEqual(self.tag.name, 'test')
|
||||
self.failUnlessEqual(self.tp.get_color_code(), 'red')
|
||||
|
||||
BIN
contrib/mayan_11_1.pdf
Normal file
BIN
contrib/mayan_11_1.pdf
Normal file
Binary file not shown.
BIN
contrib/mayan_11_1.pdf.gpg
Normal file
BIN
contrib/mayan_11_1.pdf.gpg
Normal file
Binary file not shown.
BIN
contrib/mayan_11_1.pdf.sig
Normal file
BIN
contrib/mayan_11_1.pdf.sig
Normal file
Binary file not shown.
Reference in New Issue
Block a user