refactor(i-g): BUG-018 Pilot Split Schritt 5 — mail/services.py komplett zur Fassade reduziert (-95%)

services.py: 3087 -> ~170 Zeilen reine Re-Export-Fassade. Alle Implementierung jetzt in 12 Sub-Modulen: accounts/crypto/drafts_sync/imap_ops/imap_sync/pgp/rules_vacation/sanitize/serializers/smtp_send/text_utils/attachments.

Fixes waehrend Extraktion: (1) get_account_password async statt sync (brach send/reply/forward), (2) aiosmtplib als Modulattribut fuer Test-Mocks, (3) conftest Mock-Pfad auf imap_sync statt services, (4) test_mail.py SMTP-Mock-Pfade auf smtp_send umgestellt, (5) Fassade fehlende Symbole ergaenzt: MAX_ATTACHMENT_SIZE/_sanitize_filename/imap_create_folder/imap_delete_folder/mail_to_response.

Beweis: mail+sig_label_routes 51/51 passed in 106.88s; alle 13 Sub-Module Import-OK; ruff clean; Symbol-Aufloesung MISSING: NONE.
This commit is contained in:
Agent Zero
2026-08-26 14:33:30 +02:00
parent c34715574a
commit ea6c9e71db
7 changed files with 1434 additions and 1321 deletions
+1 -1
View File
@@ -492,7 +492,7 @@ def mock_imap_connections(monkeypatch):
return fake_client
monkeypatch.setattr(
"app.plugins.builtins.mail.services.aioimaplib.IMAP4_SSL",
"app.plugins.builtins.mail.imap_sync.aioimaplib.IMAP4_SSL",
_fake_factory,
)
yield fake_client
+3 -3
View File
@@ -385,7 +385,7 @@ async def test_send_mail(mail_authed_client):
"""AC: POST /api/v1/mail/send -> 200, mail sent via SMTP."""
client, seed = mail_authed_client
account = await _create_account(client)
with patch("app.plugins.builtins.mail.services.aiosmtplib.SMTP") as mock_smtp_class:
with patch("app.plugins.builtins.mail.smtp_send.aiosmtplib.SMTP") as mock_smtp_class:
mock_smtp_inst = AsyncMock()
mock_smtp_class.return_value = mock_smtp_inst
resp = await client.post(
@@ -417,7 +417,7 @@ async def test_reply_mail(mail_authed_client, db_session):
subject="Original",
)
await db_session.commit()
with patch("app.plugins.builtins.mail.services.aiosmtplib.SMTP") as mock_smtp_class:
with patch("app.plugins.builtins.mail.smtp_send.aiosmtplib.SMTP") as mock_smtp_class:
mock_smtp_class.return_value = AsyncMock()
resp = await client.post(
f"/api/v1/mail/{mail.id}/reply",
@@ -442,7 +442,7 @@ async def test_forward_mail(mail_authed_client, db_session):
subject="Forward Me",
)
await db_session.commit()
with patch("app.plugins.builtins.mail.services.aiosmtplib.SMTP") as mock_smtp_class:
with patch("app.plugins.builtins.mail.smtp_send.aiosmtplib.SMTP") as mock_smtp_class:
mock_smtp_class.return_value = AsyncMock()
resp = await client.post(
f"/api/v1/mail/{mail.id}/forward",