← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/testfix-message-for-header into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/testfix-message-for-header into lp:launchpad.

Commit message:
Fix test failures due to message-for-header.

Requested reviews:
  Colin Watson (cjwatson)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/testfix-message-for-header/+merge/270833

Fix test failures due to message-for-header.
-- 
Your team Launchpad code reviewers is subscribed to branch lp:launchpad.
=== modified file 'lib/lp/code/configure.zcml'
--- lib/lp/code/configure.zcml	2015-09-01 17:10:46 +0000
+++ lib/lp/code/configure.zcml	2015-09-11 14:54:59 +0000
@@ -473,6 +473,7 @@
                     branch
                     mail_header
                     recipient
+                    subscriber
                     max_diff_lines
                     review_level"/>
   </class>

=== modified file 'lib/lp/code/doc/branch-merge-proposal-notifications.txt'
--- lib/lp/code/doc/branch-merge-proposal-notifications.txt	2015-09-11 12:20:23 +0000
+++ lib/lp/code/doc/branch-merge-proposal-notifications.txt	2015-09-11 14:54:59 +0000
@@ -178,7 +178,7 @@
     >>> notifications = pop_notifications(
     ...     sort_key=lambda n: n.get('X-Envelope-To'))
     >>> for notification in notifications:
-    ...     print "%s, %s" % (
+    ...     print "%s, %s, %s" % (
     ...         notification['X-Envelope-To'],
     ...         notification['X-Launchpad-Message-Rationale'],
     ...         notification['X-Launchpad-Message-For'])

=== modified file 'lib/lp/services/mail/tests/test_basemailer.py'
--- lib/lp/services/mail/tests/test_basemailer.py	2015-09-11 12:20:23 +0000
+++ lib/lp/services/mail/tests/test_basemailer.py	2015-09-11 14:54:59 +0000
@@ -21,6 +21,9 @@
 
     mail_header = 'pete'
 
+    def __init__(self, subscriber):
+        self.subscriber = subscriber
+
     def getReason(self):
         return "Because"
 
@@ -95,7 +98,7 @@
         """
         fake_to = self.factory.makePerson(email='to@xxxxxxxxxxx',
             displayname='Example To')
-        recipients = {fake_to: FakeSubscription()}
+        recipients = {fake_to: FakeSubscription(fake_to)}
         mailer = BaseMailerSubclass(
             'subject', None, recipients, 'from@xxxxxxxxxxx')
         ctrl = mailer.generateEmail('to@xxxxxxxxxxx', fake_to)
@@ -109,7 +112,7 @@
         returning the uppercased email address.
         """
         fake_to = self.factory.makePerson(email='to@xxxxxxxxxxx')
-        recipients = {fake_to: FakeSubscription()}
+        recipients = {fake_to: FakeSubscription(fake_to)}
         mailer = FromAddressUpper(
             'subject', None, recipients, 'from@xxxxxxxxxxx')
         ctrl = mailer.generateEmail('to@xxxxxxxxxxx', fake_to)
@@ -122,7 +125,7 @@
         as a single-item list with the uppercased email address.
         """
         fake_to = self.factory.makePerson(email='to@xxxxxxxxxxx')
-        recipients = {fake_to: FakeSubscription()}
+        recipients = {fake_to: FakeSubscription(fake_to)}
         mailer = ToAddressesUpper(
             'subject', None, recipients, 'from@xxxxxxxxxxx')
         ctrl = mailer.generateEmail('to@xxxxxxxxxxx', fake_to)
@@ -131,7 +134,7 @@
     def test_generateEmail_adds_attachments(self):
         # BaseMailer.generateEmail calls _addAttachments.
         fake_to = self.factory.makePerson(email='to@xxxxxxxxxxx')
-        recipients = {fake_to: FakeSubscription()}
+        recipients = {fake_to: FakeSubscription(fake_to)}
         mailer = AttachmentMailer(
             'subject', None, recipients, 'from@xxxxxxxxxxx')
         ctrl = mailer.generateEmail('to@xxxxxxxxxxx', fake_to)
@@ -141,7 +144,7 @@
         # If BaseMailer.generateEmail is called with
         # force_no_attachments=True then attachments are not added.
         fake_to = self.factory.makePerson(email='to@xxxxxxxxxxx')
-        recipients = {fake_to: FakeSubscription()}
+        recipients = {fake_to: FakeSubscription(fake_to)}
         mailer = AttachmentMailer(
             'subject', None, recipients, 'from@xxxxxxxxxxx')
         ctrl = mailer.generateEmail(
@@ -158,7 +161,7 @@
         # Recipients without expanded_notification_footers do not receive an
         # expanded footer on messages.
         fake_to = self.factory.makePerson(email='to@xxxxxxxxxxx')
-        recipients = {fake_to: FakeSubscription()}
+        recipients = {fake_to: FakeSubscription(fake_to)}
         mailer = BaseMailerSubclass(
             'subject', None, recipients, 'from@xxxxxxxxxxx',
             notification_type='test')
@@ -171,7 +174,7 @@
         fake_to = self.factory.makePerson(
             name='to-person', email='to@xxxxxxxxxxx')
         fake_to.expanded_notification_footers = True
-        recipients = {fake_to: FakeSubscription()}
+        recipients = {fake_to: FakeSubscription(fake_to)}
         mailer = BaseMailerSubclass(
             'subject', None, recipients, 'from@xxxxxxxxxxx',
             notification_type='test')
@@ -186,11 +189,12 @@
     def test_sendall_single_failure_doesnt_kill_all(self):
         # A failure to send to a particular email address doesn't stop sending
         # to others.
+        good = self.factory.makePerson(name='good', email='good@xxxxxxxxxxx')
+        bad = self.factory.makePerson(name='bad', email='bad@xxxxxxxxxxx')
         recipients = {
-            self.factory.makePerson(name='good', email='good@xxxxxxxxxxx'):
-                FakeSubscription(),
-            self.factory.makePerson(name='bad', email='bad@xxxxxxxxxxx'):
-                FakeSubscription()}
+            good: FakeSubscription(good),
+            bad: FakeSubscription(bad),
+            }
         controller_factory = RaisingMailControllerFactory(
             'bad@xxxxxxxxxxx', 2)
         mailer = BaseMailerSubclass(
@@ -208,11 +212,12 @@
     def test_sendall_first_failure_strips_attachments(self):
         # If sending an email fails, we try again without the (almost
         # certainly) large attachment.
+        good = self.factory.makePerson(name='good', email='good@xxxxxxxxxxx')
+        bad = self.factory.makePerson(name='bad', email='bad@xxxxxxxxxxx')
         recipients = {
-            self.factory.makePerson(name='good', email='good@xxxxxxxxxxx'):
-                FakeSubscription(),
-            self.factory.makePerson(name='bad', email='bad@xxxxxxxxxxx'):
-                FakeSubscription()}
+            good: FakeSubscription(good),
+            bad: FakeSubscription(bad),
+            }
         # Only raise the first time for bob.
         controller_factory = RaisingMailControllerFactory(
             'bad@xxxxxxxxxxx', 1)


References