A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Revert all changes to tests, will need a more structured approach.
Oliver Rümpelein104a68451477
diff --git a/src/paperless_mail/tests/test_mail.py b/src/paperless_mail/tests/test_mail.pyindex b275be360..24014b4dc 100644--- a/src/paperless_mail/tests/test_mail.py+++ b/src/paperless_mail/tests/test_mail.py@@ -4,7 +4,7 @@ import osimport randomimport uuidfrom collections import namedtuple-from typing import ContextManager, Callable+from typing import ContextManagerfrom typing import Listfrom typing import Unionfrom unittest import mock@@ -96,18 +96,6 @@ class BogusMailBox(ContextManager):if "UNFLAGGED" in criteria:msg = filter(lambda m: not m.flagged, msg)- if "NO_KEYWORD" in criteria:- tag: str = criteria[criteria.index("NO_KEYWORD") + 1].strip('"')- print(f"selected tag is {tag}.")- for m in msg:- print(f"Message with id {m.uid} has tags {','.join(m.flags)}")- msg = filter(lambda m: tag not in m.flags, msg)-- if "KEYWORD" in criteria:- tag = criteria[criteria.index("KEYWORD") + 1].strip('"')- print(f"selected tag is {tag}.")- msg = filter(lambda m: tag in m.flags, msg)-return list(msg)def delete(self, uid_list):@@ -142,7 +130,6 @@ def create_message(from_: str = "[email protected]",seen: bool = False,flagged: bool = False,- processed: bool = False,) -> MailMessage:email_msg = email.message.EmailMessage()# TODO: This does NOT set the UID@@ -189,10 +176,6 @@ def create_message(imap_msg.seen = seenimap_msg.flagged = flagged- # Allows to test for both unset tags, and explicitly 'false' ones.- if processed:- imap_msg._raw_flag_data.append("+FLAGS (processed)".encode())-return imap_msg@@ -242,7 +225,6 @@ class TestMail(DirectoriesMixin, TestCase):body="from my favorite electronic store",seen=False,flagged=True,- processed=True),)self.bogus_mailbox.messages.append(@@ -589,29 +571,6 @@ class TestMail(DirectoriesMixin, TestCase):self.assertEqual(len(self.bogus_mailbox.messages), 2)self.assertEqual(len(self.bogus_mailbox.messages_spam), 1)- def test_handle_mail_account_tag(self):- account = MailAccount.objects.create(- name="test",- imap_server="",- username="admin",- password="secret",- )-- _ = MailRule.objects.create(- name="testrule",- account=account,- action=MailRule.MailAction.TAG,- action_parameter="processed",- )-- self.assertEqual(len(self.bogus_mailbox.messages), 3)- self.assertEqual(self.async_task.call_count, 0)- self.assertEqual(len(self.bogus_mailbox.fetch("NO_KEYWORD processed", False)), 2)- self.mail_account_handler.handle_mail_account(account)- self.assertEqual(self.async_task.call_count, 2)- self.assertEqual(len(self.bogus_mailbox.fetch("NO_KEYWORD processed", False)), 0)- self.assertEqual(len(self.bogus_mailbox.messages), 3)-def test_error_login(self):account = MailAccount.objects.create(name="test",