~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/registry/browser/tests/team-reassignment-view.txt

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-12-14 18:16:47 UTC
  • mfrom: (14515 devel)
  • mto: This revision was merged to the branch mainline in revision 14593.
  • Revision ID: launchpad@pqm.canonical.com-20111214181647-jh80eps1ndcy6hns
[rs=buildbot-poller] automatic merge from stable. Revisions: 14510,
        14511, 14512, 14513, 14514, 14515 included.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Team Reassignment
2
 
=================
3
 
 
4
 
There are many restrictions for setting the owner of a team.
5
 
 
6
 
 
7
 
Existing Team Error
8
 
-------------------
9
 
 
10
 
The ObjectReassignmentView displays radio buttons that give you the
11
 
option to create a team as opposed to using an existing team. If the
12
 
user tries to create a new team with the same name as an existing team,
13
 
an error is displayed.
14
 
 
15
 
    >>> from lp.registry.interfaces.person import IPersonSet
16
 
    >>> person_set = getUtility(IPersonSet)
17
 
    >>> operator = person_set.getByName('name12')
18
 
    >>> login_person(operator)
19
 
    >>> a_team = factory.makeTeam(
20
 
    ...     owner=operator, name='a-team', displayname='A-Team')
21
 
    >>> b_team = factory.makeTeam(
22
 
    ...     owner=operator, name='b-team', displayname='B-Team')
23
 
    >>> c_team = factory.makeTeam(
24
 
    ...     owner=operator, name='c-team', displayname='C-Team')
25
 
    >>> a_team.addMember(b_team, operator)
26
 
    (True...
27
 
    >>> b_team.addMember(c_team, operator)
28
 
    (True...
29
 
    >>> transaction.commit()
30
 
 
31
 
    >>> view = create_initialized_view(
32
 
    ...     c_team, '+reassign', principal=operator)
33
 
    >>> print list(w.name for w in view.widgets)
34
 
    ['field.owner', 'field.existing']
35
 
 
36
 
    >>> form = {
37
 
    ...     'field.owner': 'a-team',
38
 
    ...     'field.existing': 'new',
39
 
    ...     'field.actions.change': 'Change',
40
 
    ...     }
41
 
    >>> view = create_initialized_view(
42
 
    ...     a_team, '+reassign', form=form, principal=operator)
43
 
    >>> print view.errors
44
 
    [u"There's already a person/team with the name 'a-team' in Launchpad.
45
 
    Please choose a different name or select the option to make that
46
 
    person/team the new owner, if that's what you want."]
47
 
 
48
 
 
49
 
Cyclical Team Membership Error
50
 
------------------------------
51
 
 
52
 
When a person or team becomes the owner of another team, they are also
53
 
added as a member. Team memberships cannot be cyclical; therefore, the
54
 
team can't have its owner be a team of which it is a direct or indirect
55
 
member.
56
 
 
57
 
    >>> form = {
58
 
    ...     'field.owner': 'b-team',
59
 
    ...     'field.existing': 'existing',
60
 
    ...     'field.actions.change': 'Change',
61
 
    ...     }
62
 
    >>> view = create_initialized_view(
63
 
    ...     c_team, '+reassign', form=form, principal=operator)
64
 
    >>> print view.widget_errors
65
 
    {'owner': u'Circular team memberships are not allowed.
66
 
    B-Team cannot be the new team owner, since C-Team is a direct member
67
 
    of B-Team. <...><...>'}
68
 
 
69
 
If there is an indirect membership between the teams, the path between
70
 
the teams is displayed so that the user has a better idea how to resolve
71
 
the issue.
72
 
 
73
 
    >>> form = {
74
 
    ...     'field.owner': 'a-team',
75
 
    ...     'field.existing': 'existing',
76
 
    ...     'field.actions.change': 'Change',
77
 
    ...     }
78
 
    >>> view = create_initialized_view(
79
 
    ...     c_team, '+reassign', form=form, principal=operator)
80
 
    >>> print view.widget_errors
81
 
    {'owner': u'Circular team memberships are not allowed.
82
 
    A-Team cannot be the new team owner, since C-Team is an
83
 
    indirect member of A-Team. <...>(C-Team&rArr;B-Team&rArr;A-Team)<...>'}