Update more tests to new internal APIs.
This commit is contained in:
@@ -5,7 +5,7 @@ import shutil
|
||||
from django.test import TestCase
|
||||
|
||||
from .api import GPG, Key
|
||||
from .settings import GPG_PATH, KEYSERVERS
|
||||
from .settings import setting_gpg_path
|
||||
|
||||
TEST_GPG_HOME = '/tmp/test_gpg_home'
|
||||
TEST_KEYSERVERS = ['pool.sks-keyservers.net']
|
||||
@@ -20,7 +20,7 @@ class DjangoGPGTestCase(TestCase):
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
self.gpg = GPG(binary_path=GPG_PATH, home=TEST_GPG_HOME, keyservers=KEYSERVERS)
|
||||
self.gpg = GPG(binary_path=setting_gpg_path.value, home=TEST_GPG_HOME, keyservers=TEST_KEYSERVERS)
|
||||
|
||||
def test_main(self):
|
||||
# No private or public keys in the keyring
|
||||
|
||||
@@ -20,17 +20,14 @@ TEST_KEY_FILE = os.path.join(settings.BASE_DIR, 'contrib', 'sample_documents', '
|
||||
|
||||
class DocumentTestCase(TestCase):
|
||||
def setUp(self):
|
||||
self.document_type = DocumentType(name='test doc type')
|
||||
self.document_type.save()
|
||||
self.document_type = DocumentType.objects.create(name='test doc type')
|
||||
|
||||
self.document = Document(
|
||||
document_type=self.document_type,
|
||||
description='description',
|
||||
)
|
||||
self.document.save()
|
||||
ocr_settings = self.document_type.ocr_settings
|
||||
ocr_settings.auto_ocr = False
|
||||
ocr_settings.save()
|
||||
|
||||
with open(TEST_DOCUMENT_PATH) as file_object:
|
||||
self.document.new_version(file_object=File(file_object, name='mayan_11_1.pdf'))
|
||||
self.document = self.document_type.new_document(file_object=File(file_object, name='mayan_11_1.pdf'))
|
||||
|
||||
with open(TEST_KEY_FILE) as file_object:
|
||||
gpg.import_key(file_object.read())
|
||||
|
||||
@@ -7,6 +7,9 @@ from django.contrib.auth.models import User
|
||||
from django.core.files.base import File
|
||||
from django.test import TestCase
|
||||
|
||||
from authentication.tests import (
|
||||
TEST_ADMIN_EMAIL, TEST_ADMIN_PASSWORD, TEST_ADMIN_USERNAME
|
||||
)
|
||||
from documents.models import Document, DocumentType
|
||||
|
||||
from .models import Folder
|
||||
@@ -16,21 +19,15 @@ TEST_DOCUMENT_PATH = os.path.join(settings.BASE_DIR, 'contrib', 'sample_document
|
||||
|
||||
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()
|
||||
self.document_type = DocumentType.objects.create(name='test doc type')
|
||||
|
||||
with open(TEST_DOCUMENT_PATH) as file_object:
|
||||
self.document.new_version(file_object=File(file_object))
|
||||
self.document = self.document_type.new_document(file_object=File(file_object))
|
||||
|
||||
self.user = User.objects.create_superuser(username=TEST_ADMIN_USERNAME, email=TEST_ADMIN_EMAIL, password=TEST_ADMIN_PASSWORD)
|
||||
|
||||
def test_creation_of_folder(self):
|
||||
user = User.objects.all()[0]
|
||||
folder = Folder.objects.create(title='test', user=user)
|
||||
folder = Folder.objects.create(title='test', user=self.user)
|
||||
|
||||
self.assertEqual(Folder.objects.all().count(), 1)
|
||||
self.assertEqual(list(Folder.objects.all()), [folder])
|
||||
@@ -38,7 +35,7 @@ class FolderTestCase(TestCase):
|
||||
|
||||
def test_addition_of_documents(self):
|
||||
user = User.objects.all()[0]
|
||||
folder = Folder.objects.create(title='test', user=user)
|
||||
folder = Folder.objects.create(title='test', user=self.user)
|
||||
folder.documents.add(self.document)
|
||||
|
||||
self.assertEqual(folder.documents.count(), 1)
|
||||
@@ -47,7 +44,7 @@ class FolderTestCase(TestCase):
|
||||
|
||||
def test_addition_and_deletion_of_documents(self):
|
||||
user = User.objects.all()[0]
|
||||
folder = Folder.objects.create(title='test', user=user)
|
||||
folder = Folder.objects.create(title='test', user=self.user)
|
||||
folder.documents.add(self.document)
|
||||
|
||||
self.assertEqual(folder.documents.count(), 1)
|
||||
|
||||
Reference in New Issue
Block a user