~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/registry/stories/team-polls/create-polls.txt

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-01-04 23:32:39 UTC
  • mfrom: (12156.3.1 revenge-of-the-polls)
  • Revision ID: launchpad@pqm.canonical.com-20110104233239-g2pkdei031w0vh96
[r=flacoste][ui=none][bug=697290] Restore team polls.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Let's first setup some objects that we'll need.
 
2
 
 
3
    >>> no_priv_browser = setupBrowser(
 
4
    ...     auth='Basic no-priv@canonical.com:test')
 
5
    >>> team_admin_browser = setupBrowser(
 
6
    ...    'Basic jeff.waugh@ubuntulinux.com:jdub')
 
7
 
 
8
If you're not logged in and go to the +polls page of the "Ubuntu Team"
 
9
you'll see a link to login as a team administrator.
 
10
 
 
11
    >>> anon_browser.open('http://launchpad.dev/~ubuntu-team')
 
12
    >>> anon_browser.getLink('Show polls').click()
 
13
    >>> anon_browser.url
 
14
    'http://launchpad.dev/~ubuntu-team/+polls'
 
15
    >>> anon_browser.getLink('Log in as an admin to set up a new poll').url
 
16
    'http://launchpad.dev/~ubuntu-team/+login'
 
17
 
 
18
Try to create a new poll logged in as 'no-priv', which is not a team
 
19
administrator. There's no link leading to the +newpoll page, but the user can
 
20
easily guess it.
 
21
 
 
22
    >>> no_priv_browser.open('http://launchpad.dev/~ubuntu-team/+newpoll')
 
23
    Traceback (most recent call last):
 
24
    ...
 
25
    Unauthorized:...
 
26
 
 
27
Now we're logged in as Jeff Waugh which is a team administrator and thus can
 
28
create a new poll.
 
29
 
 
30
    >>> team_admin_browser.open('http://launchpad.dev/~ubuntu-team')
 
31
    >>> team_admin_browser.getLink('Show polls').click()
 
32
    >>> team_admin_browser.getLink('Set up a new poll').click()
 
33
    >>> team_admin_browser.url
 
34
    'http://launchpad.dev/~ubuntu-team/+newpoll'
 
35
 
 
36
    >>> team_admin_browser.title
 
37
    'New poll for team Ubuntu Team...
 
38
 
 
39
First we try to create a poll with a invalid name to
 
40
test the name field validator.
 
41
 
 
42
    >>> team_admin_browser.getControl(
 
43
    ...     'The unique name of this poll').value = 'election_2100'
 
44
    >>> team_admin_browser.getControl(
 
45
    ...     'The title of this poll').value = 'Presidential Election 2100'
 
46
    >>> proposition = 'Who is going to be the next president?'
 
47
    >>> team_admin_browser.getControl(
 
48
    ...     'The proposition that is going to be voted').value = proposition
 
49
    >>> team_admin_browser.getControl(
 
50
    ...     'Users can spoil their votes?').selected = True
 
51
    >>> team_admin_browser.getControl(
 
52
    ...     name='field.dateopens').value = '2100-06-04 02:00:00+00:00'
 
53
    >>> team_admin_browser.getControl(
 
54
    ...     name='field.datecloses').value = '2100-07-04 02:00:00+00:00'
 
55
    >>> team_admin_browser.getControl('Continue').click()
 
56
 
 
57
    >>> print "\n".join(get_feedback_messages(team_admin_browser.contents))
 
58
    There is 1 error.
 
59
    Invalid name 'election_2100'. Names must be at least two characters ...
 
60
 
 
61
We fix the name, but swap the dates. Again a nice error message.
 
62
 
 
63
    >>> team_admin_browser.getControl(
 
64
    ...     'The unique name of this poll').value = 'election-2100'
 
65
    >>> team_admin_browser.getControl(
 
66
    ...     name='field.dateopens').value = '2100-07-04 02:00:00+00:00'
 
67
    >>> team_admin_browser.getControl(
 
68
    ...     name='field.datecloses').value = '2100-06-04 02:00:00+00:00'
 
69
    >>> team_admin_browser.getControl('Continue').click()
 
70
 
 
71
    >>> print "\n".join(get_feedback_messages(team_admin_browser.contents))
 
72
    There is 1 error.
 
73
    A poll cannot close at the time (or before) it opens.
 
74
 
 
75
Now we get it right.
 
76
 
 
77
    >>> team_admin_browser.getControl(
 
78
    ...     name='field.dateopens').value = '2100-06-04 02:00:00+00:00'
 
79
    >>> team_admin_browser.getControl(
 
80
    ...     name='field.datecloses').value = '2100-07-04 02:00:00+00:00'
 
81
    >>> team_admin_browser.getControl('Continue').click()
 
82
 
 
83
We're redirected to the newly created poll page.
 
84
 
 
85
    >>> team_admin_browser.url
 
86
    'http://launchpad.dev/~ubuntu-team/+poll/election-2100'
 
87
 
 
88
Create a new poll that starts in 2025-06-04 and will last until 2035.
 
89
 
 
90
    >>> team_admin_browser.open(
 
91
    ...     'http://launchpad.dev/~ubuntu-team/+newpoll')
 
92
    >>> team_admin_browser.getControl(
 
93
    ...     'The unique name of this poll').value = 'dpl-2080'
 
94
    >>> team_admin_browser.getControl(
 
95
    ...     'The title of this poll').value = 'Debian Project Leader Election 2080'
 
96
    >>> proposition = 'The next debian project leader'
 
97
    >>> team_admin_browser.getControl(
 
98
    ...     'The proposition that is going to be voted').value = proposition
 
99
    >>> team_admin_browser.getControl(
 
100
    ...     'Users can spoil their votes?').selected = True
 
101
    >>> team_admin_browser.getControl(
 
102
    ...     name='field.dateopens').value = '2025-06-04 02:00:00+00:00'
 
103
    >>> team_admin_browser.getControl(
 
104
    ...     name='field.datecloses').value = '2035-06-04 02:00:00+00:00'
 
105
    >>> team_admin_browser.getControl('Continue').click()
 
106
 
 
107
We're redirected to the newly created poll
 
108
 
 
109
    >>> team_admin_browser.url
 
110
    'http://launchpad.dev/~ubuntu-team/+poll/dpl-2080'
 
111
    >>> team_admin_browser.title
 
112
    'Debian Project Leader Election 2080 : \xe2\x80\x9cUbuntu Team\xe2\x80\x9d team'
 
113
    >>> print_location(team_admin_browser.contents)
 
114
    Hierarchy:  ?Ubuntu Team? team > Debian Project Leader Election 2080
 
115
    Tabs:
 
116
    * Overview (selected) - http://launchpad.dev/~ubuntu-team
 
117
    * Code - http://code.launchpad.dev/~ubuntu-team
 
118
    * Bugs - http://bugs.launchpad.dev/~ubuntu-team
 
119
    * Blueprints - http://blueprints.launchpad.dev/~ubuntu-team
 
120
    * Translations - http://translations.launchpad.dev/~ubuntu-team
 
121
    * Answers - http://answers.launchpad.dev/~ubuntu-team
 
122
    Main heading: Debian Project Leader Election 2080
 
123
    >>> team_admin_browser.getLink('add an option').url
 
124
    'http://launchpad.dev/%7Eubuntu-team/+poll/dpl-2080/+newoption'
 
125
 
 
126
Now lets try to insert a poll with the name of a existing one.
 
127
 
 
128
# XXX matsubara 2006-07-17 bug=53302:
 
129
# There's no link to get back to +polls.
 
130
 
 
131
    >>> team_admin_browser.open(
 
132
    ...     'http://launchpad.dev/~ubuntu-team/+newpoll')
 
133
    >>> team_admin_browser.getControl(
 
134
    ...     'The unique name of this poll').value = 'dpl-2080'
 
135
    >>> team_admin_browser.getControl(
 
136
    ...     'The title of this poll').value = 'Debian Project Leader Election 2080'
 
137
    >>> proposition = 'The next debian project leader'
 
138
    >>> team_admin_browser.getControl(
 
139
    ...     'The proposition that is going to be voted').value = proposition
 
140
    >>> team_admin_browser.getControl(
 
141
    ...     'Users can spoil their votes?').selected = True
 
142
    >>> team_admin_browser.getControl(
 
143
    ...     name='field.dateopens').value = '2025-06-04 02:00:00+00:00'
 
144
    >>> team_admin_browser.getControl(
 
145
    ...     name='field.datecloses').value = '2035-06-04 02:00:00+00:00'
 
146
    >>> team_admin_browser.getControl('Continue').click()
 
147
 
 
148
    >>> print "\n".join(get_feedback_messages(team_admin_browser.contents))
 
149
    There is 1 error.
 
150
    dpl-2080 is already in use by another poll in this team.
 
151
 
 
152
When creating a new poll, its start date must be at least 12 hours from
 
153
now, so that the user creating it has a chance to add some options before
 
154
the poll opens -- at that point new options cannot be added.
 
155
 
 
156
    >>> team_admin_browser.getControl('The unique name').value = 'today'
 
157
    >>> from datetime import datetime
 
158
    >>> today = datetime.today().strftime('%Y-%m-%d')
 
159
    >>> team_admin_browser.getControl(name='field.dateopens').value = today
 
160
    >>> team_admin_browser.getControl('Continue').click()
 
161
    >>> print "\n".join(get_feedback_messages(team_admin_browser.contents))
 
162
    There is 1 error.
 
163
    A poll cannot open less than 12 hours after it's created.