← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~twom/launchpad:email-ppa-changes into launchpad:master

 

Tom Wardill has proposed merging ~twom/launchpad:email-ppa-changes into launchpad:master.

Commit message:
Don't send packageupload mails to non main archive lists

lp: #1929243

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~twom/launchpad/+git/launchpad/+merge/405108
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~twom/launchpad:email-ppa-changes into launchpad:master.
diff --git a/lib/lp/soyuz/mail/packageupload.py b/lib/lp/soyuz/mail/packageupload.py
index a5686a1..006c1a9 100644
--- a/lib/lp/soyuz/mail/packageupload.py
+++ b/lib/lp/soyuz/mail/packageupload.py
@@ -392,6 +392,7 @@ class PackageUploadMailer(BaseMailer):
         # security uploads, or autosync uploads.
         if (action == 'accepted' and distroseries.changeslist
                 and not archive.is_ppa
+                and archive.is_main
                 and pocket != PackagePublishingPocket.BACKPORTS
                 and not (
                     pocket == PackagePublishingPocket.SECURITY and spr is None)
diff --git a/lib/lp/soyuz/mail/tests/test_packageupload.py b/lib/lp/soyuz/mail/tests/test_packageupload.py
index 3e9c0b1..ff268fd 100644
--- a/lib/lp/soyuz/mail/tests/test_packageupload.py
+++ b/lib/lp/soyuz/mail/tests/test_packageupload.py
@@ -405,6 +405,60 @@ class TestNotification(TestCaseWithFactory):
             PackagePublishingPocket.RELEASE)
         self.assertContentEqual(expected, observed.keys())
 
+    def test_getRecipientsForAction_primary(self):
+        blamer, maintainer, changer = self._setup_recipients()
+        changes = {
+            'Date': b'2001-01-01',
+            'Changed-By': b'Changer <changer@xxxxxxxxxxx>',
+            'Maintainer': b'Maintainer <maintainer@xxxxxxxxxxx>',
+            'Changes': b' * Foo!',
+            }
+        distribution = self.factory.makeDistribution()
+        archive = self.factory.makeArchive(
+            distribution=distribution, purpose=ArchivePurpose.PRIMARY)
+        distroseries = self.factory.makeDistroSeries(distribution=distribution)
+        distroseries.changeslist = "blah@xxxxxxxxxxx"
+        # Now set the uploaders.
+        component = getUtility(IComponentSet).ensure('main')
+        if component not in distroseries.components:
+            self.factory.makeComponentSelection(
+                distroseries=distroseries, component=component)
+        distribution.main_archive.newComponentUploader(maintainer, component)
+        distribution.main_archive.newComponentUploader(changer, component)
+        info = fetch_information(None, None, changes)
+        observed, _ = PackageUploadMailer.getRecipientsForAction(
+            'accepted', info, blamer, None, [], archive, distroseries,
+            PackagePublishingPocket.RELEASE)
+        email_addresses = [x.preferredemail.email for x in observed.keys()]
+        self.assertIn("blah@xxxxxxxxxxx", email_addresses)
+
+    def test_getRecipientsForAction_copy(self):
+        blamer, maintainer, changer = self._setup_recipients()
+        changes = {
+            'Date': b'2001-01-01',
+            'Changed-By': b'Changer <changer@xxxxxxxxxxx>',
+            'Maintainer': b'Maintainer <maintainer@xxxxxxxxxxx>',
+            'Changes': b' * Foo!',
+            }
+        distribution = self.factory.makeDistribution()
+        archive = self.factory.makeArchive(
+            distribution=distribution, purpose=ArchivePurpose.COPY)
+        distroseries = self.factory.makeDistroSeries(distribution=distribution)
+        distroseries.changeslist = "blah@xxxxxxxxxxx"
+        # Now set the uploaders.
+        component = getUtility(IComponentSet).ensure('main')
+        if component not in distroseries.components:
+            self.factory.makeComponentSelection(
+                distroseries=distroseries, component=component)
+        distribution.main_archive.newComponentUploader(maintainer, component)
+        distribution.main_archive.newComponentUploader(changer, component)
+        info = fetch_information(None, None, changes)
+        observed, _ = PackageUploadMailer.getRecipientsForAction(
+            'accepted', info, blamer, None, [], archive, distroseries,
+            PackagePublishingPocket.RELEASE)
+        email_addresses = [x.preferredemail.email for x in observed.keys()]
+        self.assertNotIn("blah@xxxxxxxxxxx", email_addresses)
+
     def test_getRecipientsForAction_good_emails(self):
         # Test getRecipientsForAction with good email addresses..
         blamer, maintainer, changer = self._setup_recipients()