first commit

This commit is contained in:
debu-2 2026-10-03 21:14:44 +05:30
commit cce9a8c9ba
73 changed files with 8665 additions and 0 deletions

View file

@ -0,0 +1,28 @@
from app.services.mime_parser import parse_mime
def test_parse_mime_extracts_fallback_sender_bodies_and_attachments():
raw = (
b"From: sender@example.com\r\n"
b"To: User <user@getall.help>\r\n"
b"Subject: Production test\r\n"
b"Message-ID: <one@example.com>\r\n"
b"MIME-Version: 1.0\r\n"
b'Content-Type: multipart/mixed; boundary="b"\r\n\r\n'
b"--b\r\nContent-Type: text/plain; charset=utf-8\r\n\r\nHello world\r\n"
b"--b\r\nContent-Type: application/octet-stream\r\n"
b'Content-Disposition: attachment; filename="sample.bin"\r\n\r\nabc\r\n'
b"--b--\r\n"
)
parsed = parse_mime(raw)
assert parsed["sender"] == {
"name": "sender",
"address": "sender@example.com",
}
assert parsed["subject"] == "Production test"
assert parsed["snippet"] == "Hello world"
assert parsed["body_text"] == "Hello world"
assert parsed["attachments"][0]["filename"] == "sample.bin"
assert parsed["attachments"][0]["size"] == 3