]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Some obvious fixes
authorshamoon <4887959+shamoon@users.noreply.github.com>
Wed, 9 Apr 2025 01:56:58 +0000 (18:56 -0700)
committershamoon <4887959+shamoon@users.noreply.github.com>
Wed, 9 Apr 2025 02:04:41 +0000 (19:04 -0700)
21 files changed:
src/paperless/settings.py
src/paperless/signals/handlers.py
src/paperless/tests/test_api_bulk_edit.py
src/paperless/tests/test_api_objects.py
src/paperless/tests/test_api_search.py
src/paperless/tests/test_api_tasks.py
src/paperless/tests/test_barcodes.py
src/paperless/tests/test_bulk_edit.py
src/paperless/tests/test_checks.py
src/paperless/tests/test_double_sided.py
src/paperless/tests/test_management.py
src/paperless/tests/test_management_consumer.py
src/paperless/tests/test_management_exporter.py
src/paperless/tests/test_management_importer.py
src/paperless/tests/test_management_thumbnails.py
src/paperless/tests/test_models.py
src/paperless/tests/test_settings.py
src/paperless/tests/test_task_signals.py
src/paperless/tests/test_tasks.py
src/paperless/tests/test_workflows.py
src/paperless/tests/utils.py

index f3f7af4cd36a39882f071157bea0bc46ad63af8d..5c1ad53d35e90d072cf1331f1321449866c14f7c 100644 (file)
@@ -176,7 +176,7 @@ def _parse_beat_schedule() -> dict:
             "env_key": "PAPERLESS_TRAIN_TASK_CRON",
             # Default hourly at 5 minutes past the hour
             "env_default": "5 */1 * * *",
-            "task": "documents.tasks.train_classifier",
+            "task": "paperless.tasks.train_classifier",
             "options": {
                 # 1 minute before default schedule sends again
                 "expires": 59.0 * 60.0,
@@ -187,7 +187,7 @@ def _parse_beat_schedule() -> dict:
             "env_key": "PAPERLESS_INDEX_TASK_CRON",
             # Default daily at midnight
             "env_default": "0 0 * * *",
-            "task": "documents.tasks.index_optimize",
+            "task": "paperless.tasks.index_optimize",
             "options": {
                 # 1 hour before default schedule sends again
                 "expires": 23.0 * 60.0 * 60.0,
@@ -198,7 +198,7 @@ def _parse_beat_schedule() -> dict:
             "env_key": "PAPERLESS_SANITY_TASK_CRON",
             # Default Sunday at 00:30
             "env_default": "30 0 * * sun",
-            "task": "documents.tasks.sanity_check",
+            "task": "paperless.tasks.sanity_check",
             "options": {
                 # 1 hour before default schedule sends again
                 "expires": ((7.0 * 24.0) - 1.0) * 60.0 * 60.0,
@@ -209,7 +209,7 @@ def _parse_beat_schedule() -> dict:
             "env_key": "PAPERLESS_EMPTY_TRASH_TASK_CRON",
             # Default daily at 01:00
             "env_default": "0 1 * * *",
-            "task": "documents.tasks.empty_trash",
+            "task": "paperless.tasks.empty_trash",
             "options": {
                 # 1 hour before default schedule sends again
                 "expires": 23.0 * 60.0 * 60.0,
@@ -220,7 +220,7 @@ def _parse_beat_schedule() -> dict:
             "env_key": "PAPERLESS_WORKFLOW_SCHEDULED_TASK_CRON",
             # Default hourly at 5 minutes past the hour
             "env_default": "5 */1 * * *",
-            "task": "documents.tasks.check_scheduled_workflows",
+            "task": "paperless.tasks.check_scheduled_workflows",
             "options": {
                 # 1 minute before default schedule sends again
                 "expires": 59.0 * 60.0,
@@ -443,7 +443,7 @@ TEMPLATES = [
                 "django.template.context_processors.request",
                 "django.contrib.auth.context_processors.auth",
                 "django.contrib.messages.context_processors.messages",
-                "documents.context_processors.settings",
+                "paperless.context_processors.settings",
             ],
         },
     },
index c9e23c8abe7122841a2f094d7c2a1506d0eb29ae..0bf8ffc2e4d7ace54c8204121755729a179b1dff 100644 (file)
@@ -1278,7 +1278,7 @@ def before_task_publish_handler(sender=None, headers=None, body=None, **kwargs):
     https://docs.celeryq.dev/en/stable/internals/protocol.html#version-2
 
     """
-    if "task" not in headers or headers["task"] != "documents.tasks.consume_file":
+    if "task" not in headers or headers["task"] != "paperless.tasks.consume_file":
         # Assumption: this is only ever a v2 message
         return
 
index 8db30cfe1904338d0863980898ded43c68a21829..b03d055d2cf9e3d419f92fdf5cb17e0ea6a0d466 100644 (file)
@@ -26,7 +26,7 @@ class TestBulkEditAPI(DirectoriesMixin, APITestCase):
         self.user = user
         self.client.force_authenticate(user=user)
 
-        patcher = mock.patch("documents.bulk_edit.bulk_update_documents.delay")
+        patcher = mock.patch("paperless.bulk_edit.bulk_update_documents.delay")
         self.async_task = patcher.start()
         self.addCleanup(patcher.stop)
         self.c1 = Correspondent.objects.create(name="c1")
@@ -61,7 +61,7 @@ class TestBulkEditAPI(DirectoriesMixin, APITestCase):
         m.return_value = return_value
         m.__name__ = method_name
 
-    @mock.patch("documents.bulk_edit.bulk_update_documents.delay")
+    @mock.patch("paperless.bulk_edit.bulk_update_documents.delay")
     def test_api_set_correspondent(self, bulk_update_task_mock):
         self.assertNotEqual(self.doc1.correspondent, self.c1)
         response = self.client.post(
@@ -80,7 +80,7 @@ class TestBulkEditAPI(DirectoriesMixin, APITestCase):
         self.assertEqual(self.doc1.correspondent, self.c1)
         bulk_update_task_mock.assert_called_once_with(document_ids=[self.doc1.pk])
 
-    @mock.patch("documents.bulk_edit.bulk_update_documents.delay")
+    @mock.patch("paperless.bulk_edit.bulk_update_documents.delay")
     def test_api_unset_correspondent(self, bulk_update_task_mock):
         self.doc1.correspondent = self.c1
         self.doc1.save()
@@ -102,7 +102,7 @@ class TestBulkEditAPI(DirectoriesMixin, APITestCase):
         self.doc1.refresh_from_db()
         self.assertIsNone(self.doc1.correspondent)
 
-    @mock.patch("documents.bulk_edit.bulk_update_documents.delay")
+    @mock.patch("paperless.bulk_edit.bulk_update_documents.delay")
     def test_api_set_type(self, bulk_update_task_mock):
         self.assertNotEqual(self.doc1.document_type, self.dt1)
         response = self.client.post(
@@ -121,7 +121,7 @@ class TestBulkEditAPI(DirectoriesMixin, APITestCase):
         self.assertEqual(self.doc1.document_type, self.dt1)
         bulk_update_task_mock.assert_called_once_with(document_ids=[self.doc1.pk])
 
-    @mock.patch("documents.bulk_edit.bulk_update_documents.delay")
+    @mock.patch("paperless.bulk_edit.bulk_update_documents.delay")
     def test_api_unset_type(self, bulk_update_task_mock):
         self.doc1.document_type = self.dt1
         self.doc1.save()
@@ -142,7 +142,7 @@ class TestBulkEditAPI(DirectoriesMixin, APITestCase):
         self.assertIsNone(self.doc1.document_type)
         bulk_update_task_mock.assert_called_once_with(document_ids=[self.doc1.pk])
 
-    @mock.patch("documents.bulk_edit.bulk_update_documents.delay")
+    @mock.patch("paperless.bulk_edit.bulk_update_documents.delay")
     def test_api_add_tag(self, bulk_update_task_mock):
         self.assertFalse(self.doc1.tags.filter(pk=self.t1.pk).exists())
 
@@ -164,7 +164,7 @@ class TestBulkEditAPI(DirectoriesMixin, APITestCase):
 
         bulk_update_task_mock.assert_called_once_with(document_ids=[self.doc1.pk])
 
-    @mock.patch("documents.bulk_edit.bulk_update_documents.delay")
+    @mock.patch("paperless.bulk_edit.bulk_update_documents.delay")
     def test_api_remove_tag(self, bulk_update_task_mock):
         self.doc1.tags.add(self.t1)
 
index 6c575bd55ccb1bc3362b2d6a91e920237a55adee..04c3c86a62edb7d52e12ad0a2df3810548618f6a 100644 (file)
@@ -248,7 +248,7 @@ class TestApiStoragePaths(DirectoriesMixin, APITestCase):
         self.assertEqual(response.status_code, status.HTTP_201_CREATED)
         self.assertEqual(StoragePath.objects.count(), 2)
 
-    @mock.patch("documents.bulk_edit.bulk_update_documents.delay")
+    @mock.patch("paperless.bulk_edit.bulk_update_documents.delay")
     def test_api_update_storage_path(self, bulk_update_mock):
         """
         GIVEN:
@@ -277,7 +277,7 @@ class TestApiStoragePaths(DirectoriesMixin, APITestCase):
 
         self.assertCountEqual([document.pk], args[0])
 
-    @mock.patch("documents.bulk_edit.bulk_update_documents.delay")
+    @mock.patch("paperless.bulk_edit.bulk_update_documents.delay")
     def test_api_delete_storage_path(self, bulk_update_mock):
         """
         GIVEN:
index 1202189e60f0d91d4d9b0853a7b966aeced9bc17..78413e9f836987d0a618444f413976ba7d77473b 100644 (file)
@@ -1160,7 +1160,7 @@ class TestDocumentSearchApi(DirectoriesMixin, APITestCase):
             [d3.id, d2.id, d1.id],
         )
 
-    @mock.patch("documents.bulk_edit.bulk_update_documents")
+    @mock.patch("paperless.bulk_edit.bulk_update_documents")
     def test_global_search(self, m):
         """
         GIVEN:
index 90e61abcd73fc5e1a0eb9598f43092fccbd22ba2..96bb4080f055ad4a0a892cc5d940f2867e532a3b 100644 (file)
@@ -348,7 +348,7 @@ class TestTasks(DirectoriesMixin, APITestCase):
         self.assertEqual(response.status_code, status.HTTP_500_INTERNAL_SERVER_ERROR)
         mock_train_classifier.assert_called_once_with(scheduled=False)
 
-    @mock.patch("documents.tasks.sanity_check")
+    @mock.patch("paperless.tasks.sanity_check")
     def test_run_task_requires_superuser(self, mock_check_sanity):
         """
         GIVEN:
index 184f30f17a09b5458f1b356de7e501b3e6bf8f92..2c72c63b8873a6d1ebf852c13bd0833277686dff 100644 (file)
@@ -575,7 +575,7 @@ class TestBarcodeNewConsume(
 
         overrides = DocumentMetadataOverrides(tag_ids=[1, 2, 9])
 
-        with mock.patch("documents.tasks.ProgressManager", DummyProgressManager):
+        with mock.patch("paperless.tasks.ProgressManager", DummyProgressManager):
             self.assertEqual(
                 tasks.consume_file(
                     ConsumableDocument(
@@ -711,7 +711,7 @@ class TestAsnBarcode(DirectoriesMixin, SampleDirMixin, GetReaderPluginMixin, Tes
         dst = settings.SCRATCH_DIR / "barcode-39-asn-123.pdf"
         shutil.copy(test_file, dst)
 
-        with mock.patch("documents.tasks.ProgressManager", DummyProgressManager):
+        with mock.patch("paperless.tasks.ProgressManager", DummyProgressManager):
             tasks.consume_file(
                 ConsumableDocument(
                     source=DocumentSource.ConsumeFolder,
index 1432674582db0c23f9d8faf79642a09aabddc53c..37aecbff06c0a4df9103ce78613adca5c35cf45e 100644 (file)
@@ -30,7 +30,7 @@ class TestBulkEdit(DirectoriesMixin, TestCase):
         self.group1 = Group.objects.create(name="group1")
         self.group2 = Group.objects.create(name="group2")
 
-        patcher = mock.patch("documents.bulk_edit.bulk_update_documents.delay")
+        patcher = mock.patch("paperless.bulk_edit.bulk_update_documents.delay")
         self.async_task = patcher.start()
         self.addCleanup(patcher.stop)
         self.c1 = Correspondent.objects.create(name="c1")
@@ -345,7 +345,7 @@ class TestBulkEdit(DirectoriesMixin, TestCase):
             [self.doc3.id, self.doc4.id, self.doc5.id],
         )
 
-    @mock.patch("documents.tasks.bulk_update_documents.delay")
+    @mock.patch("paperless.tasks.bulk_update_documents.delay")
     def test_set_permissions(self, m):
         doc_ids = [self.doc1.id, self.doc2.id, self.doc3.id]
 
@@ -384,7 +384,7 @@ class TestBulkEdit(DirectoriesMixin, TestCase):
         )
         self.assertEqual(groups_with_perms.count(), 1)
 
-    @mock.patch("documents.tasks.bulk_update_documents.delay")
+    @mock.patch("paperless.tasks.bulk_update_documents.delay")
     def test_set_permissions_merge(self, m):
         doc_ids = [self.doc1.id, self.doc2.id, self.doc3.id]
 
@@ -532,7 +532,7 @@ class TestPDFActions(DirectoriesMixin, TestCase):
         self.img_doc.archive_filename = img_doc_archive
         self.img_doc.save()
 
-    @mock.patch("documents.tasks.consume_file.s")
+    @mock.patch("paperless.tasks.consume_file.s")
     def test_merge(self, mock_consume_file):
         """
         GIVEN:
@@ -572,9 +572,9 @@ class TestPDFActions(DirectoriesMixin, TestCase):
 
         self.assertEqual(result, "OK")
 
-    @mock.patch("documents.bulk_edit.delete.si")
-    @mock.patch("documents.tasks.consume_file.s")
-    @mock.patch("documents.bulk_edit.chain")
+    @mock.patch("paperless.bulk_edit.delete.si")
+    @mock.patch("paperless.tasks.consume_file.s")
+    @mock.patch("paperless.bulk_edit.chain")
     def test_merge_and_delete_originals(
         self,
         mock_chain,
@@ -616,7 +616,7 @@ class TestPDFActions(DirectoriesMixin, TestCase):
             doc_ids,
         )
 
-    @mock.patch("documents.tasks.consume_file.s")
+    @mock.patch("paperless.tasks.consume_file.s")
     def test_merge_with_archive_fallback(self, mock_consume_file):
         """
         GIVEN:
@@ -642,7 +642,7 @@ class TestPDFActions(DirectoriesMixin, TestCase):
             expected_filename,
         )
 
-    @mock.patch("documents.tasks.consume_file.delay")
+    @mock.patch("paperless.tasks.consume_file.delay")
     @mock.patch("pikepdf.open")
     def test_merge_with_errors(self, mock_open_pdf, mock_consume_file):
         """
@@ -667,7 +667,7 @@ class TestPDFActions(DirectoriesMixin, TestCase):
 
         mock_consume_file.assert_not_called()
 
-    @mock.patch("documents.tasks.consume_file.s")
+    @mock.patch("paperless.tasks.consume_file.s")
     def test_split(self, mock_consume_file):
         """
         GIVEN:
@@ -687,9 +687,9 @@ class TestPDFActions(DirectoriesMixin, TestCase):
 
         self.assertEqual(result, "OK")
 
-    @mock.patch("documents.bulk_edit.delete.si")
-    @mock.patch("documents.tasks.consume_file.s")
-    @mock.patch("documents.bulk_edit.chord")
+    @mock.patch("paperless.bulk_edit.delete.si")
+    @mock.patch("paperless.tasks.consume_file.s")
+    @mock.patch("paperless.bulk_edit.chord")
     def test_split_and_delete_originals(
         self,
         mock_chord,
@@ -725,7 +725,7 @@ class TestPDFActions(DirectoriesMixin, TestCase):
             doc_ids,
         )
 
-    @mock.patch("documents.tasks.consume_file.delay")
+    @mock.patch("paperless.tasks.consume_file.delay")
     @mock.patch("pikepdf.Pdf.save")
     def test_split_with_errors(self, mock_save_pdf, mock_consume_file):
         """
@@ -749,8 +749,8 @@ class TestPDFActions(DirectoriesMixin, TestCase):
 
         mock_consume_file.assert_not_called()
 
-    @mock.patch("documents.tasks.bulk_update_documents.si")
-    @mock.patch("documents.tasks.update_document_content_maybe_archive_file.s")
+    @mock.patch("paperless.tasks.bulk_update_documents.si")
+    @mock.patch("paperless.tasks.update_document_content_maybe_archive_file.s")
     @mock.patch("celery.chord.delay")
     def test_rotate(self, mock_chord, mock_update_document, mock_update_documents):
         """
@@ -768,8 +768,8 @@ class TestPDFActions(DirectoriesMixin, TestCase):
         mock_chord.assert_called_once()
         self.assertEqual(result, "OK")
 
-    @mock.patch("documents.tasks.bulk_update_documents.si")
-    @mock.patch("documents.tasks.update_document_content_maybe_archive_file.s")
+    @mock.patch("paperless.tasks.bulk_update_documents.si")
+    @mock.patch("paperless.tasks.update_document_content_maybe_archive_file.s")
     @mock.patch("pikepdf.Pdf.save")
     def test_rotate_with_error(
         self,
@@ -796,8 +796,8 @@ class TestPDFActions(DirectoriesMixin, TestCase):
             self.assertIn(expected_str, error_str)
             mock_update_archive_file.assert_not_called()
 
-    @mock.patch("documents.tasks.bulk_update_documents.si")
-    @mock.patch("documents.tasks.update_document_content_maybe_archive_file.s")
+    @mock.patch("paperless.tasks.bulk_update_documents.si")
+    @mock.patch("paperless.tasks.update_document_content_maybe_archive_file.s")
     @mock.patch("celery.chord.delay")
     def test_rotate_non_pdf(
         self,
@@ -823,7 +823,7 @@ class TestPDFActions(DirectoriesMixin, TestCase):
             mock_chord.assert_called_once()
             self.assertEqual(result, "OK")
 
-    @mock.patch("documents.tasks.update_document_content_maybe_archive_file.delay")
+    @mock.patch("paperless.tasks.update_document_content_maybe_archive_file.delay")
     @mock.patch("pikepdf.Pdf.save")
     def test_delete_pages(self, mock_pdf_save, mock_update_archive_file):
         """
@@ -848,7 +848,7 @@ class TestPDFActions(DirectoriesMixin, TestCase):
         self.doc2.refresh_from_db()
         self.assertEqual(self.doc2.page_count, expected_page_count)
 
-    @mock.patch("documents.tasks.update_document_content_maybe_archive_file.delay")
+    @mock.patch("paperless.tasks.update_document_content_maybe_archive_file.delay")
     @mock.patch("pikepdf.Pdf.save")
     def test_delete_pages_with_error(self, mock_pdf_save, mock_update_archive_file):
         """
index dfa4a5f1db4b507ef9551879e3099f2fbb192763..b29b6e3fbdec784deff920dbaed34ec65e83d466 100644 (file)
@@ -8,7 +8,6 @@ from django.core.checks import Warning
 from django.test import TestCase
 from django.test import override_settings
 
-from documents.tests.factories import DocumentFactory
 from paperless.checks import audit_log_check
 from paperless.checks import binaries_check
 from paperless.checks import changed_password_check
@@ -18,6 +17,7 @@ from paperless.checks import parser_check
 from paperless.checks import paths_check
 from paperless.checks import settings_values_check
 from paperless.models import Document
+from paperless.tests.factories import DocumentFactory
 from paperless.tests.utils import DirectoriesMixin
 from paperless.tests.utils import FileSystemAssertsMixin
 
index 0b0d759b37b39822d91978d8cbf349e925ab3f68..a39e590798e50229108b27538d03737e78b32870 100644 (file)
@@ -43,7 +43,7 @@ class TestDoubleSided(DirectoriesMixin, FileSystemAssertsMixin, TestCase):
         dst.parent.mkdir(parents=True, exist_ok=True)
         shutil.copy(src, dst)
         with mock.patch(
-            "documents.tasks.ProgressManager",
+            "paperless.tasks.ProgressManager",
             DummyProgressManager,
         ):
             msg = tasks.consume_file(
index 05d1535a6b498d2b7d1c4dc6438026994f8a106f..6f4ab9ab1f1d9e290cf581bb6bcec52299e5c969 100644 (file)
@@ -113,7 +113,7 @@ class TestDecryptDocuments(FileSystemAssertsMixin, TestCase):
         PASSPHRASE="test",
         FILENAME_FORMAT=None,
     )
-    @mock.patch("documents.management.commands.decrypt_documents.input")
+    @mock.patch("paperless.management.commands.decrypt_documents.input")
     def test_decrypt(self, m):
         media_dir = tempfile.mkdtemp()
         originals_dir = Path(media_dir) / "documents" / "originals"
@@ -173,12 +173,12 @@ class TestDecryptDocuments(FileSystemAssertsMixin, TestCase):
 
 
 class TestMakeIndex(TestCase):
-    @mock.patch("documents.management.commands.document_index.index_reindex")
+    @mock.patch("paperless.management.commands.document_index.index_reindex")
     def test_reindex(self, m):
         call_command("document_index", "reindex")
         m.assert_called_once()
 
-    @mock.patch("documents.management.commands.document_index.index_optimize")
+    @mock.patch("paperless.management.commands.document_index.index_optimize")
     def test_optimize(self, m):
         call_command("document_index", "optimize")
         m.assert_called_once()
@@ -210,7 +210,7 @@ class TestRenamer(DirectoriesMixin, FileSystemAssertsMixin, TestCase):
 
 class TestCreateClassifier(TestCase):
     @mock.patch(
-        "documents.management.commands.document_create_classifier.train_classifier",
+        "paperless.management.commands.document_create_classifier.train_classifier",
     )
     def test_create_classifier(self, m):
         call_command("document_create_classifier")
index 19fe74971a5e5abb11ccc50a94c9218314d72b2f..a796ef683698d0846353a78d80ef244f57341e3b 100644 (file)
@@ -12,9 +12,9 @@ from django.core.management import call_command
 from django.test import TransactionTestCase
 from django.test import override_settings
 
-from documents.management.commands import document_consumer
 from paperless.consumer import ConsumerError
 from paperless.data_models import ConsumableDocument
+from paperless.management.commands import document_consumer
 from paperless.models import Tag
 from paperless.tests.utils import DirectoriesMixin
 from paperless.tests.utils import DocumentConsumeDelayMixin
@@ -148,7 +148,7 @@ class TestConsumer(DirectoriesMixin, ConsumerThreadMixin, TransactionTestCase):
 
         self.assertEqual(input_doc.original_file, f)
 
-    @mock.patch("documents.management.commands.document_consumer.logger.error")
+    @mock.patch("paperless.management.commands.document_consumer.logger.error")
     def test_slow_write_pdf(self, error_logger):
         self.consume_file_mock.side_effect = self.bogus_task
 
@@ -168,7 +168,7 @@ class TestConsumer(DirectoriesMixin, ConsumerThreadMixin, TransactionTestCase):
 
         self.assertEqual(input_doc.original_file, fname)
 
-    @mock.patch("documents.management.commands.document_consumer.logger.error")
+    @mock.patch("paperless.management.commands.document_consumer.logger.error")
     def test_slow_write_and_move(self, error_logger):
         self.consume_file_mock.side_effect = self.bogus_task
 
@@ -190,7 +190,7 @@ class TestConsumer(DirectoriesMixin, ConsumerThreadMixin, TransactionTestCase):
 
         error_logger.assert_not_called()
 
-    @mock.patch("documents.management.commands.document_consumer.logger.error")
+    @mock.patch("paperless.management.commands.document_consumer.logger.error")
     def test_slow_write_incomplete(self, error_logger):
         self.consume_file_mock.side_effect = self.bogus_task
 
@@ -325,7 +325,7 @@ class TestConsumer(DirectoriesMixin, ConsumerThreadMixin, TransactionTestCase):
                 f'_is_ignored("{filepath}") != {expected_ignored_result}',
             )
 
-    @mock.patch("documents.management.commands.document_consumer.open")
+    @mock.patch("paperless.management.commands.document_consumer.open")
     def test_consume_file_busy(self, open_mock):
         # Calling this mock always raises this
         open_mock.side_effect = OSError
index 6a1560754d7bd81bfbd4f1b69a03521f169fa0f3..0ec7bab49ae2ca09b78c4f61180b2d06a5a8f5f7 100644 (file)
@@ -24,8 +24,8 @@ from guardian.models import GroupObjectPermission
 from guardian.models import UserObjectPermission
 from guardian.shortcuts import assign_perm
 
-from documents.management.commands import document_exporter
 from documents.settings import EXPORTER_FILE_NAME
+from paperless.management.commands import document_exporter
 from paperless.models import Correspondent
 from paperless.models import CustomField
 from paperless.models import CustomFieldInstance
@@ -321,7 +321,7 @@ class TestExportImport(
         st_mtime_1 = os.stat(os.path.join(self.target, "manifest.json")).st_mtime
 
         with mock.patch(
-            "documents.management.commands.document_exporter.copy_file_with_basic_stats",
+            "paperless.management.commands.document_exporter.copy_file_with_basic_stats",
         ) as m:
             self._do_export()
             m.assert_not_called()
@@ -332,7 +332,7 @@ class TestExportImport(
         Path(self.d1.source_path).touch()
 
         with mock.patch(
-            "documents.management.commands.document_exporter.copy_file_with_basic_stats",
+            "paperless.management.commands.document_exporter.copy_file_with_basic_stats",
         ) as m:
             self._do_export()
             self.assertEqual(m.call_count, 1)
@@ -359,7 +359,7 @@ class TestExportImport(
         self.assertIsFile(os.path.join(self.target, "manifest.json"))
 
         with mock.patch(
-            "documents.management.commands.document_exporter.copy_file_with_basic_stats",
+            "paperless.management.commands.document_exporter.copy_file_with_basic_stats",
         ) as m:
             self._do_export()
             m.assert_not_called()
@@ -370,7 +370,7 @@ class TestExportImport(
         self.d2.save()
 
         with mock.patch(
-            "documents.management.commands.document_exporter.copy_file_with_basic_stats",
+            "paperless.management.commands.document_exporter.copy_file_with_basic_stats",
         ) as m:
             self._do_export(compare_checksums=True)
             self.assertEqual(m.call_count, 1)
index 4500aa3bd6a81f8b03b7c04e27efef437730be85..1b80d8ffc34050f58b67171bec589e3474568672 100644 (file)
@@ -8,9 +8,9 @@ from django.core.management import call_command
 from django.core.management.base import CommandError
 from django.test import TestCase
 
-from documents.management.commands.document_importer import Command
 from documents.settings import EXPORTER_ARCHIVE_NAME
 from documents.settings import EXPORTER_FILE_NAME
+from paperless.management.commands.document_importer import Command
 from paperless.models import Document
 from paperless.tests.utils import DirectoriesMixin
 from paperless.tests.utils import FileSystemAssertsMixin
index 6fb582c14180eba09976d9cc7420cf6b463ac588..4a6862ea017ba698bb881623a3704f1c3a98f5e0 100644 (file)
@@ -5,7 +5,7 @@ from unittest import mock
 from django.core.management import call_command
 from django.test import TestCase
 
-from documents.management.commands.document_thumbnails import _process_document
+from paperless.management.commands.document_thumbnails import _process_document
 from paperless.models import Document
 from paperless.parsers import get_default_thumbnail
 from paperless.tests.utils import DirectoriesMixin
@@ -67,7 +67,7 @@ class TestMakeThumbnails(DirectoriesMixin, FileSystemAssertsMixin, TestCase):
         self.assertIsFile(get_default_thumbnail())
         self.assertIsFile(self.d3.thumbnail_path)
 
-    @mock.patch("documents.management.commands.document_thumbnails.shutil.move")
+    @mock.patch("paperless.management.commands.document_thumbnails.shutil.move")
     def test_process_document_invalid_mime_type(self, m: mock.Mock):
         self.d1.mime_type = "asdasdasd"
         self.d1.save()
index c530c9f8006f1c97672cdd1a62a4b9c4e0cb61b1..241df901dceb60535d108bc2d34e36195a911c23 100644 (file)
@@ -1,9 +1,9 @@
 from django.test import TestCase
 
-from documents.tests.factories import CorrespondentFactory
-from documents.tests.factories import DocumentFactory
 from paperless.models import Correspondent
 from paperless.models import Document
+from paperless.tests.factories import CorrespondentFactory
+from paperless.tests.factories import DocumentFactory
 
 
 class CorrespondentTestCase(TestCase):
index fe7356947f8c3fd01a7e49776fd39936d00379a6..7b1218989ad110bccba511917f5a7d946dd5cf73 100644 (file)
@@ -178,27 +178,27 @@ class TestCeleryScheduleParsing(TestCase):
                     "options": {"expires": self.MAIL_EXPIRE_TIME},
                 },
                 "Train the classifier": {
-                    "task": "documents.tasks.train_classifier",
+                    "task": "paperless.tasks.train_classifier",
                     "schedule": crontab(minute="5", hour="*/1"),
                     "options": {"expires": self.CLASSIFIER_EXPIRE_TIME},
                 },
                 "Optimize the index": {
-                    "task": "documents.tasks.index_optimize",
+                    "task": "paperless.tasks.index_optimize",
                     "schedule": crontab(minute=0, hour=0),
                     "options": {"expires": self.INDEX_EXPIRE_TIME},
                 },
                 "Perform sanity check": {
-                    "task": "documents.tasks.sanity_check",
+                    "task": "paperless.tasks.sanity_check",
                     "schedule": crontab(minute=30, hour=0, day_of_week="sun"),
                     "options": {"expires": self.SANITY_EXPIRE_TIME},
                 },
                 "Empty trash": {
-                    "task": "documents.tasks.empty_trash",
+                    "task": "paperless.tasks.empty_trash",
                     "schedule": crontab(minute=0, hour="1"),
                     "options": {"expires": self.EMPTY_TRASH_EXPIRE_TIME},
                 },
                 "Check and run scheduled workflows": {
-                    "task": "documents.tasks.check_scheduled_workflows",
+                    "task": "paperless.tasks.check_scheduled_workflows",
                     "schedule": crontab(minute="5", hour="*/1"),
                     "options": {"expires": self.RUN_SCHEDULED_WORKFLOWS_EXPIRE_TIME},
                 },
@@ -230,27 +230,27 @@ class TestCeleryScheduleParsing(TestCase):
                     "options": {"expires": self.MAIL_EXPIRE_TIME},
                 },
                 "Train the classifier": {
-                    "task": "documents.tasks.train_classifier",
+                    "task": "paperless.tasks.train_classifier",
                     "schedule": crontab(minute="5", hour="*/1"),
                     "options": {"expires": self.CLASSIFIER_EXPIRE_TIME},
                 },
                 "Optimize the index": {
-                    "task": "documents.tasks.index_optimize",
+                    "task": "paperless.tasks.index_optimize",
                     "schedule": crontab(minute=0, hour=0),
                     "options": {"expires": self.INDEX_EXPIRE_TIME},
                 },
                 "Perform sanity check": {
-                    "task": "documents.tasks.sanity_check",
+                    "task": "paperless.tasks.sanity_check",
                     "schedule": crontab(minute=30, hour=0, day_of_week="sun"),
                     "options": {"expires": self.SANITY_EXPIRE_TIME},
                 },
                 "Empty trash": {
-                    "task": "documents.tasks.empty_trash",
+                    "task": "paperless.tasks.empty_trash",
                     "schedule": crontab(minute=0, hour="1"),
                     "options": {"expires": self.EMPTY_TRASH_EXPIRE_TIME},
                 },
                 "Check and run scheduled workflows": {
-                    "task": "documents.tasks.check_scheduled_workflows",
+                    "task": "paperless.tasks.check_scheduled_workflows",
                     "schedule": crontab(minute="5", hour="*/1"),
                     "options": {"expires": self.RUN_SCHEDULED_WORKFLOWS_EXPIRE_TIME},
                 },
@@ -279,22 +279,22 @@ class TestCeleryScheduleParsing(TestCase):
                     "options": {"expires": self.MAIL_EXPIRE_TIME},
                 },
                 "Train the classifier": {
-                    "task": "documents.tasks.train_classifier",
+                    "task": "paperless.tasks.train_classifier",
                     "schedule": crontab(minute="5", hour="*/1"),
                     "options": {"expires": self.CLASSIFIER_EXPIRE_TIME},
                 },
                 "Perform sanity check": {
-                    "task": "documents.tasks.sanity_check",
+                    "task": "paperless.tasks.sanity_check",
                     "schedule": crontab(minute=30, hour=0, day_of_week="sun"),
                     "options": {"expires": self.SANITY_EXPIRE_TIME},
                 },
                 "Empty trash": {
-                    "task": "documents.tasks.empty_trash",
+                    "task": "paperless.tasks.empty_trash",
                     "schedule": crontab(minute=0, hour="1"),
                     "options": {"expires": self.EMPTY_TRASH_EXPIRE_TIME},
                 },
                 "Check and run scheduled workflows": {
-                    "task": "documents.tasks.check_scheduled_workflows",
+                    "task": "paperless.tasks.check_scheduled_workflows",
                     "schedule": crontab(minute="5", hour="*/1"),
                     "options": {"expires": self.RUN_SCHEDULED_WORKFLOWS_EXPIRE_TIME},
                 },
index 1ec578d82b9e14ff9e5fb6eb5d624bc028cabce5..5aaab2dafd0e11e4fbf81b0bce22542947a8d25a 100644 (file)
@@ -4,7 +4,6 @@ from unittest import mock
 import celery
 from django.test import TestCase
 
-from documents.tests.test_consumer import fake_magic_from_file
 from paperless.data_models import ConsumableDocument
 from paperless.data_models import DocumentMetadataOverrides
 from paperless.data_models import DocumentSource
@@ -13,6 +12,7 @@ from paperless.signals.handlers import before_task_publish_handler
 from paperless.signals.handlers import task_failure_handler
 from paperless.signals.handlers import task_postrun_handler
 from paperless.signals.handlers import task_prerun_handler
+from paperless.tests.test_consumer import fake_magic_from_file
 from paperless.tests.utils import DirectoriesMixin
 
 
@@ -40,7 +40,7 @@ class TestTaskSignalHandler(DirectoriesMixin, TestCase):
         """
         headers = {
             "id": str(uuid.uuid4()),
-            "task": "documents.tasks.consume_file",
+            "task": "paperless.tasks.consume_file",
         }
         body = (
             # args
@@ -84,7 +84,7 @@ class TestTaskSignalHandler(DirectoriesMixin, TestCase):
 
         headers = {
             "id": str(uuid.uuid4()),
-            "task": "documents.tasks.consume_file",
+            "task": "paperless.tasks.consume_file",
         }
         body = (
             # args
@@ -123,7 +123,7 @@ class TestTaskSignalHandler(DirectoriesMixin, TestCase):
         """
         headers = {
             "id": str(uuid.uuid4()),
-            "task": "documents.tasks.consume_file",
+            "task": "paperless.tasks.consume_file",
         }
         body = (
             # args
@@ -165,7 +165,7 @@ class TestTaskSignalHandler(DirectoriesMixin, TestCase):
         """
         headers = {
             "id": str(uuid.uuid4()),
-            "task": "documents.tasks.consume_file",
+            "task": "paperless.tasks.consume_file",
         }
         body = (
             # args
index 4130d71eceaa7ec7525cc22a0aee6933c051ac4c..7f6da9746b2c74f33918e53a4f2ff695b6e8c5c6 100644 (file)
@@ -7,7 +7,6 @@ from django.conf import settings
 from django.test import TestCase
 from django.utils import timezone
 
-from documents.tests.test_classifier import dummy_preprocess
 from paperless import tasks
 from paperless.models import Correspondent
 from paperless.models import Document
@@ -15,6 +14,7 @@ from paperless.models import DocumentType
 from paperless.models import Tag
 from paperless.sanity_checker import SanityCheckFailedException
 from paperless.sanity_checker import SanityCheckMessages
+from paperless.tests.test_classifier import dummy_preprocess
 from paperless.tests.utils import DirectoriesMixin
 from paperless.tests.utils import FileSystemAssertsMixin
 
@@ -46,12 +46,12 @@ class TestIndexReindex(DirectoriesMixin, TestCase):
 
 
 class TestClassifier(DirectoriesMixin, FileSystemAssertsMixin, TestCase):
-    @mock.patch("documents.tasks.load_classifier")
+    @mock.patch("paperless.tasks.load_classifier")
     def test_train_classifier_no_auto_matching(self, load_classifier):
         tasks.train_classifier()
         load_classifier.assert_not_called()
 
-    @mock.patch("documents.tasks.load_classifier")
+    @mock.patch("paperless.tasks.load_classifier")
     def test_train_classifier_with_auto_tag(self, load_classifier):
         load_classifier.return_value = None
         Tag.objects.create(matching_algorithm=Tag.MATCH_AUTO, name="test")
@@ -59,7 +59,7 @@ class TestClassifier(DirectoriesMixin, FileSystemAssertsMixin, TestCase):
         load_classifier.assert_called_once()
         self.assertIsNotFile(settings.MODEL_FILE)
 
-    @mock.patch("documents.tasks.load_classifier")
+    @mock.patch("paperless.tasks.load_classifier")
     def test_train_classifier_with_auto_type(self, load_classifier):
         load_classifier.return_value = None
         DocumentType.objects.create(matching_algorithm=Tag.MATCH_AUTO, name="test")
@@ -67,7 +67,7 @@ class TestClassifier(DirectoriesMixin, FileSystemAssertsMixin, TestCase):
         load_classifier.assert_called_once()
         self.assertIsNotFile(settings.MODEL_FILE)
 
-    @mock.patch("documents.tasks.load_classifier")
+    @mock.patch("paperless.tasks.load_classifier")
     def test_train_classifier_with_auto_correspondent(self, load_classifier):
         load_classifier.return_value = None
         Correspondent.objects.create(matching_algorithm=Tag.MATCH_AUTO, name="test")
@@ -103,13 +103,13 @@ class TestClassifier(DirectoriesMixin, FileSystemAssertsMixin, TestCase):
 
 
 class TestSanityCheck(DirectoriesMixin, TestCase):
-    @mock.patch("documents.tasks.sanity_checker.check_sanity")
+    @mock.patch("paperless.tasks.sanity_checker.check_sanity")
     def test_sanity_check_success(self, m):
         m.return_value = SanityCheckMessages()
         self.assertEqual(tasks.sanity_check(), "No issues detected.")
         m.assert_called_once()
 
-    @mock.patch("documents.tasks.sanity_checker.check_sanity")
+    @mock.patch("paperless.tasks.sanity_checker.check_sanity")
     def test_sanity_check_error(self, m):
         messages = SanityCheckMessages()
         messages.error(None, "Some error")
@@ -117,7 +117,7 @@ class TestSanityCheck(DirectoriesMixin, TestCase):
         self.assertRaises(SanityCheckFailedException, tasks.sanity_check)
         m.assert_called_once()
 
-    @mock.patch("documents.tasks.sanity_checker.check_sanity")
+    @mock.patch("paperless.tasks.sanity_checker.check_sanity")
     def test_sanity_check_error_no_raise(self, m):
         messages = SanityCheckMessages()
         messages.error(None, "Some error")
@@ -130,7 +130,7 @@ class TestSanityCheck(DirectoriesMixin, TestCase):
         )
         m.assert_called_once()
 
-    @mock.patch("documents.tasks.sanity_checker.check_sanity")
+    @mock.patch("paperless.tasks.sanity_checker.check_sanity")
     def test_sanity_check_warning(self, m):
         messages = SanityCheckMessages()
         messages.warning(None, "Some warning")
@@ -141,7 +141,7 @@ class TestSanityCheck(DirectoriesMixin, TestCase):
         )
         m.assert_called_once()
 
-    @mock.patch("documents.tasks.sanity_checker.check_sanity")
+    @mock.patch("paperless.tasks.sanity_checker.check_sanity")
     def test_sanity_check_info(self, m):
         messages = SanityCheckMessages()
         messages.info(None, "Some info")
index 2ad9064fb809df6d528b7e1cb4c53512cf83d915..8d3604f2c864300b5ef291941b7d09891d878bdb 100644 (file)
@@ -154,7 +154,7 @@ class TestWorkflows(
             self.dirs.scratch_dir / "simple.pdf",
         )
 
-        with mock.patch("documents.tasks.ProgressManager", DummyProgressManager):
+        with mock.patch("paperless.tasks.ProgressManager", DummyProgressManager):
             with self.assertLogs("paperless.matching", level="INFO") as cm:
                 tasks.consume_file(
                     ConsumableDocument(
@@ -265,7 +265,7 @@ class TestWorkflows(
             self.dirs.scratch_dir / "simple.pdf",
         )
 
-        with mock.patch("documents.tasks.ProgressManager", DummyProgressManager):
+        with mock.patch("paperless.tasks.ProgressManager", DummyProgressManager):
             with self.assertLogs("paperless.matching", level="INFO") as cm:
                 tasks.consume_file(
                     ConsumableDocument(
@@ -383,7 +383,7 @@ class TestWorkflows(
             self.dirs.scratch_dir / "simple.pdf",
         )
 
-        with mock.patch("documents.tasks.ProgressManager", DummyProgressManager):
+        with mock.patch("paperless.tasks.ProgressManager", DummyProgressManager):
             with self.assertLogs("paperless.matching", level="INFO") as cm:
                 tasks.consume_file(
                     ConsumableDocument(
@@ -451,7 +451,7 @@ class TestWorkflows(
             self.dirs.scratch_dir / "simple.pdf",
         )
 
-        with mock.patch("documents.tasks.ProgressManager", DummyProgressManager):
+        with mock.patch("paperless.tasks.ProgressManager", DummyProgressManager):
             with self.assertLogs("paperless.matching", level="DEBUG") as cm:
                 tasks.consume_file(
                     ConsumableDocument(
@@ -503,7 +503,7 @@ class TestWorkflows(
             self.dirs.scratch_dir / "simple.pdf",
         )
 
-        with mock.patch("documents.tasks.ProgressManager", DummyProgressManager):
+        with mock.patch("paperless.tasks.ProgressManager", DummyProgressManager):
             with self.assertLogs("paperless.matching", level="DEBUG") as cm:
                 tasks.consume_file(
                     ConsumableDocument(
@@ -577,7 +577,7 @@ class TestWorkflows(
             self.dirs.scratch_dir / "simple.pdf",
         )
 
-        with mock.patch("documents.tasks.ProgressManager", DummyProgressManager):
+        with mock.patch("paperless.tasks.ProgressManager", DummyProgressManager):
             with self.assertLogs("paperless.matching", level="DEBUG") as cm:
                 tasks.consume_file(
                     ConsumableDocument(
@@ -661,7 +661,7 @@ class TestWorkflows(
             self.dirs.scratch_dir / "simple.pdf",
         )
 
-        with mock.patch("documents.tasks.ProgressManager", DummyProgressManager):
+        with mock.patch("paperless.tasks.ProgressManager", DummyProgressManager):
             with self.assertLogs("paperless.matching", level="DEBUG") as cm:
                 tasks.consume_file(
                     ConsumableDocument(
@@ -746,7 +746,7 @@ class TestWorkflows(
             self.dirs.scratch_dir / "simple.pdf",
         )
 
-        with mock.patch("documents.tasks.ProgressManager", DummyProgressManager):
+        with mock.patch("paperless.tasks.ProgressManager", DummyProgressManager):
             with self.assertLogs("paperless.matching", level="DEBUG") as cm:
                 tasks.consume_file(
                     ConsumableDocument(
@@ -864,7 +864,7 @@ class TestWorkflows(
             self.dirs.scratch_dir / "simple.pdf",
         )
 
-        with mock.patch("documents.tasks.ProgressManager", DummyProgressManager):
+        with mock.patch("paperless.tasks.ProgressManager", DummyProgressManager):
             with self.assertLogs("paperless.matching", level="INFO") as cm:
                 tasks.consume_file(
                     ConsumableDocument(
@@ -1875,7 +1875,7 @@ class TestWorkflows(
             self.dirs.scratch_dir / "simple.pdf",
         )
 
-        with mock.patch("documents.tasks.ProgressManager", DummyProgressManager):
+        with mock.patch("paperless.tasks.ProgressManager", DummyProgressManager):
             with self.assertLogs("paperless.matching", level="INFO") as cm:
                 tasks.consume_file(
                     ConsumableDocument(
@@ -1998,7 +1998,7 @@ class TestWorkflows(
             self.dirs.scratch_dir / "simple.pdf",
         )
 
-        with mock.patch("documents.tasks.ProgressManager", DummyProgressManager):
+        with mock.patch("paperless.tasks.ProgressManager", DummyProgressManager):
             with self.assertLogs("paperless.matching", level="INFO") as cm:
                 tasks.consume_file(
                     ConsumableDocument(
@@ -2369,7 +2369,7 @@ class TestWorkflows(
             self.dirs.scratch_dir / "simple.pdf",
         )
 
-        with mock.patch("documents.tasks.ProgressManager", DummyProgressManager):
+        with mock.patch("paperless.tasks.ProgressManager", DummyProgressManager):
             with self.assertLogs("paperless.matching", level="INFO"):
                 tasks.consume_file(
                     ConsumableDocument(
@@ -2690,7 +2690,7 @@ class TestWorkflows(
             self.dirs.scratch_dir / "simple.pdf",
         )
 
-        with mock.patch("documents.tasks.ProgressManager", DummyProgressManager):
+        with mock.patch("paperless.tasks.ProgressManager", DummyProgressManager):
             with self.assertLogs("paperless.matching", level="INFO"):
                 tasks.consume_file(
                     ConsumableDocument(
index 581a553b3b1e87de10a5a9314b9c482713deaf4d..9c2e52f4f5c055a4fb3b4ce6ee78be3f7f4b6765 100644 (file)
@@ -230,7 +230,7 @@ class DocumentConsumeDelayMixin:
     """
 
     def setUp(self) -> None:
-        self.consume_file_patcher = mock.patch("documents.tasks.consume_file.delay")
+        self.consume_file_patcher = mock.patch("paperless.tasks.consume_file.delay")
         self.consume_file_mock = self.consume_file_patcher.start()
         super().setUp()
 
@@ -368,7 +368,7 @@ class DummyProgressManager:
     connect to Redis.  Payloads are stored for test assertions if needed.
 
     Use it with
-      mock.patch("documents.tasks.ProgressManager", DummyProgressManager)
+      mock.patch("paperless.tasks.ProgressManager", DummyProgressManager)
     """
 
     def __init__(self, filename: str, task_id: str | None = None) -> None: