Status: PASSED 2026-03-16
Tests count_attachments() in scan_attachments.py with fabricated MIME messages. No live IMAP needed.
Extracted the counting logic from scan_attachments() into a new count_attachments(raw_messages) function that returns (summary, filenames, total_emails, total_with_attachments). scan_attachments() now fetches raw bytes from IMAP and passes them to count_attachments(), then prints the results. The __main__ block is unchanged.
PASS — all 4 cases passed
1. Single PDF attachment → summary['application/pdf'] == 1, filename recorded correctly.
2. Plain email, no attachments → total_with_attachments == 0, summary empty.
3. Inline image (Content-Disposition: inline) → NOT counted. total_with_attachments == 0.
4. Two attachments in one email → total_with_attachments == 2, both filenames recorded.
cd ~/py/envoy && python3 test_scan_attachments.py