~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
= Poll options =
 
2
 
 
3
A poll can have any number of options, but these must be created
 
4
before the poll has opened.
 
5
 
 
6
First we create a new poll to use throughout this test.
 
7
 
 
8
    >>> login('jeff.waugh@ubuntulinux.com')
 
9
    >>> from zope.component import getUtility
 
10
    >>> from lp.registry.interfaces.person import IPersonSet
 
11
    >>> factory.makePoll(getUtility(IPersonSet).getByName('ubuntu-team'),
 
12
    ...                  'dpl-2080', 'dpl-2080', 'dpl-2080')
 
13
    <Poll...
 
14
    >>> logout()
 
15
 
 
16
Our poll is not yet open, so new options can be added to it.
 
17
 
 
18
    >>> team_admin_browser = setupBrowser(
 
19
    ...     auth='Basic jeff.waugh@ubuntulinux.com:jdub')
 
20
    >>> team_admin_browser.open(
 
21
    ...     'http://launchpad.dev/~ubuntu-team/+poll/dpl-2080')
 
22
    >>> team_admin_browser.getLink('Add new option').click()
 
23
    >>> team_admin_browser.url
 
24
    'http://launchpad.dev/~ubuntu-team/+poll/dpl-2080/+newoption'
 
25
 
 
26
    >>> bill_name = (
 
27
    ...     'bill-amazingly-huge-middle-name-almost-impossible-to-read-graham')
 
28
    >>> team_admin_browser.getControl('Name').value = bill_name
 
29
    >>> team_admin_browser.getControl('Title').value = 'Bill Graham'
 
30
    >>> team_admin_browser.getControl('Create').click()
 
31
 
 
32
After adding an options we're taken back to the poll's home page.
 
33
 
 
34
    >>> team_admin_browser.url
 
35
    'http://launchpad.dev/~ubuntu-team/+poll/dpl-2080'
 
36
 
 
37
And here we see the option listed as one of the active options for this
 
38
poll.
 
39
 
 
40
    >>> print extract_text(
 
41
    ...     find_tag_by_id(team_admin_browser.contents, 'options'))
 
42
    Name        Title           Active
 
43
    bill...     Bill Graham     Yes
 
44
 
 
45
If we try to add a new option without providing a title, we'll get an error
 
46
message because the title is required.
 
47
 
 
48
    >>> team_admin_browser.getLink('Add new option').click()
 
49
    >>> team_admin_browser.url
 
50
    'http://launchpad.dev/~ubuntu-team/+poll/dpl-2080/+newoption'
 
51
 
 
52
    >>> will_name = (
 
53
    ...     'will-amazingly-huge-middle-name-almost-impossible-to-read-graham')
 
54
    >>> team_admin_browser.getControl('Name').value = will_name
 
55
    >>> team_admin_browser.getControl('Title').value = ''
 
56
    >>> team_admin_browser.getControl('Create').click()
 
57
 
 
58
    >>> print "\n".join(get_feedback_messages(team_admin_browser.contents))
 
59
    There is 1 error.
 
60
    Required input is missing.
 
61
 
 
62
If we try to add a new option with the same name of a existing option, we
 
63
should get a nice error message
 
64
 
 
65
    >>> team_admin_browser.getControl('Name').value = bill_name
 
66
    >>> team_admin_browser.getControl('Title').value = 'Bill Again'
 
67
    >>> team_admin_browser.getControl('Create').click()
 
68
 
 
69
    >>> print "\n".join(get_feedback_messages(team_admin_browser.contents))
 
70
    There is 1 error.
 
71
    ...is already in use by another option in this poll.
 
72
 
 
73
It's not possible to add/edit a poll option after a poll is open or closed.
 
74
That's only possible when the poll is not yet open.
 
75
 
 
76
    >>> team_admin_browser.open(
 
77
    ...     'http://launchpad.dev/~ubuntu-team/+poll/director-2004/+newoption')
 
78
 
 
79
    >>> "\n".join(get_feedback_messages(team_admin_browser.contents))
 
80
    u'You can&#8217;t add new options because the poll is already closed.'
 
81
 
 
82
    >>> team_admin_browser.open(
 
83
    ...     'http://launchpad.dev/~ubuntu-team/+poll/never-closes/+newoption')
 
84
    >>> "\n".join(get_feedback_messages(team_admin_browser.contents))
 
85
    u'You can&#8217;t add new options because the poll is already open.'