From e431a658cc3409ee4a347dc7020a038b9e9028d9 Mon Sep 17 00:00:00 2001 From: jonaswinkler Date: Mon, 30 Nov 2020 22:04:25 +0100 Subject: [PATCH] more testing. --- src/documents/tests/test_api.py | 4 ++-- src/documents/tests/test_consumer.py | 1 + .../tests/test_management_decrypt.py | 3 ++- src/documents/tests/test_tasks.py | 23 +++++++++++++++++++ 4 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 src/documents/tests/test_tasks.py diff --git a/src/documents/tests/test_api.py b/src/documents/tests/test_api.py index b9f3dcfba..78a3a8ad9 100644 --- a/src/documents/tests/test_api.py +++ b/src/documents/tests/test_api.py @@ -12,10 +12,10 @@ from documents.models import Document, Correspondent, DocumentType, Tag from documents.tests.utils import DirectoriesMixin -class DocumentApiTest(DirectoriesMixin, APITestCase): +class TestDocumentApi(DirectoriesMixin, APITestCase): def setUp(self): - super(DocumentApiTest, self).setUp() + super(TestDocumentApi, self).setUp() user = User.objects.create_superuser(username="temp_admin") self.client.force_login(user=user) diff --git a/src/documents/tests/test_consumer.py b/src/documents/tests/test_consumer.py index 1b2e3e649..8217bf0cf 100644 --- a/src/documents/tests/test_consumer.py +++ b/src/documents/tests/test_consumer.py @@ -435,6 +435,7 @@ class TestConsumer(DirectoriesMixin, TestCase): fd, f = tempfile.mkstemp(suffix=".pdf", dir=self.dirs.scratch_dir) return f + @override_settings(PAPERLESS_FILENAME_FORMAT=None) def testNormalOperation(self): filename = self.get_test_file() diff --git a/src/documents/tests/test_management_decrypt.py b/src/documents/tests/test_management_decrypt.py index 8f41e076f..f68ea7cc1 100644 --- a/src/documents/tests/test_management_decrypt.py +++ b/src/documents/tests/test_management_decrypt.py @@ -17,7 +17,8 @@ class TestDecryptDocuments(TestCase): @override_settings( ORIGINALS_DIR=os.path.join(os.path.dirname(__file__), "samples", "originals"), THUMBNAIL_DIR=os.path.join(os.path.dirname(__file__), "samples", "thumb"), - PASSPHRASE="test" + PASSPHRASE="test", + PAPERLESS_FILENAME_FORMAT=None ) @mock.patch("documents.management.commands.decrypt_documents.input") def test_decrypt(self, m): diff --git a/src/documents/tests/test_tasks.py b/src/documents/tests/test_tasks.py new file mode 100644 index 000000000..d408c1e3d --- /dev/null +++ b/src/documents/tests/test_tasks.py @@ -0,0 +1,23 @@ +from datetime import datetime + +from django.test import TestCase + +from documents import tasks +from documents.models import Document +from documents.tests.utils import DirectoriesMixin + + +class TestTasks(DirectoriesMixin, TestCase): + + def test_index_reindex(self): + Document.objects.create(title="test", content="my document", checksum="wow", added=datetime.now(), created=datetime.now(), modified=datetime.now()) + + tasks.index_reindex() + + def test_index_optimize(self): + Document.objects.create(title="test", content="my document", checksum="wow", added=datetime.now(), created=datetime.now(), modified=datetime.now()) + + tasks.index_optimize() + + def test_train_classifier(self): + tasks.train_classifier()