A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Add test for not moving default thumbnail
Johannes Plunien9946acb1a03e
diff --git a/src/documents/tests/test_management_thumbnails.py b/src/documents/tests/test_management_thumbnails.pyindex 1b9d9f664..9f3ff63c5 100644--- a/src/documents/tests/test_management_thumbnails.py+++ b/src/documents/tests/test_management_thumbnails.py@@ -7,6 +7,7 @@ from django.test import TestCasefrom documents.management.commands.document_thumbnails import _process_documentfrom documents.models import Document+from documents.parsers import get_default_thumbnailfrom documents.tests.utils import DirectoriesMixinfrom documents.tests.utils import FileSystemAssertsMixin@@ -26,9 +27,9 @@ class TestMakeThumbnails(DirectoriesMixin, FileSystemAssertsMixin, TestCase):)self.d2 = Document.objects.create(- checksum="Ass",- title="A",- content="first document",+ checksum="B",+ title="B",+ content="second document",mime_type="application/pdf",filename="test2.pdf",)@@ -37,6 +38,18 @@ class TestMakeThumbnails(DirectoriesMixin, FileSystemAssertsMixin, TestCase):self.d2.source_path,)+ self.d3 = Document.objects.create(+ checksum="C",+ title="C",+ content="third document",+ mime_type="application/pdf",+ filename="test3.pdf",+ )+ shutil.copy(+ os.path.join(os.path.dirname(__file__), "samples", "password-is-test.pdf"),+ self.d3.source_path,+ )+def setUp(self) -> None:super().setUp()self.make_models()@@ -46,6 +59,14 @@ class TestMakeThumbnails(DirectoriesMixin, FileSystemAssertsMixin, TestCase):_process_document(self.d1.id)self.assertIsFile(self.d1.thumbnail_path)+ def test_process_document_password_protected(self):+ self.assertIsFile(get_default_thumbnail())+ self.assertIsNotFile(self.d3.thumbnail_path)+ _process_document(self.d3.id)+ # Ensure default thumbnail is still there+ self.assertIsFile(get_default_thumbnail())+ self.assertIsFile(self.d3.thumbnail_path)+@mock.patch("documents.management.commands.document_thumbnails.shutil.move")def test_process_document_invalid_mime_type(self, m: mock.Mock):self.d1.mime_type = "asdasdasd"