Merge lp:~sinzui/launchpad/person-merge-job-3 into lp:launchpad

Proposed by Curtis Hovey
Status: Merged
Approved by: Curtis Hovey
Approved revision: no longer in the source branch.
Merged at revision: 12670
Proposed branch: lp:~sinzui/launchpad/person-merge-job-3
Merge into: lp:launchpad
Diff against target: 44 lines (+18/-5)
2 files modified
lib/lp/registry/model/person.py (+6/-5)
lib/lp/registry/tests/test_person.py (+12/-0)
To merge this branch: bzr merge lp:~sinzui/launchpad/person-merge-job-3
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+54961@code.launchpad.net

Description of the change

Allow users to merge teams with purges lists.

    Launchpad bug: https://bugs.launchpad.net/bugs/743194
    Pre-implementation: no one
    Test command: ./bin/test -vv -t TestPersonSetMerge

While testing the move the of merge team rules, I discovered there is a defect
in the original rules. There are about 30 teams with purged mailing lists that
will oops because the mailing list checking rules are including purges lists
in the active lists. I believe this one worked, but the checking rules were
altered to only look for deactivated lists because users cannot purge lists.
The affected teams were purged by ~registry or ~admins members. at the request
of users.

--------------------------------------------------------------------

RULES

    * Update the mailing list guard in _purgeUnmergableTeamArtifacts
      to not raise an error if the mailing list is purged.

QA

    * Visit https://qastaging.launchpad.net/~green-squad
    * Choose Delete
    * Verify the team is deleted.

LINT

    lib/lp/registry/model/person.py
    lib/lp/registry/tests/test_person.py

IMPLEMENTATION

Added a test for a purges list. Updated the guard to only raise an error
if the list is not PURGED.
    lib/lp/registry/model/person.py
    lib/lp/registry/tests/test_person.py

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

I am self-approving this because this is a one-line change + a test to prevent an false assertion.

review: Approve (code)

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 2011-03-25 23:42:33 +0000
3+++ lib/lp/registry/model/person.py 2011-03-26 16:35:59 +0000
4@@ -3808,11 +3808,12 @@
5 """Purge team artifacts that cannot be merged, but can be removed."""
6 # A team cannot have more than one mailing list.
7 mailing_list = getUtility(IMailingListSet).get(from_team.name)
8- if mailing_list is not None and mailing_list.status in PURGE_STATES:
9- from_team.mailing_list.purge()
10- elif mailing_list is not None:
11- raise AssertionError(
12- "Teams with active mailing lists cannot be merged.")
13+ if mailing_list is not None:
14+ if mailing_list.status in PURGE_STATES:
15+ from_team.mailing_list.purge()
16+ elif mailing_list.status != MailingListStatus.PURGED:
17+ raise AssertionError(
18+ "Teams with active mailing lists cannot be merged.")
19 # Team email addresses are not transferable.
20 from_team.setContactAddress(None)
21 # Memberships in the team are not transferable because there
22
23=== modified file 'lib/lp/registry/tests/test_person.py'
24--- lib/lp/registry/tests/test_person.py 2011-03-25 23:42:33 +0000
25+++ lib/lp/registry/tests/test_person.py 2011-03-26 16:35:59 +0000
26@@ -716,6 +716,18 @@
27 emails = getUtility(IEmailAddressSet).getByPerson(target_team).count()
28 self.assertEqual(0, emails)
29
30+ def test_team_with_purged_mailing_list(self):
31+ # A team with a purges mailing list can be merged.
32+ target_team = self.factory.makeTeam()
33+ test_team = self.factory.makeTeam()
34+ mailing_list = self.factory.makeMailingList(
35+ test_team, test_team.teamowner)
36+ mailing_list.deactivate()
37+ mailing_list.transitionToStatus(MailingListStatus.INACTIVE)
38+ mailing_list.purge()
39+ self.person_set.merge(test_team, target_team, test_team.teamowner)
40+ self.assertEqual(target_team, test_team.merged)
41+
42 def test_team_with_members(self):
43 # Team members are removed before merging.
44 target_team = self.factory.makeTeam()