Merge lp:~sinzui/launchpad/delete-team-2 into lp:launchpad

Proposed by Curtis Hovey on 2010-08-18
Status: Merged
Approved by: Edwin Grubbs on 2010-08-18
Approved revision: no longer in the source branch.
Merged at revision: 11387
Proposed branch: lp:~sinzui/launchpad/delete-team-2
Merge into: lp:launchpad
Diff against target: 67 lines (+24/-7)
2 files modified
lib/lp/registry/model/person.py (+3/-2)
lib/lp/registry/tests/test_team.py (+21/-5)
To merge this branch: bzr merge lp:~sinzui/launchpad/delete-team-2
Reviewer Review Type Date Requested Status
Edwin Grubbs (community) 2010-08-18 Approve on 2010-08-18
Review via email: mp+32948@code.launchpad.net

Description of the Change

This is my branch to allow renamed teams with purged mailing lists to set
their contact address.

    lp:~sinzui/launchpad/delete-team-2
    Diff size: 62
    Launchpad bug:
          https://bugs.launchpad.net/bugs/619022
    Test command: ./bin/test -vv -t TestTeamContactAddress
    Pre-implementation: EdwinGrubbs
    Target release: 10.09

Allow renamed teams with purged mailing lists to set their contact address
--------------------------------------------------------------------------

This team had a list purged, then it was renamed. The team has the old mailing
list address but the mailing list does not. This is expected.
setContactAddress should not assume that it will always have an email address
for a mailing list. It is okay to be None, since the deletion loop does the
right thing, but the MasterStore step is not needed.

There was some discussion about whether the email address should be deleted
when the list is purged. It could be, but we need a reallocation mechanism
if the list is recreated. This issue was caused by a rename, and we still
have many examples where renaming persons breaks other things. We really
want to make rename safe for mailing lists and PPAs. Since renames can happen
via the SQL, we cannot entertain such an enhancement until we have a UI
that supports all the cases.

Rules
-----

    * Check is mailing_list_email is not None before getting the master store.

QA
--

    * Visit https://edge.launchpad.net/~ubuntu-l10n-nds
    * Delete the team (which implicitly sets the address to None).
    * Verify you see the people and teams search page.

Lint
----

Paste Linting changed files:
  lib/lp/registry/model/person.py
  lib/lp/registry/tests/test_team.py

I can clean up this file after the review.
./lib/lp/registry/model/person.py
      66: 'safe_hasattr' imported but unused
      64: E501 line too long (83 characters)
      68: E501 line too long (80 characters)
    1450: W291 trailing whitespace
    1491: W291 trailing whitespace
    1492: E501 line too long (82 characters)
    1522: E301 expected 1 blank line, found 0
    1559: E501 line too long (82 characters)
      64: Line exceeds 78 characters.
      68: Line exceeds 78 characters.
    1450: Line has trailing whitespace.
    1478: Line exceeds 78 characters.
    1491: Line has trailing whitespace.
    1492: Line exceeds 78 characters.
    1559: Line exceeds 78 characters. lint report

Test
----

    * lib/lp/registry/tests/test_team.py
      * Added a test that repeats the events that happened to the problem
        team and verified it can set its contact address.

Implementation
--------------

    * lib/lp/registry/model/person.py
      * Added check to see if the address is None before

--
__Curtis C. Hovey_________
http://launchpad.net/

To post a comment you must log in.
Edwin Grubbs (edwin-grubbs) wrote :

Hi Curtis,

This looks good. One minor comment: login_person and login_celebrity are not in alphabetical order.

-Edwin

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/model/person.py'
2--- lib/lp/registry/model/person.py 2010-08-17 13:53:04 +0000
3+++ lib/lp/registry/model/person.py 2010-08-18 15:54:47 +0000
4@@ -1,4 +1,4 @@
5-# Copyright 2009 Canonical Ltd. This software is licensed under the
6+# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
7 # GNU Affero General Public License version 3 (see the file LICENSE).
8 from __future__ import with_statement
9
10@@ -2179,7 +2179,8 @@
11 if self.mailing_list is not None:
12 mailing_list_email = getUtility(IEmailAddressSet).getByEmail(
13 self.mailing_list.address)
14- mailing_list_email = IMasterObject(mailing_list_email)
15+ if mailing_list_email is not None:
16+ mailing_list_email = IMasterObject(mailing_list_email)
17 else:
18 mailing_list_email = None
19 all_addresses = IMasterStore(self).find(
20
21=== modified file 'lib/lp/registry/tests/test_team.py'
22--- lib/lp/registry/tests/test_team.py 2010-04-19 21:16:12 +0000
23+++ lib/lp/registry/tests/test_team.py 2010-08-18 15:54:47 +0000
24@@ -6,7 +6,6 @@
25 __metaclass__ = type
26
27 import transaction
28-from unittest import TestLoader
29
30 from zope.component import getUtility
31
32@@ -15,7 +14,8 @@
33 from canonical.launchpad.interfaces.lpstorm import IMasterStore
34 from canonical.testing import DatabaseFunctionalLayer
35
36-from lp.testing import TestCaseWithFactory
37+from lp.registry.interfaces.mailinglist import MailingListStatus
38+from lp.testing import login_celebrity, login_person, TestCaseWithFactory
39
40
41 class TestTeamContactAddress(TestCaseWithFactory):
42@@ -81,6 +81,22 @@
43 self.assertEqual(None, self.team.preferredemail)
44 self.assertEqual([list_address], self.getAllEmailAddresses())
45
46-
47-def test_suite():
48- return TestLoader().loadTestsFromName(__name__)
49+ def test_setContactAddress_after_purged_mailing_list_and_rename(self):
50+ # This is the rare case where a list is purged for a team rename,
51+ # then the contact address is set/unset sometime afterwards.
52+ # The old mailing list address belongs the the team, but not the list.
53+ # 1. Create then purge a mailing list.
54+ list_address = self.createMailingListAndGetAddress()
55+ mailing_list = self.team.mailing_list
56+ mailing_list.deactivate()
57+ mailing_list.transitionToStatus(MailingListStatus.INACTIVE)
58+ mailing_list.purge()
59+ transaction.commit()
60+ # 2. Rename the team.
61+ login_celebrity('admin')
62+ self.team.name = 'beta'
63+ login_person(self.team.teamowner)
64+ # 3. Set the contact address.
65+ self.team.setContactAddress(None)
66+ self.assertEqual(None, self.team.preferredemail)
67+ self.assertEqual([], self.getAllEmailAddresses())