~launchpad-pqm/launchpad/devel

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
= Editing FAQs =

It is possible to modify the title, keywords and content of an existing
FAQ. To do this, the user goes to the FAQ that he wants to modify and
clicks the 'Edit FAQ' action.

That action is only available to project owners and answer contacts.
That's why the link doesn't appear for the anonymous user nor
No Privileges Person:

    >>> from lp.services.helpers import backslashreplace
    >>> anon_browser.open('http://answers.launchpad.dev/firefox/+faq/7')
    >>> print backslashreplace(anon_browser.title)
    FAQ #7 : Questions : Mozilla Firefox

    >>> anon_browser.getLink('Edit FAQ')
    Traceback (most recent call last):
    ...
    LinkNotFoundError

    >>> user_browser.open('http://answers.launchpad.dev/firefox/+faq/7')
    >>> user_browser.getLink('Edit FAQ')
    Traceback (most recent call last):
    ...
    LinkNotFoundError

Even trying to access the link directly will fail:

    >>> anon_browser.open(
    ...     'http://answers.launchpad.dev/firefox/+faq/7/+edit')
    Traceback (most recent call last):
    ...
    Unauthorized: ...
    >>> user_browser.open(
    ...     'http://answers.launchpad.dev/firefox/+faq/7/+edit')
    Traceback (most recent call last):
    ...
    Unauthorized: ...

The link is accessible to Sample Person who is the owner of the Firefox
project:

    >>> browser.addHeader('Authorization', 'Basic test@canonical.com:test')
    >>> browser.open('http://answers.launchpad.dev/firefox/+faq/7')
    >>> browser.getLink('Edit FAQ').click()
    >>> print browser.url
    http://answers.launchpad.dev/firefox/+faq/7/+edit
    >>> print browser.title
    Edit FAQ...

The user can change the title, keywords and content fields. He then
clicks 'Save' to save his changes.

    >>> print browser.getControl('Title').value
    How do I install Java?
    >>> browser.getControl('Keywords').value
    ''
    >>> print browser.getControl('Content').value
    Windows
    On Windows, ...

    >>> browser.getControl('Keywords').value = (
    ...     'windows ubuntu plugins extensions')
    >>> browser.getControl('Content').value += (
    ...     '\nUbuntu:\nSee https://help.ubuntu.com/community/Java\n')

    >>> browser.getControl('Save').click()

The user can see his changes on the page:

    >>> print browser.url
    http://answers.launchpad.dev/firefox/+faq/7

    >>> print extract_text(find_tag_by_id(browser.contents, 'faq-keywords'))
    Keywords: windows ubuntu plugins extensions

    >>> print extract_text(find_tag_by_id(browser.contents, 'faq-content'))
    Windows
    On Windows,...
    Ubuntu: See https://help.ubuntu.com/community/Java

The 'Last updated by' field in the 'Lifecycle' portlet is updated
with the name of the user who made the last modification:

    >>> print extract_text(find_tag_by_id(browser.contents, 'faq-updated'))
    Last updated by: Sample Person on ...