aboutsummaryrefslogtreecommitdiff
path: root/tests/cli/test_mail.py
diff options
context:
space:
mode:
authorDennis Fink2026-11-12 19:57:08 +0100
committerDennis Fink2026-11-12 19:57:08 +0100
commit4bd1d9e348918b2e55db47a1ac3489d035cf55e2 (patch)
treef7ed41a374a8a4136792039a262dc62aa8cf8c59 /tests/cli/test_mail.py
parent7035e9f9467684cccae2b7ff3faaa62e6a9f91aa (diff)
downloadwebmentions-ssg-4bd1d9e348918b2e55db47a1ac3489d035cf55e2.tar.gz
webmentions-ssg-4bd1d9e348918b2e55db47a1ac3489d035cf55e2.zip
refactor(core): split modules by responsibility
Break up monolithic views, task helpers, networking, CLI, and application extension setup so each module owns a focused concern. Reorganize the test suite around the new boundaries while preserving existing Webmention behavior and coverage.
Diffstat (limited to '')
-rw-r--r--tests/cli/test_mail.py77
1 files changed, 0 insertions, 77 deletions
diff --git a/tests/cli/test_mail.py b/tests/cli/test_mail.py
deleted file mode 100644
index 0a2afce..0000000
--- a/tests/cli/test_mail.py
+++ /dev/null
@@ -1,77 +0,0 @@
-# SPDX-FileCopyrightText: 2026 Dennis Fink <me+coding@dennisfink.me>
-#
-# SPDX-License-Identifier: BSD-3-Clause
-
-from unittest.mock import patch
-
-from flask import Flask
-
-
-def test_mail_cli_sends_to_configured_notification_email(app: Flask) -> None:
- app.config.update(
- NOTIFICATION_EMAIL="owner@example.com", MAIL_DEFAULT_SENDER="sender@example.com"
- )
-
- with patch("webmentions_ssg.MAIL.send") as send:
- result = app.test_cli_runner().invoke(args=["mail", "test"])
-
- assert result.exit_code == 0, result.output
- send.assert_called_once()
- message = send.call_args.args[0]
- assert message.sender == "sender@example.com"
- assert message.recipients == ["owner@example.com"]
- assert "test email" in message.subject.lower()
- assert "outgoing mail configuration" in message.body
- assert "Test email sent to owner@example.com." in result.output
-
-
-def test_mail_cli_overrides_configured_recipient(app: Flask) -> None:
- app.config.update(
- NOTIFICATION_EMAIL="owner@example.com", MAIL_DEFAULT_SENDER="sender@example.com"
- )
-
- with patch("webmentions_ssg.MAIL.send") as send:
- result = app.test_cli_runner().invoke(
- args=["mail", "test", "--to", "other@example.com"]
- )
-
- assert result.exit_code == 0, result.output
- send.assert_called_once()
- assert send.call_args.args[0].recipients == ["other@example.com"]
-
-
-def test_mail_cli_requires_recipient(app: Flask) -> None:
- app.config.update(NOTIFICATION_EMAIL=None, MAIL_DEFAULT_SENDER="sender@example.com")
-
- with patch("webmentions_ssg.MAIL.send") as send:
- result = app.test_cli_runner().invoke(args=["mail", "test"])
-
- assert result.exit_code != 0
- assert "Set NOTIFICATION_EMAIL or pass --to" in result.output
- send.assert_not_called()
-
-
-def test_mail_cli_requires_default_sender(app: Flask) -> None:
- app.config.update(NOTIFICATION_EMAIL="owner@example.com", MAIL_DEFAULT_SENDER=None)
-
- with patch("webmentions_ssg.MAIL.send") as send:
- result = app.test_cli_runner().invoke(args=["mail", "test"])
-
- assert result.exit_code != 0
- assert "MAIL_DEFAULT_SENDER is not configured" in result.output
- send.assert_not_called()
-
-
-def test_mail_cli_reports_smtp_failure(app: Flask) -> None:
- app.config.update(
- NOTIFICATION_EMAIL="owner@example.com", MAIL_DEFAULT_SENDER="sender@example.com"
- )
-
- with patch(
- "webmentions_ssg.MAIL.send", side_effect=ConnectionError("SMTP unavailable")
- ) as send:
- result = app.test_cli_runner().invoke(args=["mail", "test"])
-
- assert result.exit_code != 0
- assert "Could not send test email: SMTP unavailable" in result.output
- send.assert_called_once()