summaryrefslogtreecommitdiff
path: root/tests/modeltests/test_client/models.py
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2007-05-08 11:19:34 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2007-05-08 11:19:34 +0000
commit469314e7bcad7390362804b73d74b1ff1ba6396b (patch)
tree000e15eae66836d323ce4465cfb1cd537273f932 /tests/modeltests/test_client/models.py
parent1c53661bd14cbb19138bd7f9dbc03074c58d63c2 (diff)
Added redirection for email services during test conditions.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5173 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/modeltests/test_client/models.py')
-rw-r--r--tests/modeltests/test_client/models.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/modeltests/test_client/models.py b/tests/modeltests/test_client/models.py
index cd8dbe37d2..34242ee0d8 100644
--- a/tests/modeltests/test_client/models.py
+++ b/tests/modeltests/test_client/models.py
@@ -20,6 +20,7 @@ rather than the HTML rendered to the end-user.
"""
from django.test import Client, TestCase
+from django.core import mail
class ClientTest(TestCase):
fixtures = ['testdata.json']
@@ -232,3 +233,36 @@ class ClientTest(TestCase):
self.fail('Should raise an error')
except KeyError:
pass
+
+ def test_mail_sending(self):
+ "Test that mail is redirected to a dummy outbox during test setup"
+
+ response = self.client.get('/test_client/mail_sending_view/')
+ self.assertEqual(response.status_code, 200)
+
+ self.assertEqual(len(mail.outbox), 1)
+ self.assertEqual(mail.outbox[0].subject, 'Test message')
+ self.assertEqual(mail.outbox[0].body, 'This is a test email')
+ self.assertEqual(mail.outbox[0].from_email, 'from@example.com')
+ self.assertEqual(mail.outbox[0].to[0], 'first@example.com')
+ self.assertEqual(mail.outbox[0].to[1], 'second@example.com')
+
+ def test_mass_mail_sending(self):
+ "Test that mass mail is redirected to a dummy outbox during test setup"
+
+ response = self.client.get('/test_client/mass_mail_sending_view/')
+ self.assertEqual(response.status_code, 200)
+
+ self.assertEqual(len(mail.outbox), 2)
+ self.assertEqual(mail.outbox[0].subject, 'First Test message')
+ self.assertEqual(mail.outbox[0].body, 'This is the first test email')
+ self.assertEqual(mail.outbox[0].from_email, 'from@example.com')
+ self.assertEqual(mail.outbox[0].to[0], 'first@example.com')
+ self.assertEqual(mail.outbox[0].to[1], 'second@example.com')
+
+ self.assertEqual(mail.outbox[1].subject, 'Second Test message')
+ self.assertEqual(mail.outbox[1].body, 'This is the second test email')
+ self.assertEqual(mail.outbox[1].from_email, 'from@example.com')
+ self.assertEqual(mail.outbox[1].to[0], 'second@example.com')
+ self.assertEqual(mail.outbox[1].to[1], 'third@example.com')
+ \ No newline at end of file