A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
more tests
jonaswinklerb787983e4243
diff --git a/src/documents/models.py b/src/documents/models.pyindex b544f413d..d81343afa 100755--- a/src/documents/models.py+++ b/src/documents/models.py@@ -221,7 +221,7 @@ class Document(models.Model):else:fname = "{:07}{}".format(self.pk, self.file_type)if self.storage_type == self.STORAGE_TYPE_GPG:- fname += ".gpg"+ fname += ".gpg" # pragma: no coverreturn os.path.join(settings.ORIGINALS_DIR,diff --git a/src/documents/tests/test_sanity_check.py b/src/documents/tests/test_sanity_check.pyindex 725e87617..0554cd7cd 100644--- a/src/documents/tests/test_sanity_check.py+++ b/src/documents/tests/test_sanity_check.py@@ -2,6 +2,8 @@ import osimport shutilfrom pathlib import Path+import filelock+from django.conf import settingsfrom django.test import TestCasefrom documents.models import Document@@ -13,9 +15,11 @@ class TestSanityCheck(DirectoriesMixin, TestCase):def make_test_data(self):- shutil.copy(os.path.join(os.path.dirname(__file__), "samples", "documents", "originals", "0000001.pdf"), os.path.join(self.dirs.originals_dir, "0000001.pdf"))- shutil.copy(os.path.join(os.path.dirname(__file__), "samples", "documents", "archive", "0000001.pdf"), os.path.join(self.dirs.archive_dir, "0000001.pdf"))- shutil.copy(os.path.join(os.path.dirname(__file__), "samples", "documents", "thumbnails", "0000001.png"), os.path.join(self.dirs.thumbnail_dir, "0000001.png"))+ with filelock.FileLock(settings.MEDIA_LOCK):+ # just make sure that the lockfile is present.+ shutil.copy(os.path.join(os.path.dirname(__file__), "samples", "documents", "originals", "0000001.pdf"), os.path.join(self.dirs.originals_dir, "0000001.pdf"))+ shutil.copy(os.path.join(os.path.dirname(__file__), "samples", "documents", "archive", "0000001.pdf"), os.path.join(self.dirs.archive_dir, "0000001.pdf"))+ shutil.copy(os.path.join(os.path.dirname(__file__), "samples", "documents", "thumbnails", "0000001.png"), os.path.join(self.dirs.thumbnail_dir, "0000001.png"))return Document.objects.create(title="test", checksum="42995833e01aea9b3edee44bbfdd7ce1", archive_checksum="62acb0bcbfbcaa62ca6ad3668e4e404b", content="test", pk=1, filename="0000001.pdf", mime_type="application/pdf")diff --git a/src/documents/tests/utils.py b/src/documents/tests/utils.pyindex 7f9d50ed5..dfefc4061 100644--- a/src/documents/tests/utils.py+++ b/src/documents/tests/utils.py@@ -34,7 +34,8 @@ def setup_directories():ARCHIVE_DIR=dirs.archive_dir,CONSUMPTION_DIR=dirs.consumption_dir,INDEX_DIR=dirs.index_dir,- MODEL_FILE=os.path.join(dirs.data_dir, "classification_model.pickle")+ MODEL_FILE=os.path.join(dirs.data_dir, "classification_model.pickle"),+ MEDIA_LOCK=os.path.join(dirs.media_dir, "media.lock"))dirs.settings_override.enable()diff --git a/src/paperless_mail/mail.py b/src/paperless_mail/mail.pyindex a82c34f15..3c200362d 100644--- a/src/paperless_mail/mail.py+++ b/src/paperless_mail/mail.py@@ -26,7 +26,7 @@ class BaseMailAction:return {}def post_consume(self, M, message_uids, parameter):- pass+ pass # pragma: nocoverclass DeleteMailAction(BaseMailAction):@@ -69,7 +69,7 @@ def get_rule_action(rule):elif rule.action == MailRule.ACTION_MARK_READ:return MarkReadMailAction()else:- raise ValueError("Unknown action.")+ raise NotImplementedError("Unknown action.") # pragma: nocoverdef make_criterias(rule):@@ -95,7 +95,7 @@ def get_mailbox(server, port, security):elif security == MailAccount.IMAP_SECURITY_SSL:mailbox = MailBox(server, port)else:- raise ValueError("Unknown IMAP security")+ raise NotImplementedError("Unknown IMAP security") # pragma: nocoverreturn mailbox@@ -119,7 +119,7 @@ class MailAccountHandler(LoggingMixin):return os.path.splitext(os.path.basename(att.filename))[0]else:- raise ValueError("Unknown title selector.")+ raise NotImplementedError("Unknown title selector.") # pragma: nocover # NOQA: E501def get_correspondent(self, message, rule):c_from = rule.assign_correspondent_from@@ -141,7 +141,7 @@ class MailAccountHandler(LoggingMixin):return rule.assign_correspondentelse:- raise ValueError("Unknwown correspondent selector")+ raise NotImplementedError("Unknwown correspondent selector") # pragma: nocover # NOQA: E501def handle_mail_account(self, account):