Merge lp:~sinzui/launchpad/private-persontransferjob-0 into lp:launchpad

Proposed by Curtis Hovey
Status: Merged
Approved by: Graham Binns
Approved revision: no longer in the source branch.
Merged at revision: 11963
Proposed branch: lp:~sinzui/launchpad/private-persontransferjob-0
Merge into: lp:launchpad
Diff against target: 75 lines (+28/-6)
2 files modified
lib/lp/registry/model/person.py (+4/-6)
lib/lp/registry/tests/test_team.py (+24/-0)
To merge this branch: bzr merge lp:~sinzui/launchpad/private-persontransferjob-0
Reviewer Review Type Date Requested Status
Graham Binns (community) code Approve
Review via email: mp+41614@code.launchpad.net

Description of the change

This is my branch to skip PersonTransferJob in team visibility checks.

    lp:~sinzui/launchpad/private-persontransferjob-0
    Diff size: 75
    Launchpad bug: https://bugs.launchpad.net/bugs/665158
    Test command: ./bin/test -vv -t TestVisibilityConsistencyWarning
    Pre-implementation: no one
    Target release: 10.12

Skip PersonTransferJob in team visibility checks
------------------------------------------------

It should be possible to make a team private even if there is a pending
PersonTransferJob for sending emails.

Rules
-----

    * Add PersonTransferJob to the skip list used by
      visibilityConsistencyWarning.

QA
--

In quick succession
    * Register a new team
    * Add a member
    * Use the Administer page to change the team to private
    * Verify the team is private. There should not be a warning:
      This team cannot be converted to Private since it is referenced by
      a persontransferjob.

Lint
----

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

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

Added PersonTransferJob to the visibilityConsistencyWarning skip list. Removed
comment about private-membership teams which no longer exist.
  lib/lp/registry/model/person.py
  lib/lp/registry/tests/test_team.py

To post a comment you must log in.
Revision history for this message
Graham Binns (gmb) wrote :

From IRC:
<gmb> sinzui: Please add a comment / docstring to test_no_warning_for_PersonTransferJob() explaining the expected behaviour. Otherwise, r=me.

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 2010-11-18 12:05:34 +0000
3+++ lib/lp/registry/model/person.py 2010-11-23 16:17:48 +0000
4@@ -2091,13 +2091,12 @@
5 ('logintoken', 'requester'),
6 ('personlanguage', 'person'),
7 ('personlocation', 'person'),
8+ ('persontransferjob', 'minor_person'),
9+ ('persontransferjob', 'major_person'),
10 ('signedcodeofconduct', 'owner'),
11 ('sshkey', 'person'),
12 ('structuralsubscription', 'subscriber'),
13- # Private-membership teams can have members, but they
14- # cannot be members of other teams.
15 ('teammembership', 'team'),
16- # A private-membership team must be able to participate in itself.
17 ('teamparticipation', 'person'),
18 ('teamparticipation', 'team'),
19 # Skip mailing lists because if the mailing list is purged, it's
20@@ -2105,9 +2104,8 @@
21 ('mailinglist', 'team'),
22 ])
23
24- # Private teams may participate in more areas of Launchpad than
25- # Private Membership teams. The following relationships are allowable
26- # for Private teams and thus should be skipped.
27+ # The following relationships are allowable for Private teams and
28+ # thus should be skipped.
29 if new_value == PersonVisibility.PRIVATE:
30 skip.update([('bugsubscription', 'person'),
31 ('bugtask', 'assignee'),
32
33=== modified file 'lib/lp/registry/tests/test_team.py'
34--- lib/lp/registry/tests/test_team.py 2010-10-04 19:50:45 +0000
35+++ lib/lp/registry/tests/test_team.py 2010-11-23 16:17:48 +0000
36@@ -13,11 +13,14 @@
37 from canonical.launchpad.interfaces.emailaddress import IEmailAddressSet
38 from canonical.launchpad.interfaces.lpstorm import IMasterStore
39 from canonical.testing.layers import DatabaseFunctionalLayer
40+from lp.registry.enum import PersonTransferJobType
41 from lp.registry.interfaces.mailinglist import MailingListStatus
42 from lp.registry.interfaces.person import (
43 ITeamPublic,
44+ PersonVisibility,
45 TeamMembershipRenewalPolicy,
46 )
47+from lp.registry.model.persontransferjob import PersonTransferJob
48 from lp.testing import (
49 login_celebrity,
50 login_person,
51@@ -186,3 +189,24 @@
52
53 def test_default_membership_period_maximum(self):
54 ITeamPublic['defaultmembershipperiod'].validate(3650)
55+
56+
57+class TestVisibilityConsistencyWarning(TestCaseWithFactory):
58+
59+ layer = DatabaseFunctionalLayer
60+
61+ def setUp(self):
62+ super(TestVisibilityConsistencyWarning, self).setUp()
63+ self.team = self.factory.makeTeam()
64+ login_celebrity('admin')
65+
66+ def test_no_warning_for_PersonTransferJob(self):
67+ # An entry in the PersonTransferJob table does not cause a warning.
68+ member = self.factory.makePerson()
69+ metadata = ('some', 'arbitrary', 'metadata')
70+ person_transfer_job = PersonTransferJob(
71+ member, self.team,
72+ PersonTransferJobType.MEMBERSHIP_NOTIFICATION, metadata)
73+ self.assertEqual(
74+ None,
75+ self.team.visibilityConsistencyWarning(PersonVisibility.PRIVATE))