From 5c71ef6e493858577836fe28f35277678fc819de Mon Sep 17 00:00:00 2001 From: Xubin Ren <52506698+Re-bin@users.noreply.github.com> Date: Sun, 30 Aug 2026 17:32:27 +0800 Subject: [PATCH] test(email): assert header-first fetch contract --- nanobot/channels/email/tests/test_email_channel.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nanobot/channels/email/tests/test_email_channel.py b/nanobot/channels/email/tests/test_email_channel.py index 115798a19..c26e53da9 100644 --- a/nanobot/channels/email/tests/test_email_channel.py +++ b/nanobot/channels/email/tests/test_email_channel.py @@ -64,12 +64,17 @@ def test_fetch_new_messages_parses_unseen_and_marks_seen(monkeypatch) -> None: assert items[0]["subject"] == "Invoice" assert "Please pay" in items[0]["content"] assert ("STORE", "123", "+FLAGS", "(\\Seen)") in fake.uid_calls + assert [call for call in fake.uid_calls if call[0] == "FETCH"] == [ + ("FETCH", "123", "(BODY.PEEK[HEADER])"), + ("FETCH", "123", "(BODY.PEEK[])"), + ] assert skipped_uids == set() # Same UID should be deduped in-process. items_again, skipped_again = channel._fetch_new_messages() assert items_again == [] assert skipped_again == set() + assert len([call for call in fake.uid_calls if call[0] == "FETCH"]) == 2 def test_fetch_new_messages_returns_accepted_and_skipped_uids(monkeypatch) -> None: @@ -1192,6 +1197,9 @@ def test_fetch_new_messages_ignores_unauthorized_sender_before_attachments(monke assert channel._fetch_new_messages() == ([], {"500"}) assert called["attachments"] is False + assert [call for call in fake.uid_calls if call[0] == "FETCH"] == [ + ("FETCH", "500", "(BODY.PEEK[HEADER])") + ] assert ("STORE", "500", "+FLAGS", "(\\Seen)") in fake.uid_calls