From a702a0773dee8ea74119a8e0edf7ecc5d0ee4a1a Mon Sep 17 00:00:00 2001 From: Baptiste Mispelon Date: Wed, 24 Jan 2024 19:02:42 +0100 Subject: [PATCH] Added test for the sendtestemail command when no recipients are given. --- tests/mail/test_sendtestemail.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/mail/test_sendtestemail.py b/tests/mail/test_sendtestemail.py index 8aff320568..c871f1a299 100644 --- a/tests/mail/test_sendtestemail.py +++ b/tests/mail/test_sendtestemail.py @@ -1,5 +1,5 @@ from django.core import mail -from django.core.management import call_command +from django.core.management import CommandError, call_command from django.test import SimpleTestCase, override_settings @@ -46,6 +46,18 @@ class SendTestEmailManagementCommand(SimpleTestCase): ], ) + def test_missing_receivers(self): + """ + The command should complain if no receivers are given (and --admins or + --managers are not set). + """ + msg = ( + "You must specify some email recipients, or pass the --managers or " + "--admin options." + ) + with self.assertRaisesMessage(CommandError, msg): + call_command("sendtestemail") + def test_manager_receivers(self): """ The mail should be sent to the email addresses specified in