summaryrefslogtreecommitdiff
path: root/tests/mail
diff options
context:
space:
mode:
authorHasan Ramezani <hasan.r67@gmail.com>2019-06-29 01:50:43 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-07-02 07:34:07 +0200
commit090ca6512f514556394d4a8d321db7883f03e2a6 (patch)
tree3f36f7d97c8910b0eb6be962ef64ef44baa8c9e8 /tests/mail
parent29240a99526f5f2a234a9093cd7e001f32ba1801 (diff)
downloaddjango-090ca6512f514556394d4a8d321db7883f03e2a6.tar.gz
Fixed #30604 -- Made mail_admins()/mail_managers() raise ValueError if ADMINS/MANAGERS is set incorrectly.
Diffstat (limited to 'tests/mail')
-rw-r--r--tests/mail/tests.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/mail/tests.py b/tests/mail/tests.py
index a36c09b369..15593dc3f7 100644
--- a/tests/mail/tests.py
+++ b/tests/mail/tests.py
@@ -991,6 +991,23 @@ class BaseEmailBackendTests(HeadersCheckMixin):
mail_managers('hi', 'there')
self.assertEqual(self.get_mailbox_content(), [])
+ def test_wrong_admins_managers(self):
+ tests = (
+ 'test@example.com',
+ ('test@example.com',),
+ ['test@example.com', 'other@example.com'],
+ ('test@example.com', 'other@example.com'),
+ )
+ for setting, mail_func in (
+ ('ADMINS', mail_admins),
+ ('MANAGERS', mail_managers),
+ ):
+ msg = 'The %s setting must be a list of 2-tuples.' % setting
+ for value in tests:
+ with self.subTest(setting=setting, value=value), self.settings(**{setting: value}):
+ with self.assertRaisesMessage(ValueError, msg):
+ mail_func('subject', 'content')
+
def test_message_cc_header(self):
"""
Regression test for #7722