Status: PASSED 2026-03-16
Tests parse_email_message() in orchestrator.py (line ~159) in isolation. No live IMAP needed — builds raw MIME bytes directly with email.mime.*.
[2026-03-16 12:39:36] INFO Parsed continuation email: Test (iteration 2, total 5)
[2026-03-16 12:39:36] INFO Parsed email: Test from sender@example.com (Message-ID: <test@example.com>)
[2026-03-16 12:39:36] INFO Parsed email: Test from sender@example.com (Message-ID: <test@example.com>)
[2026-03-16 12:39:36] INFO Parsed email: Simple from a@b.com (Message-ID: <simple@test>)
[2026-03-16 12:39:36] INFO Parsed continuation email: Test (iteration 4, total 9)
PASS — all 5 cases passed
1. Happy path — valid continuation attachment
Build a multipart email with a text/plain body and an application/json attachment containing {"type": "continuation", "iteration": 2, ...}. Assert parsed['continuation'] is populated and all fields present.
2. Non-continuation JSON
Attach JSON where type is set to something else. Assert parsed.get('continuation') is absent and body parses normally.
3. Malformed JSON attachment
Attach a file with application/json content type but invalid JSON bytes. Assert no exception is raised and continuation is absent.
4. Plain single-part email
Non-multipart message. Assert body is extracted correctly and continuation is absent.
5. Multiple attachments — PDF + continuation JSON
PDF attachment alongside a continuation JSON part. Assert continuation is set correctly and no exception from the binary part.
cd ~/py/envoy && python3 test_parse_email_message.py
All 5 cases pass without exception. continuation is only set when a valid continuation-typed JSON attachment is present.