← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/copy-errors-to-sponsored into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/copy-errors-to-sponsored into lp:launchpad.

Commit message:
Send notification of PCJ errors to the sponsored person, if any.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1319704 in Launchpad itself: "PackageCopyJob errors should be copied to the sponsored person if any"
  https://bugs.launchpad.net/launchpad/+bug/1319704

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/copy-errors-to-sponsored/+merge/219666

If there is a sponsored person listed in a PCJ, add them to the list of people notified on errors.  Fixes the Launchpad part of bug 1319704.
-- 
https://code.launchpad.net/~cjwatson/launchpad/copy-errors-to-sponsored/+merge/219666
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/copy-errors-to-sponsored into lp:launchpad.
=== modified file 'lib/lp/soyuz/model/packagecopyjob.py'
--- lib/lp/soyuz/model/packagecopyjob.py	2013-07-16 14:06:08 +0000
+++ lib/lp/soyuz/model/packagecopyjob.py	2014-05-15 09:22:49 +0000
@@ -1,4 +1,4 @@
-# Copyright 2010-2013 Canonical Ltd.  This software is licensed under the
+# Copyright 2010-2014 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 __metaclass__ = type
@@ -246,7 +246,10 @@
 
     def getErrorRecipients(self):
         """See `IPlainPackageCopyJob`."""
-        return [format_address_for_person(self.requester)]
+        recipients = [self.requester]
+        if self.sponsored is not None:
+            recipients.append(self.sponsored)
+        return [format_address_for_person(person) for person in recipients]
 
     @property
     def copy_policy(self):

=== modified file 'lib/lp/soyuz/tests/test_packagecopyjob.py'
--- lib/lp/soyuz/tests/test_packagecopyjob.py	2014-04-24 06:45:51 +0000
+++ lib/lp/soyuz/tests/test_packagecopyjob.py	2014-05-15 09:22:49 +0000
@@ -1,4 +1,4 @@
-# Copyright 2010-2013 Canonical Ltd.  This software is licensed under the
+# Copyright 2010-2014 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Tests for sync package jobs."""
@@ -192,6 +192,13 @@
         email = format_address_for_person(job.requester)
         self.assertEqual([email], job.getErrorRecipients())
 
+    def test_getErrorRecipients_sponsored(self):
+        # If there is a sponsored person, they are notified of errors too.
+        job = self.makeJob(sponsored=self.factory.makePerson())
+        recipients = (job.requester, job.sponsored)
+        emails = [format_address_for_person(person) for person in recipients]
+        self.assertContentEqual(emails, job.getErrorRecipients())
+
     def test_create(self):
         # A PackageCopyJob can be created and stores its arguments.
         distroseries = self.factory.makeDistroSeries()


Follow ups