1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
= Voting on polls =
Foo Bar (a member of the ubuntu-team) wants to vote on the 'never-closes'
poll, which is a poll with secret votes, which means he'll get a token that he
must use to see/change his vote afterwards.
>>> browser = setupBrowser(auth='Basic foo.bar@canonical.com:test')
>>> browser.open('http://launchpad.dev/~ubuntu-team/+polls')
>>> browser.getLink('A random poll that never closes').click()
>>> browser.url
'http://launchpad.dev/~ubuntu-team/+poll/never-closes/+vote'
>>> print find_tag_by_id(browser.contents, 'your-vote').renderContents()
<BLANKLINE>
...
<h2>Your current vote</h2>
...You have not yet voted in this poll...
<h2>Vote now</h2>
...
>>> browser.getControl('None of these options').selected = True
>>> browser.getControl('Continue').click()
>>> browser.url
'http://launchpad.dev/~ubuntu-team/+poll/never-closes/+vote'
>>> tags = find_tags_by_class(browser.contents, "informational message")
>>> for tag in tags:
... print tag.renderContents()
Your vote has been recorded. If you want to view or change it later you
must write down this key: ...
>>> print find_tag_by_id(browser.contents, 'your-vote').renderContents()
<BLANKLINE>
...
<h2>Your current vote</h2>
...Your current vote is for <b> none of the options. </b>...
...
Foo Bar will now vote on a poll with public votes.
>>> browser.open('http://launchpad.dev/~ubuntu-team/+polls')
>>> browser.getLink('A public poll that never closes').click()
>>> browser.url
'http://launchpad.dev/~ubuntu-team/+poll/never-closes4/+vote'
>>> print find_tag_by_id(browser.contents, 'your-vote').renderContents()
<BLANKLINE>
...
<h2>Your current vote</h2>
...You have not yet voted in this poll...
<h2>Vote now</h2>
...
>>> browser.getControl('OptionB').selected = True
>>> browser.getControl('Continue').click()
>>> browser.url
'http://launchpad.dev/~ubuntu-team/+poll/never-closes4/+vote'
>>> tags = find_tags_by_class(browser.contents, "informational message")
>>> for tag in tags:
... print tag.renderContents()
Your vote was stored successfully. You can come back to this page at any
time before this poll closes to view or change your vote, if you want.
>>> print find_tag_by_id(browser.contents, 'your-vote').renderContents()
<BLANKLINE>
...
<h2>Your current vote</h2>
...Your current vote is for <b>OptionB</b>...
...
For convenience we provide an option for when the user doesn't want to vote
yet.
>>> team_admin_browser = setupBrowser(
... auth='Basic jeff.waugh@ubuntulinux.com:jdub')
>>> team_admin_browser.open(
... 'http://launchpad.dev/~ubuntu-team/+poll/never-closes/+vote')
>>> not_yet_voted_message = 'You have not yet voted in this poll.'
>>> not_yet_voted_message in team_admin_browser.contents
True
>>> team_admin_browser.getControl(name='newoption').value = ["donotvote"]
>>> team_admin_browser.getControl(name='continue').click()
>>> contents = team_admin_browser.contents
>>> for tag in find_tags_by_class(contents, "informational message"):
... print tag.renderContents()
You chose not to vote yet.
>>> print find_tag_by_id(contents, 'your-vote').renderContents()
<BLANKLINE>
...
<h2>Your current vote</h2>
...You have not yet voted in this poll...
...
== No permission to vote ==
Only members of a given team can vote on that team's polls. Other users can't,
even if they guess the URL for the voting page.
>>> non_member_browser = setupBrowser(
... auth='Basic test@canonical.com:test')
>>> non_member_browser.open(
... 'http://launchpad.dev/~ubuntu-team/+poll/never-closes/+vote')
>>> for tag in find_tags_by_class(
... non_member_browser.contents, "informational message"):
... print tag.renderContents()
You can’t vote in this poll because you’re not a member
of Ubuntu Team.
== Closed polls ==
It's not possible to vote on closed polls, even if we manually craft the URL.
>>> team_admin_browser.open(
... 'http://launchpad.dev/~ubuntu-team/+poll/leader-2004')
>>> print find_tag_by_id(
... team_admin_browser.contents, 'maincontent').renderContents()
<BLANKLINE>
...
<h2>Voting has closed</h2>
...
>>> team_admin_browser.open(
... 'http://launchpad.dev/~ubuntu-team/+poll/leader-2004/+vote')
>>> print find_tag_by_id(
... team_admin_browser.contents, 'maincontent').renderContents()
<BLANKLINE>
...
<p class="informational message">
This poll is already closed.
</p>
...
>>> team_admin_browser.getControl(name='continue')
Traceback (most recent call last):
...
LookupError: name 'continue'
The same is true for condorcet polls too.
>>> team_admin_browser.open(
... 'http://launchpad.dev/~ubuntu-team/+poll/director-2004')
>>> print find_tag_by_id(
... team_admin_browser.contents, 'maincontent').renderContents()
<BLANKLINE>
...
<h2>Voting has closed</h2>
...
>>> team_admin_browser.getControl(name='continue')
Traceback (most recent call last):
...
LookupError: name 'continue'
>>> team_admin_browser.open(
... 'http://launchpad.dev/~ubuntu-team/+poll/director-2004/+vote')
>>> for message in get_feedback_messages(team_admin_browser.contents):
... print message
This poll is already closed.
|