Merge lp:~james-w/launchpad/no-subscription-cancellation-email into lp:launchpad

Proposed by James Westby on 2012-05-10
Status: Merged
Approved by: j.c.sackett on 2012-05-10
Approved revision: no longer in the source branch.
Merged at revision: 15230
Proposed branch: lp:~james-w/launchpad/no-subscription-cancellation-email
Merge into: lp:launchpad
Diff against target: 42 lines (+21/-0)
2 files modified
lib/lp/archivepublisher/scripts/generate_ppa_htaccess.py (+4/-0)
lib/lp/archivepublisher/tests/test_generate_ppa_htaccess.py (+17/-0)
To merge this branch: bzr merge lp:~james-w/launchpad/no-subscription-cancellation-email
Reviewer Review Type Date Requested Status
Launchpad code reviewers 2012-05-10 Pending
Review via email: mp+105400@code.launchpad.net

Commit Message

Don't send email when a subscription to a "suppress_subscription_notifications" archive is cancelled.

Description of the Change

Hi,

We've noticed that emails are being sent when a subscription to a "suppress_subscription_notifications"
PPA is deleted, and we don't want that.

This branch makes the script that creates those emails pay attention to the flag.

Thanks,

James

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/archivepublisher/scripts/generate_ppa_htaccess.py'
2--- lib/lp/archivepublisher/scripts/generate_ppa_htaccess.py 2012-03-13 11:48:01 +0000
3+++ lib/lp/archivepublisher/scripts/generate_ppa_htaccess.py 2012-05-10 21:51:20 +0000
4@@ -122,6 +122,10 @@
5
6 def sendCancellationEmail(self, token):
7 """Send an email to the person whose subscription was cancelled."""
8+ if token.archive.suppress_subscription_notifications:
9+ # Don't send an email if they should be suppresed for the
10+ # archive
11+ return
12 send_to_person = token.person
13 ppa_name = token.archive.displayname
14 ppa_owner_url = canonical_url(token.archive.owner)
15
16=== modified file 'lib/lp/archivepublisher/tests/test_generate_ppa_htaccess.py'
17--- lib/lp/archivepublisher/tests/test_generate_ppa_htaccess.py 2012-01-20 16:11:11 +0000
18+++ lib/lp/archivepublisher/tests/test_generate_ppa_htaccess.py 2012-05-10 21:51:20 +0000
19@@ -538,6 +538,23 @@
20 "Regards,\n"
21 "The Launchpad team")
22
23+ def testNoEmailOnCancellationForSuppressedArchive(self):
24+ """No email should be sent if the archive has
25+ suppress_subscription_notifications set."""
26+ subs, tokens = self.setupDummyTokens()
27+ token = tokens[0]
28+ token.archive.suppress_subscription_notifications = True
29+ script = self.getScript()
30+
31+ # Clear out any existing email.
32+ pop_notifications()
33+
34+ script.sendCancellationEmail(token)
35+
36+ num_emails = len(stub.test_emails)
37+ self.assertEqual(
38+ num_emails, 0, "Expected 0 emails, got %s" % num_emails)
39+
40 def test_getNewPrivatePPAs_no_previous_run(self):
41 # All private PPAs are returned if there was no previous run.
42 # This happens even if they have no tokens.