← Back to team overview

launchpad-reviewers team mailing list archive

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

 

James Westby has proposed merging lp:~james-w/launchpad/no-subscription-cancellation-email into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~james-w/launchpad/no-subscription-cancellation-email/+merge/105400

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

-- 
https://code.launchpad.net/~james-w/launchpad/no-subscription-cancellation-email/+merge/105400
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~james-w/launchpad/no-subscription-cancellation-email into lp:launchpad.
=== modified file 'lib/lp/archivepublisher/scripts/generate_ppa_htaccess.py'
--- lib/lp/archivepublisher/scripts/generate_ppa_htaccess.py	2012-03-13 11:48:01 +0000
+++ lib/lp/archivepublisher/scripts/generate_ppa_htaccess.py	2012-05-10 21:51:20 +0000
@@ -122,6 +122,10 @@
 
     def sendCancellationEmail(self, token):
         """Send an email to the person whose subscription was cancelled."""
+        if token.archive.suppress_subscription_notifications:
+            # Don't send an email if they should be suppresed for the
+            # archive
+            return
         send_to_person = token.person
         ppa_name = token.archive.displayname
         ppa_owner_url = canonical_url(token.archive.owner)

=== modified file 'lib/lp/archivepublisher/tests/test_generate_ppa_htaccess.py'
--- lib/lp/archivepublisher/tests/test_generate_ppa_htaccess.py	2012-01-20 16:11:11 +0000
+++ lib/lp/archivepublisher/tests/test_generate_ppa_htaccess.py	2012-05-10 21:51:20 +0000
@@ -538,6 +538,23 @@
             "Regards,\n"
             "The Launchpad team")
 
+    def testNoEmailOnCancellationForSuppressedArchive(self):
+        """No email should be sent if the archive has
+        suppress_subscription_notifications set."""
+        subs, tokens = self.setupDummyTokens()
+        token = tokens[0]
+        token.archive.suppress_subscription_notifications = True
+        script = self.getScript()
+
+        # Clear out any existing email.
+        pop_notifications()
+
+        script.sendCancellationEmail(token)
+
+        num_emails = len(stub.test_emails)
+        self.assertEqual(
+            num_emails, 0, "Expected 0 emails, got %s" % num_emails)
+
     def test_getNewPrivatePPAs_no_previous_run(self):
         # All private PPAs are returned if there was no previous run.
         # This happens even if they have no tokens.


Follow ups