Esempio n. 1
0
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()
Esempio n. 2
0
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()

        with open(TEST_DOCUMENT_PATH) as file_object:
            self.document.new_version(file=File(file_object, name='title_page.png'))

        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()
Esempio n. 3
0
class DocumentSearchTestCase(TestCase):
    def setUp(self):
        self.admin_user = User.objects.create_superuser(
            username=TEST_ADMIN_USERNAME,
            email=TEST_ADMIN_EMAIL,
            password=TEST_ADMIN_PASSWORD)

        self.document_type = DocumentType(name=TEST_DOCUMENT_TYPE)
        self.document_type.save()

        self.document = Document(document_type=self.document_type, )
        self.document.save()

        with open(TEST_DOCUMENT_PATH) as file_object:
            self.document.new_version(
                file_object=File(file_object, name='mayan_11_1.pdf'))

    def test_simple_search_after_related_name_change(self):
        """
        Test that simple search works after related_name changes to
        document versions and document version pages
        """

        model_list, result_set, elapsed_time = document_search.search(
            {'q': 'Mayan'}, user=self.admin_user)
        self.assertEqual(len(result_set), 1)
        self.assertEqual(model_list, [self.document])

    def test_advanced_search_after_related_name_change(self):
        # Test versions__filename
        model_list, result_set, elapsed_time = document_search.search(
            {'label': self.document.label}, user=self.admin_user)
        self.assertEqual(len(result_set), 1)
        self.assertEqual(model_list, [self.document])

        # Test versions__mimetype
        model_list, result_set, elapsed_time = document_search.search(
            {'versions__mimetype': self.document.file_mimetype},
            user=self.admin_user)
        self.assertEqual(len(result_set), 1)
        self.assertEqual(model_list, [self.document])

        # Test versions__pages__content
        # Search by the first 20 characters of the content of the first page of the uploaded document
        model_list, result_set, elapsed_time = document_search.search(
            {
                'versions__pages__content':
                self.document.latest_version.pages.all()[0].content[0:20]
            },
            user=self.admin_user)
        self.assertEqual(len(result_set), 1)
        self.assertEqual(model_list, [self.document])

    def tearDown(self):
        self.document.delete()
        self.document_type.delete()
Esempio n. 4
0
class DocumentTestCase(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()

        with open(TEST_DOCUMENT_PATH) as file_object:
            self.document.new_version(file=File(file_object, name='mayan_11_1.pdf'))

        with open(TEST_KEY_FILE) as file_object:
            gpg.import_key(file_object.read())

    def test_document_no_signature(self):
        self.failUnlessEqual(DocumentVersionSignature.objects.has_detached_signature(self.document), False)

    def test_new_document_version_signed(self):
        with open(TEST_SIGNED_DOCUMENT_PATH) as file_object:
            new_version_data = {
                'comment': 'test comment 1',
                'version_update': VERSION_UPDATE_MAJOR,
                'release_level': RELEASE_LEVEL_FINAL,
                'serial': 0,
            }

            self.document.new_version(file=File(file_object, name='mayan_11_1.pdf.gpg'), **new_version_data)

        self.failUnlessEqual(DocumentVersionSignature.objects.has_detached_signature(self.document), False)
        self.failUnlessEqual(DocumentVersionSignature.objects.verify_signature(self.document).status, SIGNATURE_STATE_VALID)

    def test_detached_signatures(self):
        new_version_data = {
            'comment': 'test comment 2',
            'version_update': VERSION_UPDATE_MAJOR,
            'release_level': RELEASE_LEVEL_FINAL,
            'serial': 0,
        }
        with open(TEST_DOCUMENT_PATH) as file_object:
            self.document.new_version(file=File(file_object), **new_version_data)

        # GPGVerificationError
        self.failUnlessEqual(DocumentVersionSignature.objects.verify_signature(self.document), None)

        with open(TEST_SIGNATURE_FILE_PATH, 'rb') as file_object:
            DocumentVersionSignature.objects.add_detached_signature(self.document, File(file_object))

        self.failUnlessEqual(DocumentVersionSignature.objects.has_detached_signature(self.document), True)
        self.failUnlessEqual(DocumentVersionSignature.objects.verify_signature(self.document).status, SIGNATURE_STATE_VALID)

    def tearDown(self):
        self.document.delete()
        self.document_type.delete()
Esempio n. 5
0
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()

        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 test_document_no_signature(self):
        self.failUnlessEqual(DocumentVersionSignature.objects.has_detached_signature(self.document), False)

    def test_new_document_version_signed(self):
        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,
        }

        self.failUnlessEqual(DocumentVersionSignature.objects.has_detached_signature(self.document), False)
        # self.failUnlessEqual(DocumentVersionSignature.objects.verify_signature(self.document).status, SIGNATURE_STATE_VALID)
        # TODO: verify_signature is failing, check

    def test_detached_signatures(self):
        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()

        # GPGVerificationError
        self.failUnlessEqual(DocumentVersionSignature.objects.verify_signature(self.document), None)

        file_object = open(os.path.join(settings.PROJECT_ROOT, 'contrib', 'mayan_11_1.pdf.sig'), 'rb')
        DocumentVersionSignature.objects.add_detached_signature(self.document, File(file_object))
        file_object.close()

        self.failUnlessEqual(DocumentVersionSignature.objects.has_detached_signature(self.document), True)
        # self.failUnlessEqual(DocumentVersionSignature.objects.verify_signature(self.document).status, SIGNATURE_STATE_VALID)
        # TODO: verify_signature is failing, check

    def tearDown(self):
        self.document.delete()
        self.document_type.delete()
Esempio n. 6
0
    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()

        with open(TEST_DOCUMENT_PATH) as file_object:
            self.document.new_version(file_object=File(file_object))
Esempio n. 7
0
class FolderTestCase(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()

        file_object = open(os.path.join(settings.SITE_ROOT, 'contrib', 'sample_documents', 'mayan_11_1.pdf'))
        new_version = self.document.new_version(file=File(file_object, name='mayan_11_1.pdf'))
        file_object.close()

    def test_creation_of_folder(self):
        user = User.objects.all()[0]
        folder = Folder.objects.create(title='test', user=user)

        self.assertEqual(Folder.objects.all().count(), 1)
        self.assertEqual(list(Folder.objects.all()), [folder])
        folder.delete()

    def test_addition_of_documents(self):
        user = User.objects.all()[0]
        folder = Folder.objects.create(title='test', user=user)
        folder.add_document(self.document)

        self.assertEqual(folder.documents.count(), 1)
        self.assertEqual(list(folder.documents), [self.document])
        folder.delete()

    def test_addition_and_deletion_of_documents(self):
        user = User.objects.all()[0]
        folder = Folder.objects.create(title='test', user=user)
        folder.add_document(self.document)

        self.assertEqual(folder.documents.count(), 1)
        self.assertEqual(list(folder.documents), [self.document])

        folder.remove_document(self.document)

        self.assertEqual(folder.documents.count(), 0)
        self.assertEqual(list(folder.documents), [])

        folder.delete()

    def tearDown(self):
        self.document.delete()
        self.document_type.delete()
Esempio n. 8
0
class FolderTestCase(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()

        with open(TEST_DOCUMENT_PATH) as file_object:
            self.document.new_version(file=File(file_object, name='nucleos_11_1.pdf'))

    def test_creation_of_folder(self):
        user = User.objects.all()[0]
        folder = Folder.objects.create(title='test', user=user)

        self.assertEqual(Folder.objects.all().count(), 1)
        self.assertEqual(list(Folder.objects.all()), [folder])
        folder.delete()

    def test_addition_of_documents(self):
        user = User.objects.all()[0]
        folder = Folder.objects.create(title='test', user=user)
        folder.add_document(self.document)

        self.assertEqual(folder.documents.count(), 1)
        self.assertEqual(list(folder.documents), [self.document])
        folder.delete()

    def test_addition_and_deletion_of_documents(self):
        user = User.objects.all()[0]
        folder = Folder.objects.create(title='test', user=user)
        folder.add_document(self.document)

        self.assertEqual(folder.documents.count(), 1)
        self.assertEqual(list(folder.documents), [self.document])

        folder.remove_document(self.document)

        self.assertEqual(folder.documents.count(), 0)
        self.assertEqual(list(folder.documents), [])

        folder.delete()

    def tearDown(self):
        self.document.delete()
        self.document_type.delete()
Esempio n. 9
0
class FolderTestCase(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()

        with open(TEST_DOCUMENT_PATH) as file_object:
            self.document.new_version(file_object=File(file_object))

    def test_creation_of_folder(self):
        user = User.objects.all()[0]
        folder = Folder.objects.create(title='test', user=user)

        self.assertEqual(Folder.objects.all().count(), 1)
        self.assertEqual(list(Folder.objects.all()), [folder])
        folder.delete()

    def test_addition_of_documents(self):
        user = User.objects.all()[0]
        folder = Folder.objects.create(title='test', user=user)
        folder.documents.add(self.document)

        self.assertEqual(folder.documents.count(), 1)
        self.assertEqual(list(folder.documents.all()), [self.document])
        folder.delete()

    def test_addition_and_deletion_of_documents(self):
        user = User.objects.all()[0]
        folder = Folder.objects.create(title='test', user=user)
        folder.documents.add(self.document)

        self.assertEqual(folder.documents.count(), 1)
        self.assertEqual(list(folder.documents.all()), [self.document])

        folder.documents.remove(self.document)

        self.assertEqual(folder.documents.count(), 0)
        self.assertEqual(list(folder.documents.all()), [])

        folder.delete()

    def tearDown(self):
        self.document.delete()
        self.document_type.delete()
Esempio n. 10
0
    def setUp(self):
        self.admin_user = User.objects.create_superuser(
            username=TEST_ADMIN_USERNAME,
            email=TEST_ADMIN_EMAIL,
            password=TEST_ADMIN_PASSWORD)

        self.document_type = DocumentType(name=TEST_DOCUMENT_TYPE)
        self.document_type.save()

        self.document = Document(document_type=self.document_type, )
        self.document.save()

        with open(TEST_DOCUMENT_PATH) as file_object:
            self.document.new_version(
                file_object=File(file_object, name='mayan_11_1.pdf'))
Esempio n. 11
0
    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()

        with open(TEST_DOCUMENT_PATH) as file_object:
            self.document.new_version(
                file_object=File(file_object, name='mayan_11_1.pdf'))

        with open(TEST_KEY_FILE) as file_object:
            gpg.import_key(file_object.read())
Esempio n. 12
0
class DocumentTestCase(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()

        with open(TEST_DOCUMENT_PATH) as file_object:
            self.document.new_version(file_object=File(file_object, name="mayan_11_1.pdf"))

        with open(TEST_KEY_FILE) as file_object:
            gpg.import_key(file_object.read())

    def test_document_no_signature(self):
        self.failUnlessEqual(DocumentVersionSignature.objects.has_detached_signature(self.document), False)

    def test_new_document_version_signed(self):
        with open(TEST_SIGNED_DOCUMENT_PATH) as file_object:
            new_version_data = {"comment": "test comment 1"}

            self.document.new_version(file_object=File(file_object, name="mayan_11_1.pdf.gpg"), **new_version_data)

        self.failUnlessEqual(DocumentVersionSignature.objects.has_detached_signature(self.document), False)
        self.failUnlessEqual(
            DocumentVersionSignature.objects.verify_signature(self.document).status, SIGNATURE_STATE_VALID
        )

    def test_detached_signatures(self):
        new_version_data = {"comment": "test comment 2"}
        with open(TEST_DOCUMENT_PATH) as file_object:
            self.document.new_version(file_object=File(file_object), **new_version_data)

        # GPGVerificationError
        self.failUnlessEqual(DocumentVersionSignature.objects.verify_signature(self.document), None)

        with open(TEST_SIGNATURE_FILE_PATH, "rb") as file_object:
            DocumentVersionSignature.objects.add_detached_signature(self.document, File(file_object))

        self.failUnlessEqual(DocumentVersionSignature.objects.has_detached_signature(self.document), True)
        self.failUnlessEqual(
            DocumentVersionSignature.objects.verify_signature(self.document).status, SIGNATURE_STATE_VALID
        )

    def tearDown(self):
        self.document.delete()
        self.document_type.delete()
Esempio n. 13
0
class DocumentSearchTestCase(TestCase):
    def setUp(self):
        self.admin_user = User.objects.create_superuser(username=TEST_ADMIN_USERNAME, email=TEST_ADMIN_EMAIL, password=TEST_ADMIN_PASSWORD)

        self.document_type = DocumentType(name=TEST_DOCUMENT_TYPE)
        self.document_type.save()

        self.document = Document(
            document_type=self.document_type,
        )
        self.document.save()

        with open(TEST_DOCUMENT_PATH) as file_object:
            self.document.new_version(file_object=File(file_object, name='mayan_11_1.pdf'))

    def test_simple_search_after_related_name_change(self):
        """
        Test that simple search works after related_name changes to
        document versions and document version pages
        """

        model_list, result_set, elapsed_time = document_search.search({'q': 'Mayan'}, user=self.admin_user)
        self.assertEqual(len(result_set), 1)
        self.assertEqual(model_list, [self.document])

    def test_advanced_search_after_related_name_change(self):
        # Test versions__filename
        model_list, result_set, elapsed_time = document_search.search({'label': self.document.label}, user=self.admin_user)
        self.assertEqual(len(result_set), 1)
        self.assertEqual(model_list, [self.document])

        # Test versions__mimetype
        model_list, result_set, elapsed_time = document_search.search({'versions__mimetype': self.document.file_mimetype}, user=self.admin_user)
        self.assertEqual(len(result_set), 1)
        self.assertEqual(model_list, [self.document])

        # Test versions__pages__content
        # Search by the first 20 characters of the content of the first page of the uploaded document
        model_list, result_set, elapsed_time = document_search.search({'versions__pages__content': self.document.latest_version.pages.all()[0].content[0:20]}, user=self.admin_user)
        self.assertEqual(len(result_set), 1)
        self.assertEqual(model_list, [self.document])

    def tearDown(self):
        self.document.delete()
        self.document_type.delete()
Esempio n. 14
0
    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()

        with open(TEST_DOCUMENT_PATH) as file_object:
            self.document.new_version(file_object=File(file_object))
Esempio n. 15
0
    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()

        with open(TEST_DOCUMENT_PATH) as file_object:
            self.document.new_version(file=File(file_object, name='nucleos_11_1.pdf'))
Esempio n. 16
0
    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()

        with open(TEST_DOCUMENT_PATH) as file_object:
            self.document.new_version(file_object=File(file_object, name="mayan_11_1.pdf"))

        with open(TEST_KEY_FILE) as file_object:
            gpg.import_key(file_object.read())
Esempio n. 17
0
    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()

        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()
Esempio n. 18
0
    def setUp(self):
        self.admin_user = User.objects.create_superuser(username=TEST_ADMIN_USERNAME, email=TEST_ADMIN_EMAIL, password=TEST_ADMIN_PASSWORD)

        self.document_type = DocumentType(name=TEST_DOCUMENT_TYPE)
        self.document_type.save()

        self.document = Document(
            document_type=self.document_type,
        )
        self.document.save()

        with open(TEST_DOCUMENT_PATH) as file_object:
            self.document.new_version(file_object=File(file_object, name='mayan_11_1.pdf'))
Esempio n. 19
0
class TagTestCase(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()

        with open(TEST_DOCUMENT_PATH) as file_object:
            self.document.new_version(file_object=File(file_object))

    def runTest(self):
        tag = Tag(label='test', color=COLOR_RED)
        tag.save()
        self.failUnlessEqual(tag.label, 'test')
        self.failUnlessEqual(tag.get_color_code(), 'red')

    def test_addition_and_deletion_of_documents(self):
        tag = Tag(label='test', color=COLOR_RED)
        tag.save()

        tag.documents.add(self.document)

        self.assertEqual(tag.documents.count(), 1)
        self.assertEqual(list(tag.documents.all()), [self.document])

        tag.documents.remove(self.document)

        self.assertEqual(tag.documents.count(), 0)
        self.assertEqual(list(tag.documents.all()), [])

        tag.delete()

    def tearDown(self):
        self.document.delete()
        self.document_type.delete()
Esempio n. 20
0
class TagTestCase(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()

        with open(TEST_DOCUMENT_PATH) as file_object:
            self.document.new_version(file_object=File(file_object))

    def runTest(self):
        tag = Tag(label="test", color=COLOR_RED)
        tag.save()
        self.failUnlessEqual(tag.label, "test")
        self.failUnlessEqual(tag.get_color_code(), "red")

    def test_addition_and_deletion_of_documents(self):
        tag = Tag(label="test", color=COLOR_RED)
        tag.save()

        tag.documents.add(self.document)

        self.assertEqual(tag.documents.count(), 1)
        self.assertEqual(list(tag.documents.all()), [self.document])

        tag.documents.remove(self.document)

        self.assertEqual(tag.documents.count(), 0)
        self.assertEqual(list(tag.documents.all()), [])

        tag.delete()

    def tearDown(self):
        self.document.delete()
        self.document_type.delete()
Esempio n. 21
0
    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()

        with open(TEST_DOCUMENT_PATH) as file_object:
            self.document.new_version(file=File(file_object, name='title_page.png'))

        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)
Esempio n. 22
0
    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)
Esempio n. 23
0
class DocumentTestCase(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()

        with open(TEST_DOCUMENT_PATH) as file_object:
            self.document.new_version(
                file_object=File(file_object, name='mayan_11_1.pdf'))

        with open(TEST_KEY_FILE) as file_object:
            gpg.import_key(file_object.read())

    def test_document_no_signature(self):
        self.failUnlessEqual(
            DocumentVersionSignature.objects.has_detached_signature(
                self.document), False)

    def test_new_document_version_signed(self):
        with open(TEST_SIGNED_DOCUMENT_PATH) as file_object:
            new_version_data = {
                'comment': 'test comment 1',
            }

            self.document.new_version(file_object=File(
                file_object, name='mayan_11_1.pdf.gpg'),
                                      **new_version_data)

        self.failUnlessEqual(
            DocumentVersionSignature.objects.has_detached_signature(
                self.document), False)
        self.failUnlessEqual(
            DocumentVersionSignature.objects.verify_signature(
                self.document).status, SIGNATURE_STATE_VALID)

    def test_detached_signatures(self):
        new_version_data = {
            'comment': 'test comment 2',
        }
        with open(TEST_DOCUMENT_PATH) as file_object:
            self.document.new_version(file_object=File(file_object),
                                      **new_version_data)

        # GPGVerificationError
        self.failUnlessEqual(
            DocumentVersionSignature.objects.verify_signature(self.document),
            None)

        with open(TEST_SIGNATURE_FILE_PATH, 'rb') as file_object:
            DocumentVersionSignature.objects.add_detached_signature(
                self.document, File(file_object))

        self.failUnlessEqual(
            DocumentVersionSignature.objects.has_detached_signature(
                self.document), True)
        self.failUnlessEqual(
            DocumentVersionSignature.objects.verify_signature(
                self.document).status, SIGNATURE_STATE_VALID)

    def tearDown(self):
        self.document.delete()
        self.document_type.delete()