launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #00910
lp:~michael.nelson/launchpad/db-611568-no-email-for-commercial-subscriptions into lp:launchpad
Michael Nelson has proposed merging lp:~michael.nelson/launchpad/db-611568-no-email-for-commercial-subscriptions into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
#611568 Suppress email notification for SCA P3A subscriptions
https://bugs.launchpad.net/bugs/611568
Overview
========
As per bug 611568, this branch simply ensures that email notifications for private PPA subscriptions are not sent for commercial PPAs.
Details
=======
It's trivial :) Pre-imp on the bug.
Testing
=======
bin/test -vvm test_archive_subscriptions
--
https://code.launchpad.net/~michael.nelson/launchpad/db-611568-no-email-for-commercial-subscriptions/+merge/34757
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~michael.nelson/launchpad/db-611568-no-email-for-commercial-subscriptions into lp:launchpad.
=== modified file 'lib/canonical/launchpad/mailnotification.py'
--- lib/canonical/launchpad/mailnotification.py 2010-08-23 09:18:51 +0000
+++ lib/canonical/launchpad/mailnotification.py 2010-09-07 14:31:00 +0000
@@ -536,6 +536,12 @@
non_active_subscribers = subscription.getNonActiveSubscribers()
archive = subscription.archive
+
+ # We don't send notification emails for commercial PPAs as these
+ # are purchased via software center (and do not mention Launchpad).
+ if archive.commercial:
+ return
+
registrant_name = subscription.registrant.displayname
ppa_displayname = archive.displayname
ppa_reference = "ppa:%s/%s" % (
=== modified file 'lib/lp/soyuz/tests/test_archive_subscriptions.py'
--- lib/lp/soyuz/tests/test_archive_subscriptions.py 2010-08-20 20:31:18 +0000
+++ lib/lp/soyuz/tests/test_archive_subscriptions.py 2010-09-07 14:31:00 +0000
@@ -3,14 +3,18 @@
"""Test Archive features."""
+from __future__ import with_statement
+
from zope.security.interfaces import Unauthorized
from canonical.testing import DatabaseFunctionalLayer
from lp.registry.interfaces.person import PersonVisibility
from lp.testing import (
+ celebrity_logged_in,
login_person,
TestCaseWithFactory,
)
+from lp.testing.mail_helpers import pop_notifications
class TestArchiveSubscriptions(TestCaseWithFactory):
@@ -50,3 +54,27 @@
# When a subscription exists, it's fine.
login_person(self.subscriber)
self.assertEqual(self.archive.owner.name, "subscribertest")
+
+ def test_new_subscription_sends_email(self):
+ # Creating a new subscription sends an email to all members
+ # of the person or team subscribed.
+ self.assertEqual(0, len(pop_notifications()))
+
+ self.archive.newSubscription(
+ self.subscriber, registrant=self.archive.owner)
+
+ notifications = pop_notifications()
+ self.assertEqual(1, len(notifications))
+ self.assertEqual(
+ self.subscriber.preferredemail.email,
+ notifications[0]['to'])
+
+ def test_new_commercial_subscription_no_email(self):
+ # As per bug 611568, an email is not sent for commercial PPAs.
+ with celebrity_logged_in('commercial_admin'):
+ self.archive.commercial = True
+
+ self.archive.newSubscription(
+ self.subscriber, registrant=self.archive.owner)
+
+ self.assertEqual(0, len(pop_notifications()))