fix: restore missing forward_email signature and reformat with black

Agent-Logs-Url: https://github.com/christianlouis/InboxConverge/sessions/3c4ae596-6052-4a61-9edd-b668a6cda32e

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-04-07 10:38:00 +00:00
committed by GitHub
parent ff7b50d944
commit 3dd71cd61d
3 changed files with 27 additions and 27 deletions
+4 -7
View File
@@ -432,9 +432,7 @@ class MailProcessor:
return emails, new_uids return emails, new_uids
async def post_process_imap( async def post_process_imap(self, successfully_forwarded_uids: List[str]) -> None:
self, successfully_forwarded_uids: List[str]
) -> None:
"""Mark successfully forwarded IMAP messages as \\Seen and optionally delete. """Mark successfully forwarded IMAP messages as \\Seen and optionally delete.
Because fetch uses ``BODY.PEEK[]`` (which does NOT set \\Seen), this Because fetch uses ``BODY.PEEK[]`` (which does NOT set \\Seen), this
@@ -485,9 +483,7 @@ class MailProcessor:
except Exception: except Exception:
pass pass
async def post_process_pop3( async def post_process_pop3(self, successfully_forwarded_uids: List[str]) -> None:
self, successfully_forwarded_uids: List[str]
) -> None:
"""Delete successfully forwarded POP3 messages from the source mailbox. """Delete successfully forwarded POP3 messages from the source mailbox.
Opens a fresh POP3 session, maps stable UIDs back to current message Opens a fresh POP3 session, maps stable UIDs back to current message
@@ -569,7 +565,8 @@ class MailProcessor:
else: else:
await self.post_process_imap(successfully_forwarded_uids) await self.post_process_imap(successfully_forwarded_uids)
@staticmethod
async def forward_email(
email_data: bytes, email_data: bytes,
source_account_name: str, source_account_name: str,
destination: str, destination: str,
+23 -17
View File
@@ -814,12 +814,13 @@ class TestPostProcessImap:
mock_imap.uid = AsyncMock(return_value=_make_imap_response()) mock_imap.uid = AsyncMock(return_value=_make_imap_response())
mock_imap.logout = AsyncMock() mock_imap.logout = AsyncMock()
with patch( with (
"app.services.mail_processor.aioimaplib.IMAP4", patch(
return_value=mock_imap, "app.services.mail_processor.aioimaplib.IMAP4",
) as mock_cls, patch( return_value=mock_imap,
"app.services.mail_processor.aioimaplib.IMAP4_SSL" ) as mock_cls,
) as mock_ssl_cls: patch("app.services.mail_processor.aioimaplib.IMAP4_SSL") as mock_ssl_cls,
):
await processor.post_process_imap(["1"]) await processor.post_process_imap(["1"])
mock_cls.assert_called_once() mock_cls.assert_called_once()
mock_ssl_cls.assert_not_called() mock_ssl_cls.assert_not_called()
@@ -852,11 +853,14 @@ class TestPostProcessMessages:
account = _make_account(protocol="imap_ssl") account = _make_account(protocol="imap_ssl")
processor = MailProcessor(account=account, decrypted_password="pw") processor = MailProcessor(account=account, decrypted_password="pw")
with patch.object( with (
processor, "post_process_imap", new_callable=AsyncMock patch.object(
) as mock_imap, patch.object( processor, "post_process_imap", new_callable=AsyncMock
processor, "post_process_pop3", new_callable=AsyncMock ) as mock_imap,
) as mock_pop3: patch.object(
processor, "post_process_pop3", new_callable=AsyncMock
) as mock_pop3,
):
await processor.post_process_messages(["1", "2"]) await processor.post_process_messages(["1", "2"])
mock_imap.assert_awaited_once_with(["1", "2"]) mock_imap.assert_awaited_once_with(["1", "2"])
mock_pop3.assert_not_awaited() mock_pop3.assert_not_awaited()
@@ -869,12 +873,14 @@ class TestPostProcessMessages:
"app.models.database_models", fromlist=["MailProtocol"] "app.models.database_models", fromlist=["MailProtocol"]
).MailProtocol.POP3_SSL ).MailProtocol.POP3_SSL
processor = MailProcessor(account=account, decrypted_password="pw") processor = MailProcessor(account=account, decrypted_password="pw")
with patch.object( with (
processor, "post_process_pop3", new_callable=AsyncMock patch.object(
) as mock_pop3, patch.object( processor, "post_process_pop3", new_callable=AsyncMock
processor, "post_process_imap", new_callable=AsyncMock ) as mock_pop3,
) as mock_imap: patch.object(
processor, "post_process_imap", new_callable=AsyncMock
) as mock_imap,
):
await processor.post_process_messages(["a"]) await processor.post_process_messages(["a"])
mock_pop3.assert_awaited_once_with(["a"]) mock_pop3.assert_awaited_once_with(["a"])
mock_imap.assert_not_awaited() mock_imap.assert_not_awaited()
@@ -632,9 +632,6 @@ class TestPostProcessPop3:
await proc.post_process_pop3(["uid-a"]) # must not raise await proc.post_process_pop3(["uid-a"]) # must not raise
class TestForwardEmail: class TestForwardEmail:
"""Unit tests for forward_email().""" """Unit tests for forward_email()."""