Skip to content

Your lightweight open-source personal agent.

test(email): cover progress message suppression

chengyongru3b4638688763
diff --git a/tests/channels/test_email_channel.py b/tests/channels/test_email_channel.py
index 2ee915d9e..f6af636ed 100644
--- a/tests/channels/test_email_channel.py
+++ b/tests/channels/test_email_channel.py
@@ -395,6 +395,33 @@ async def test_send_uses_smtp_and_reply_subject(monkeypatch) -> None:
assert sent["In-Reply-To"] == "<[email protected]>"
+async def test_send_skips_progress_messages_before_smtp(monkeypatch) -> None:
+ called = {"smtp": False}
+
+ def _smtp_factory(*_args, **_kwargs):
+ called["smtp"] = True
+ raise AssertionError("progress messages must not open an SMTP connection")
+
+ monkeypatch.setattr("nanobot.channels.email.smtplib.SMTP", _smtp_factory)
+
+ channel = EmailChannel(_make_config(), MessageBus())
+
+ await channel.send(
+ OutboundMessage(
+ channel="email",
+ chat_id="[email protected]",
+ content="",
+ metadata={
+ "_progress": True,
+ "_tool_events": [{"phase": "end", "name": "exec"}],
+ },
+ )
+ )
+
+ assert called["smtp"] is False
+
+
@pytest.mark.asyncio
async def test_send_skips_reply_when_auto_reply_disabled(monkeypatch) -> None:
"""When auto_reply_enabled=False, replies should be skipped but proactive sends allowed."""