A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
Chore: Fixes the TO filter chaining so it doesn't reset the messages list + deterministic UIDs (#11987)
Trenton H276dc13e3fc3
diff --git a/src/paperless_mail/tests/test_mail.py b/src/paperless_mail/tests/test_mail.pyindex 305c2854c..51a1929ab 100644--- a/src/paperless_mail/tests/test_mail.py+++ b/src/paperless_mail/tests/test_mail.py@@ -1,6 +1,5 @@import dataclassesimport email.contentmanager-import randomimport timeimport uuidfrom collections import namedtuple@@ -148,11 +147,7 @@ class BogusMailBox(AbstractContextManager):if "TO" in criteria:to_ = criteria[criteria.index("TO") + 1].strip('"')- msg = []- for m in self.messages:- for to_addrs in m.to:- if to_ in to_addrs:- msg.append(m)+ msg = filter(lambda m: any(to_ in to_addr for to_addr in m.to), msg)if "UNFLAGGED" in criteria:msg = filter(lambda m: not m.flagged, msg)@@ -204,7 +199,7 @@ def fake_magic_from_buffer(buffer, *, mime=False):class MessageBuilder:def __init__(self) -> None:- self._used_uids = set()+ self._next_uid = 1def create_message(self,@@ -257,10 +252,8 @@ class MessageBuilder:# TODO: Unsure how to add a uid to the actual EmailMessage. This hacks it in,# based on how imap_tools uses regex to extract it.# This should be a large enough pool- uid = random.randint(1, 10000)- while uid in self._used_uids:- uid = random.randint(1, 10000)- self._used_uids.add(uid)+ uid = self._next_uid+ self._next_uid += 1imap_msg._raw_uid_data = f"UID {uid}".encode()