~launchpad-pqm/launchpad/devel

1716.1.197 by Christian Reis
Seriously whack the team membership edit view, improving the way validation is done, preserving form values when submitting, and reducing the wordiness everywhere. De-indent some main page silliness. Simplify the template by using macros. Add a test that checks the form's behaviour
1
Start out by verifying the members page is sane.
1375 by Canonical.com Patch Queue Manager
Rewrote team's members page and added a pagetest for it.
2
7466.1.8 by Edwin Grubbs
Fixed test indentation.
3
    >>> browser.open('http://launchpad.dev/~ubuntu-team/+members')
4
    >>> 'Ubuntu Team' in browser.contents
5
    True
2578 by Canonical.com Patch Queue Manager
r=kiko, salgado. Multiple fixes foiled by odd PQM failure. Fixes for bug 2166: System error if trying to subscribe to a calendar while not logged in and bug 2328: Calendar should display this month, this week, this year instead of today for month, week and year views. Fixes bug 2501: edit hackergotchi link disabled. Adds hackergotchi pagetests and rewrites the validator code. Fixes bug 2580: Declined member's page is blank and has confusing title. Add declined portion to membership status page message and a pagetest for it. Patches by Diogo Matsubara <matsubara@async.com.br>. Fixes +subscribe to not require a Launchbag.user in the constructure, adds basic test and changes wording. Patch by Gabriel Neuman <gneuman@async.com.br>
6
1716.1.201 by Christian Reis
We all love pagetests
7
Let's take a look at Colin's subscription page. Colin is an
8
administrator and his subscription never expires.
1716.1.197 by Christian Reis
Seriously whack the team membership edit view, improving the way validation is done, preserving form values when submitting, and reducing the wordiness everywhere. De-indent some main page silliness. Simplify the template by using macros. Add a test that checks the form's behaviour
9
7466.1.8 by Edwin Grubbs
Fixed test indentation.
10
    >>> browser.addHeader('Authorization', 'Basic foo.bar@canonical.com:test')
11
    >>> browser.reload()
12
    >>> url = '/~ubuntu-team/+member/kamion'
13
    >>> browser.getLink(url=url).click()
14
9644.5.7 by Curtis Hovey
Updated to to verify title, not random page content.
15
    >>> print browser.title
16
    Colin Watson's membership : ...Ubuntu Team... team
7466.1.8 by Edwin Grubbs
Fixed test indentation.
17
    >>> "Active member" in browser.contents
18
    True
19
    >>> browser.getControl(name='admin').value
20
    ['yes']
21
22
    >>> browser.getControl(name='expires').value
23
    ['never']
3564.2.13 by Diogo Matsubara
fix bug 48858 and test conversion
24
25
Post an incomplete date and remove his administrator status.
26
5534.2.14 by Mark Shuttleworth
Address review comments for [r=barry]
27
There is some TestBrowser voodoo at work here. The datepicker widget now
28
allows you to render it disabled, which is neat because in the compound
29
widget that we have made it shows more clearly when the date is relevant and
30
when it is not if we disable it when it is not relevant (when the expiration
31
is set to "Never" with the radio button).
32
33
The Zope TestBrowser is smart enough to detect that the widget was rendered
34
with the input disabled, but not smart enough to play out the JavaScript
35
which would enable the input when the radio button was clicked to indicate
36
that a specific expiration date was desired. There is also no TestBrowser
37
way to "enable" the input. So, we have to reach into the guts of the
38
TestBrowser to manually re-enable the input. That's what the
39
control.mech_control.disabled=False stuff is.
40
7466.1.8 by Edwin Grubbs
Fixed test indentation.
41
    >>> browser.getControl(name='admin').value = ['no']
42
    >>> browser.getControl(name='expires').value = ['date']
43
    >>> expiry = browser.getControl(name='membership.expirationdate')
44
    >>> expiry.mech_control.disabled = False # control may have been disabled
45
    >>> expiry.value = 'ssdf'
46
    >>> browser.getControl('Change').click()
3564.2.13 by Diogo Matsubara
fix bug 48858 and test conversion
47
48
We get a nice error message
49
7466.1.8 by Edwin Grubbs
Fixed test indentation.
50
    >>> for tag in find_tags_by_class(browser.contents, 'message'):
51
    ...     print tag.renderContents()
52
    Invalid expiration: Invalid date value
3564.2.13 by Diogo Matsubara
fix bug 48858 and test conversion
53
54
Give up on change, nothing should have changed with Colin:
55
7466.1.8 by Edwin Grubbs
Fixed test indentation.
56
    >>> from zope.component import getUtility
11716.1.6 by Curtis Hovey
Converted glob imports in doctests to import for the true module.
57
    >>> from lp.registry.interfaces.person import IPersonSet
58
    >>> from lp.registry.interfaces.teammembership import ITeamMembershipSet
7466.1.8 by Edwin Grubbs
Fixed test indentation.
59
    >>> from canonical.launchpad.ftests import login, logout, ANONYMOUS
60
    >>> login(ANONYMOUS)
61
    >>> personset = getUtility(IPersonSet)
62
    >>> teammembershipset = getUtility(ITeamMembershipSet)
63
    >>> ubuntu_team = personset.getByName('ubuntu-team')
64
    >>> kamion = personset.getByName('kamion')
65
    >>> kamion_membership = teammembershipset.getByPersonAndTeam(
66
    ...     kamion, ubuntu_team)
67
    >>> kamion_membership.status.title
68
    'Administrator'
69
    >>> print kamion_membership.dateexpires
70
    None
71
    >>> logout()
3564.2.13 by Diogo Matsubara
fix bug 48858 and test conversion
72
73
74
Now revoke Colin's administrator status and make him expire in November
3564.2.15 by Diogo Matsubara
review comments
75
next year -- successfully.
1716.1.197 by Christian Reis
Seriously whack the team membership edit view, improving the way validation is done, preserving form values when submitting, and reducing the wordiness everywhere. De-indent some main page silliness. Simplify the template by using macros. Add a test that checks the form's behaviour
76
7466.1.8 by Edwin Grubbs
Fixed test indentation.
77
    >>> from datetime import datetime, timedelta
78
    >>> expire_date = datetime.utcnow() + timedelta(days=365)
3564.2.13 by Diogo Matsubara
fix bug 48858 and test conversion
79
7466.1.8 by Edwin Grubbs
Fixed test indentation.
80
    >>> browser.getControl(name='admin').value = ['no']
81
    >>> browser.getControl(name='expires').value = ['date']
82
    >>> expiry = browser.getControl(name='membership.expirationdate')
83
    >>> expiry.mech_control.disabled = False # control may have been disabled
84
    >>> expiry.value = expire_date.strftime('%Y-%m-%d')
85
    >>> browser.getControl(name='comment').value = 'Arfie'
86
    >>> browser.getControl('Change').click()
3564.2.13 by Diogo Matsubara
fix bug 48858 and test conversion
87
88
We're redirected to the +members page
89
7466.1.8 by Edwin Grubbs
Fixed test indentation.
90
    >>> browser.url
91
    'http://launchpad.dev/~ubuntu-team/+members'
3564.2.13 by Diogo Matsubara
fix bug 48858 and test conversion
92
7466.1.8 by Edwin Grubbs
Fixed test indentation.
93
    >>> login(ANONYMOUS)
94
    >>> kamion_membership = teammembershipset.getByPersonAndTeam(
95
    ...     kamion, ubuntu_team)
10163.2.2 by Brad Crittenden
Eliminate whitespace in a textarea.
96
    >>> print kamion_membership.status.title
97
    Approved
7466.1.8 by Edwin Grubbs
Fixed test indentation.
98
    >>> kamion_membership.dateexpires.date() == expire_date.date()
99
    True
10163.2.2 by Brad Crittenden
Eliminate whitespace in a textarea.
100
    >>> print kamion_membership.last_change_comment
101
    Arfie
7466.1.8 by Edwin Grubbs
Fixed test indentation.
102
    >>> logout()
1716.1.197 by Christian Reis
Seriously whack the team membership edit view, improving the way validation is done, preserving form values when submitting, and reducing the wordiness everywhere. De-indent some main page silliness. Simplify the template by using macros. Add a test that checks the form's behaviour
103
10163.2.2 by Brad Crittenden
Eliminate whitespace in a textarea.
104
If we revisit Colin's membership page we'll see the comment field is
105
pre-populated with the last comment.
106
107
    >>> url = '/~ubuntu-team/+member/kamion'
108
    >>> browser.getLink(url=url).click()
109
    >>> # Do not use 'print' for the following test as it will eliminate potential
110
    >>> # leading and trailing whitespace, which we don't want.
111
    >>> browser.getControl(name='comment').value
112
    'Arfie'
113
7466.1.6 by Edwin Grubbs
Addressed reviewer comments.
114
Jeff is also an administrator and his subscription never expires, but he can
115
demote himself. He starts by paging though the memberships, then he deselects
116
the administrator control on the membership page.
3564.2.13 by Diogo Matsubara
fix bug 48858 and test conversion
117
7466.1.8 by Edwin Grubbs
Fixed test indentation.
118
    >>> jdub_browser = setupBrowser(auth='Basic jeff.waugh@ubuntulinux.com:jdub')
119
    >>> jdub_browser.open('http://launchpad.dev/~ubuntu-team/+members')
120
    >>> jdub_browser.getLink('Next').click()
121
    >>> url = '/~ubuntu-team/+member/jdub'
122
    >>> jdub_browser.getLink(url=url).click()
123
9644.5.7 by Curtis Hovey
Updated to to verify title, not random page content.
124
    >>> print jdub_browser.title
125
    Jeff Waugh's membership : ...Ubuntu Team... team
7466.1.8 by Edwin Grubbs
Fixed test indentation.
126
    >>> "Active member" in jdub_browser.contents
127
    True
128
129
    >>> jdub_browser.getControl(name='admin').value = ['no']
130
    >>> jdub_browser.getControl('Change').click()
131
132
    >>> jdub_browser.url
133
    'http://launchpad.dev/~ubuntu-team/+members'
134
135
    >>> login(ANONYMOUS)
136
    >>> jdub = personset.getByName('jdub')
137
    >>> jdub_membership = teammembershipset.getByPersonAndTeam(
138
    ...     jdub, ubuntu_team)
139
    >>> jdub_membership.status.title
140
    'Approved'
141
    >>> logout()
3564.2.13 by Diogo Matsubara
fix bug 48858 and test conversion
142
1716.1.197 by Christian Reis
Seriously whack the team membership edit view, improving the way validation is done, preserving form values when submitting, and reducing the wordiness everywhere. De-indent some main page silliness. Simplify the template by using macros. Add a test that checks the form's behaviour
143
Sample person had his membership declined to the guadamen group. Test
144
that the page works and that foo.bar@canonical can access it.
2578 by Canonical.com Patch Queue Manager
r=kiko, salgado. Multiple fixes foiled by odd PQM failure. Fixes for bug 2166: System error if trying to subscribe to a calendar while not logged in and bug 2328: Calendar should display this month, this week, this year instead of today for month, week and year views. Fixes bug 2501: edit hackergotchi link disabled. Adds hackergotchi pagetests and rewrites the validator code. Fixes bug 2580: Declined member's page is blank and has confusing title. Add declined portion to membership status page message and a pagetest for it. Patches by Diogo Matsubara <matsubara@async.com.br>. Fixes +subscribe to not require a Launchbag.user in the constructure, adds basic test and changes wording. Patch by Gabriel Neuman <gneuman@async.com.br>
145
7466.1.8 by Edwin Grubbs
Fixed test indentation.
146
    >>> browser.open('http://launchpad.dev/~guadamen/+member/name12/')
3564.2.13 by Diogo Matsubara
fix bug 48858 and test conversion
147
7466.1.8 by Edwin Grubbs
Fixed test indentation.
148
    >>> 'Declined member' in browser.contents
149
    True
3361.1.1 by Diogo Matsubara
Fix https://launchpad.net/products/launchpad/+bug/34202 (Approving a proposed team member twice will cause an OOPS)
150
151
Dave Miller is a proposed member in Ubuntu Gnome Team.
152
If two people try to accept him as a member at the same time, the first one
153
should succeed and the second one receive a nice error message.
154
7466.1.8 by Edwin Grubbs
Fixed test indentation.
155
    >>> browser.open('http://launchpad.dev/~name18/+members')
156
    >>> url = '/~name18/+member/justdave'
157
    >>> browser.getLink(url=url).click()
3564.2.13 by Diogo Matsubara
fix bug 48858 and test conversion
158
7466.1.8 by Edwin Grubbs
Fixed test indentation.
159
    >>> second_browser = setupBrowser(auth='Basic foo.bar@canonical.com:test')
160
    >>> second_browser.open('http://launchpad.dev' + url)
3564.2.13 by Diogo Matsubara
fix bug 48858 and test conversion
161
162
Approve the membership in the first browser.
163
7466.1.8 by Edwin Grubbs
Fixed test indentation.
164
    >>> browser.getControl('Approve').click()
3564.2.13 by Diogo Matsubara
fix bug 48858 and test conversion
165
166
We're redirected to the members page.
167
7466.1.8 by Edwin Grubbs
Fixed test indentation.
168
    >>> browser.url
169
    'http://launchpad.dev/~name18/+members'
3564.2.13 by Diogo Matsubara
fix bug 48858 and test conversion
170
7466.1.8 by Edwin Grubbs
Fixed test indentation.
171
    >>> login(ANONYMOUS)
172
    >>> dave = personset.getByName('justdave')
173
    >>> ubuntu_gnome_team = personset.getByName('name18')
174
    >>> dave_membership = teammembershipset.getByPersonAndTeam(
175
    ...     dave, ubuntu_gnome_team)
176
    >>> dave_membership.status.title
177
    'Approved'
178
    >>> logout()
3564.2.13 by Diogo Matsubara
fix bug 48858 and test conversion
179
180
181
But in the second browser with the stale data we get an error message:
182
7466.1.8 by Edwin Grubbs
Fixed test indentation.
183
    >>> second_browser.getControl('Approve').click()
184
    >>> message = (
185
    ...     'The membership request for Dave Miller has already been processed')
186
    >>> message in second_browser.contents
187
    True
3691.436.64 by Mark Shuttleworth
Add page for team participation, and limit person home to recent memberships
188
10002.2.19 by Edwin Grubbs
Added test for restricted viewing of the former members of a team.
189
An admin can see the former members of the team.
190
191
    >>> browser.open('http://launchpad.dev/~name18/+members')
10002.2.20 by Edwin Grubbs
Fixed tests.
192
    >>> print extract_text(
193
    ...     find_tag_by_id(browser.contents, 'inactivemembers'))
10002.2.19 by Edwin Grubbs
Added test for restricted viewing of the former members of a team.
194
    Name    Joined in   Status...
195
196
Other users cannot see the former members of the team.
197
198
    >>> user_browser.open('http://launchpad.dev/~name18/+members')
10002.2.20 by Edwin Grubbs
Fixed tests.
199
    >>> print find_tag_by_id(user_browser.contents, 'inactivemembers')
10002.2.19 by Edwin Grubbs
Added test for restricted viewing of the former members of a team.
200
    None
201
3691.436.64 by Mark Shuttleworth
Add page for team participation, and limit person home to recent memberships
202
203
Team Participation page
204
=======================
205
206
The team participation page shows the team in which a person is a direct
10944.2.4 by Curtis Hovey
Removed moot and duplicate tests.
207
member, as well as the teams in which they are an indirect member.
208
209
Kiko has not joined any teams:
210
211
    >>> anon_browser.open('http://launchpad.dev/~kiko/+participation')
212
    >>> print extract_text(
213
    ...     find_tag_by_id(anon_browser.contents, 'no-participation'))
214
    Christian Reis has not yet joined any teams.
215
    >>> print find_tag_by_id(anon_browser.contents, 'participation')
216
    None
217
218
Sample Person has both direct and indirect memberships:
219
220
    >>> anon_browser.open('http://launchpad.dev/~name12/+participation')
221
    >>> content = find_main_content(anon_browser.contents)
222
    >>> print find_tag_by_id(content, 'no-participation')
223
    None
224
225
    >>> print extract_text(
226
    ...     find_tag_by_id(content, 'participation'))
227
    Team                  Joined      Role    Via                 Mailing List
228
    HWDB Team             2009-07-09  Member  &mdash;              &mdash;
229
    Landscape Developers  2006-07-11  Owner   &mdash;              &mdash;
230
    Launchpad Users       2008-11-26  Owner   &mdash;              &mdash;
231
    Ubuntu Gnome Team     &mdash;     Member  Warty Security Team  &mdash;
232
    Warty Security Team   2007-01-26  Member  &mdash;              &mdash;
233
234
User can see links to register teams and change their mailing list
235
subscriptions on their own participation page.
236
237
    >>> print find_tag_by_id(content, 'participation-actions')
238
    None
239
10944.2.7 by Curtis Hovey
Use a standard test browser.
240
    >>> user_browser.open('http://launchpad.dev/~no-priv/+participation')
10944.2.4 by Curtis Hovey
Removed moot and duplicate tests.
241
    >>> actions = find_tag_by_id(
10944.2.7 by Curtis Hovey
Use a standard test browser.
242
    ...     user_browser.contents, 'participation-actions')
10944.2.4 by Curtis Hovey
Removed moot and duplicate tests.
243
    >>> print extract_text(actions)
244
    Register a team
245
    Change mailing list subscriptions
246
10944.2.7 by Curtis Hovey
Use a standard test browser.
247
    >>> user_browser.getLink('Register a team')
10944.2.4 by Curtis Hovey
Removed moot and duplicate tests.
248
    <Link ... url='http://.../people/+newteam'>
10944.2.7 by Curtis Hovey
Use a standard test browser.
249
    >>> user_browser.getLink('Change mailing list subscriptions')
250
    <Link ... url='http://.../~no-priv/+editemails'>
10944.2.4 by Curtis Hovey
Removed moot and duplicate tests.
251
10977.6.9 by Curtis Hovey
Do not show the mailing list column on the team participation page.
252
Teams also have a participation page, but it does not include a mailing
253
list column.
254
10977.6.11 by Curtis Hovey
Do not show action links on the team participation page.
255
    >>> admin_browser.open('http://launchpad.dev/~admins/+participation')
10977.6.9 by Curtis Hovey
Do not show the mailing list column on the team participation page.
256
    >>> print extract_text(
10977.6.11 by Curtis Hovey
Do not show action links on the team participation page.
257
    ...     find_tag_by_id(admin_browser.contents, 'participation'))
10977.6.9 by Curtis Hovey
Do not show the mailing list column on the team participation page.
258
    Team                  Joined      Role    Via
259
    Mailing List Experts  2007-10-04  Owner   &mdash;