← Back to team overview

launchpad-reviewers team mailing list archive

lp:~jcsackett/launchpad/notificationrecipients-and-preferredemail-error-round-two into lp:launchpad

 

j.c.sackett has proposed merging lp:~jcsackett/launchpad/notificationrecipients-and-preferredemail-error-round-two into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #922160 in Launchpad itself: "Get 'not allowed' when filing a bug against ubuntu-website"
  https://bugs.launchpad.net/launchpad/+bug/922160

For more details, see:
https://code.launchpad.net/~jcsackett/launchpad/notificationrecipients-and-preferredemail-error-round-two/+merge/95662

Summary
=======
This branch is a follow up to
lp:~jcsackett/notificationrecipients-and-preferredemail-error. That branch,
while getting the preferredemail error that was causing the initial error,
didn't take care of all instances in the execution path.

This branch does. I think.

Preimplementation
=================
None; this follows on the strategy from the first branch, discussed with
Curtis Hovey.

Implementation
==============
Replaces a call of `removeSecurityProxy(person.preferredemail)` to
`removeSecurityProxy(person).preferredemail`, as person is now the protected
object.

Tests
=====
bin/test -vvct get_contact_email_addresses

QA
==
Follow the steps in the linked bug; no error should occur.

Lint
====
Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/services/mail/tests/test_helpers.py
  lib/lp/services/mail/helpers.py
-- 
https://code.launchpad.net/~jcsackett/launchpad/notificationrecipients-and-preferredemail-error-round-two/+merge/95662
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jcsackett/launchpad/notificationrecipients-and-preferredemail-error-round-two into lp:launchpad.
=== modified file 'lib/lp/services/mail/helpers.py'
--- lib/lp/services/mail/helpers.py	2012-01-01 02:58:52 +0000
+++ lib/lp/services/mail/helpers.py	2012-03-02 20:22:19 +0000
@@ -262,5 +262,5 @@
     # Circular imports force this import.
     from lp.registry.model.person import get_recipients
     return set(
-        str(removeSecurityProxy(mail_person.preferredemail).email)
+        str(removeSecurityProxy(mail_person).preferredemail.email)
         for mail_person in get_recipients(person))

=== modified file 'lib/lp/services/mail/tests/test_helpers.py'
--- lib/lp/services/mail/tests/test_helpers.py	2012-01-01 02:58:52 +0000
+++ lib/lp/services/mail/tests/test_helpers.py	2012-03-02 20:22:19 +0000
@@ -12,6 +12,7 @@
     directlyProvides,
     )
 
+from lp.registry.interfaces.person import PersonVisibility
 from lp.services.mail.helpers import (
     ensure_not_weakly_authenticated,
     ensure_sane_signature_timestamp,
@@ -223,15 +224,30 @@
             team, get_person_or_team('fooix-devs@xxxxxxxxxxxxxxxxx'))
 
 
-class getContactEmailAddresses(TestCaseWithFactory):
+class Testget_contact_email_addresses(TestCaseWithFactory):
+
     layer = DatabaseFunctionalLayer
 
+    def test_person_with_hidden_email(self):
+        user = self.factory.makePerson(
+            email='user@xxxxxxxxxxxxx',
+            hide_email_addresses=True,
+            name='user')
+        result = get_contact_email_addresses(user)
+        self.assertEqual(set(['user@xxxxxxxxxxxxx']), result)
+
     def test_user_with_preferredemail(self):
         user = self.factory.makePerson(
             email='user@xxxxxxxxxxxxx', name='user',)
         result = get_contact_email_addresses(user)
         self.assertEqual(set(['user@xxxxxxxxxxxxx']), result)
 
+    def test_private_team(self):
+        email = 'team@xxxxxxxxxxxxx'
+        team = self.factory.makeTeam(
+            name='breaks-things', email=email, visibility=PersonVisibility.PRIVATE)
+        result = get_contact_email_addresses(team)
+        self.assertEqual(set(['team@xxxxxxxxxxxxx']), result)
 
 def test_suite():
     suite = DocTestSuite('lp.services.mail.helpers')


Follow ups