X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=apps%2Fpatchwork%2Ftests%2Fnotifications.py;h=df7e3f9766c16c013b164dfe42343366881c795f;hb=011ee687fda0d3baf66831279565c14e411eab11;hp=ae379889bb100f52b75b9e0a586318d9280324fe;hpb=f94d40159168d0811de576328b77fd2a553039af;p=patchwork diff --git a/apps/patchwork/tests/notifications.py b/apps/patchwork/tests/notifications.py index ae37988..df7e3f9 100644 --- a/apps/patchwork/tests/notifications.py +++ b/apps/patchwork/tests/notifications.py @@ -23,7 +23,7 @@ from django.core.urlresolvers import reverse from django.core import mail from django.conf import settings from django.db.utils import IntegrityError -from patchwork.models import Patch, State, PatchChangeNotification +from patchwork.models import Patch, State, PatchChangeNotification, EmailOptout from patchwork.tests.utils import defaults, create_maintainer from patchwork.utils import send_notifications @@ -172,6 +172,32 @@ class PatchNotificationEmailTest(TestCase): self.assertEquals(msg.to, [self.submitter.email]) self.assertTrue(self.patch.get_absolute_url() in msg.body) + def testNotificationEscaping(self): + self.patch.name = 'Patch name with " character' + self.patch.save() + PatchChangeNotification(patch = self.patch, + orig_state = self.patch.state).save() + self._expireNotifications() + + errors = send_notifications() + self.assertEquals(errors, []) + self.assertEquals(len(mail.outbox), 1) + msg = mail.outbox[0] + self.assertEquals(msg.to, [self.submitter.email]) + self.assertFalse('"' in msg.body) + + def testNotificationOptout(self): + """ensure opt-out addresses don't get notifications""" + PatchChangeNotification(patch = self.patch, + orig_state = self.patch.state).save() + self._expireNotifications() + + EmailOptout(email = self.submitter.email).save() + + errors = send_notifications() + self.assertEquals(errors, []) + self.assertEquals(len(mail.outbox), 0) + def testNotificationMerge(self): patches = [self.patch, Patch(project = self.project, msgid = 'testpatch-2',