Files
group_fqcd_jr/tests/unit/service/test_offsite_mail_query.py
T

37 lines
1.1 KiB
Python
Raw Normal View History

2026-09-11 16:57:47 +08:00
from pathlib import Path
from app.service.offsite_fund_service import OffsiteFundService
def test_parse_eml_returns_mailbox_fields(tmp_path: Path) -> None:
eml_path = tmp_path / "message.eml"
eml_path.write_bytes(
b"From: sender@example.com\r\n"
b"To: mailbox@example.com\r\n"
b"Subject: Fund application\r\n"
b"Date: Fri, 11 Sep 2026 09:30:00 +0800\r\n"
b"MIME-Version: 1.0\r\n"
b"Content-Type: text/plain; charset=utf-8\r\n"
b"\r\n"
b"Please review the fund application.\r\n"
)
result = OffsiteFundService._parse_eml(str(eml_path))
assert result["subject"] == "Fund application"
assert result["sent_at"] == "2026-09-11T09:30:00+08:00"
assert result["has_body"] is True
assert result["body_text"] == "Please review the fund application.\r\n"
def test_parse_eml_missing_file_returns_empty_content() -> None:
result = OffsiteFundService._parse_eml("missing/message.eml")
assert result == {
"subject": None,
"sent_at": None,
"has_body": False,
"body_text": None,
"body_html": None,
}