Merge lp:~michael.nelson/launchpad/db-611568-no-email-for-commercial-subscriptions into lp:launchpad/db-devel

Proposed by Michael Nelson on 2010-09-07
Status: Merged
Approved by: Michael Nelson on 2010-09-07
Approved revision: no longer in the source branch.
Merged at revision: 9760
Proposed branch: lp:~michael.nelson/launchpad/db-611568-no-email-for-commercial-subscriptions
Merge into: lp:launchpad/db-devel
Diff against target: 67 lines (+34/-0)
2 files modified
lib/canonical/launchpad/mailnotification.py (+6/-0)
lib/lp/soyuz/tests/test_archive_subscriptions.py (+28/-0)
To merge this branch: bzr merge lp:~michael.nelson/launchpad/db-611568-no-email-for-commercial-subscriptions
Reviewer Review Type Date Requested Status
Graham Binns (community) release-critical 2010-09-07 Approve on 2010-09-07
Leonard Richardson (community) 2010-09-07 Approve on 2010-09-07
Review via email: mp+34757@code.launchpad.net

Commit Message

Email notifications for new P3A subscriptions should not be sent for commercial PPAs.

Description of the Change

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

To post a comment you must log in.
review: Approve
Graham Binns (gmb) :
review: Approve (release-critical)
Robert Collins (lifeless) wrote :

Just a small note - it looks like that check could go higher up and
avoid unnecessary work.

Perhaps even better if it was a different class and simply skipped the
whole thing.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/mailnotification.py'
2--- lib/canonical/launchpad/mailnotification.py 2010-08-23 09:18:51 +0000
3+++ lib/canonical/launchpad/mailnotification.py 2010-09-07 14:31:00 +0000
4@@ -536,6 +536,12 @@
5 non_active_subscribers = subscription.getNonActiveSubscribers()
6
7 archive = subscription.archive
8+
9+ # We don't send notification emails for commercial PPAs as these
10+ # are purchased via software center (and do not mention Launchpad).
11+ if archive.commercial:
12+ return
13+
14 registrant_name = subscription.registrant.displayname
15 ppa_displayname = archive.displayname
16 ppa_reference = "ppa:%s/%s" % (
17
18=== modified file 'lib/lp/soyuz/tests/test_archive_subscriptions.py'
19--- lib/lp/soyuz/tests/test_archive_subscriptions.py 2010-08-20 20:31:18 +0000
20+++ lib/lp/soyuz/tests/test_archive_subscriptions.py 2010-09-07 14:31:00 +0000
21@@ -3,14 +3,18 @@
22
23 """Test Archive features."""
24
25+from __future__ import with_statement
26+
27 from zope.security.interfaces import Unauthorized
28
29 from canonical.testing import DatabaseFunctionalLayer
30 from lp.registry.interfaces.person import PersonVisibility
31 from lp.testing import (
32+ celebrity_logged_in,
33 login_person,
34 TestCaseWithFactory,
35 )
36+from lp.testing.mail_helpers import pop_notifications
37
38
39 class TestArchiveSubscriptions(TestCaseWithFactory):
40@@ -50,3 +54,27 @@
41 # When a subscription exists, it's fine.
42 login_person(self.subscriber)
43 self.assertEqual(self.archive.owner.name, "subscribertest")
44+
45+ def test_new_subscription_sends_email(self):
46+ # Creating a new subscription sends an email to all members
47+ # of the person or team subscribed.
48+ self.assertEqual(0, len(pop_notifications()))
49+
50+ self.archive.newSubscription(
51+ self.subscriber, registrant=self.archive.owner)
52+
53+ notifications = pop_notifications()
54+ self.assertEqual(1, len(notifications))
55+ self.assertEqual(
56+ self.subscriber.preferredemail.email,
57+ notifications[0]['to'])
58+
59+ def test_new_commercial_subscription_no_email(self):
60+ # As per bug 611568, an email is not sent for commercial PPAs.
61+ with celebrity_logged_in('commercial_admin'):
62+ self.archive.commercial = True
63+
64+ self.archive.newSubscription(
65+ self.subscriber, registrant=self.archive.owner)
66+
67+ self.assertEqual(0, len(pop_notifications()))

Subscribers

People subscribed via source and target branches

to status/vote changes: