diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-10-24 04:38:43 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2008-10-24 04:38:43 +0000 |
| commit | e3aa9a28288737a75f05f2174b4105d01e52af96 (patch) | |
| tree | f26716885bd5d012343ad766dfe073dfe0789db3 /tests/regressiontests/mail/tests.py | |
| parent | 62c3a7a6254b2038b0fe13e9c9f779bb2ca95c3c (diff) | |
Fixed #9383 -- Don't open a network connection for sending email if there's
nothing to send. Saves a bit of time when, for example, processing 500-error
emails with no ADMINs configured. Based on a patch from Jesse Young.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9248 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/mail/tests.py')
| -rw-r--r-- | tests/regressiontests/mail/tests.py | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/tests/regressiontests/mail/tests.py b/tests/regressiontests/mail/tests.py index c2c084c4c6..4317a66b79 100644 --- a/tests/regressiontests/mail/tests.py +++ b/tests/regressiontests/mail/tests.py @@ -2,7 +2,9 @@ r""" # Tests for the django.core.mail. ->>> from django.core.mail import EmailMessage +>>> from django.conf import settings +>>> from django.core import mail +>>> from django.core.mail import EmailMessage, mail_admins, mail_managers >>> from django.utils.translation import ugettext_lazy # Test normal ascii character case: @@ -60,4 +62,30 @@ BadHeaderError: Header values can't contain newlines (got u'Subject\nInjection T >>> email.message().as_string() 'Content-Type: text/plain; charset="utf-8"\nMIME-Version: 1.0\nContent-Transfer-Encoding: quoted-printable\nSubject: subject\nFrom: from@example.com\nTo: to@example.com\ndate: Fri, 09 Nov 2001 01:08:47 -0000\nMessage-ID: foo\n\ncontent' +# Test that mail_admins/mail_managers doesn't connect to the mail server if there are no recipients (#9383) + +>>> old_admins = settings.ADMINS +>>> old_managers = settings.MANAGERS +>>> settings.ADMINS = [] +>>> settings.MANAGERS = [] +>>> mail.outbox = [] +>>> mail_admins('hi','there') +>>> len(mail.outbox) +0 +>>> mail.outbox = [] +>>> mail_managers('hi','there') +>>> len(mail.outbox) +0 +>>> settings.ADMINS = settings.MANAGERS = [('nobody','nobody@example.com')] +>>> mail.outbox = [] +>>> mail_admins('hi','there') +>>> len(mail.outbox) +1 +>>> mail.outbox = [] +>>> mail_managers('hi','there') +>>> len(mail.outbox) +1 +>>> settings.ADMINS = old_admins +>>> settings.MANAGERS = old_managers + """ |
