~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
First, some setup. Find out what the latest [private] bug reported on
Ubuntu evolution is, so we can avoid hardcoding its ID here:

    >>> from zope.component import getUtility
    >>> from canonical.launchpad.webapp.interfaces import ILaunchBag
    >>> from lp.bugs.interfaces.bugtask import BugTaskSearchParams
    >>> from lp.registry.interfaces.distribution import IDistributionSet
    >>> from lp.registry.interfaces.sourcepackagename import (
    ...     ISourcePackageNameSet,
    ...     )
    >>> from canonical.launchpad.ftests import login, logout

    >>> login("foo.bar@canonical.com")
    >>> launchbag = getUtility(ILaunchBag)
    >>> evo = getUtility(ISourcePackageNameSet).queryByName("evolution")
    >>> params = BugTaskSearchParams(user=launchbag.user,
    ...     sourcepackagename=evo, orderby="-id")

    >>> ubuntu = getUtility(IDistributionSet).getByName("ubuntu")
    >>> latest_evo_task = ubuntu.searchTasks(params)[0]
    >>> latest_evo_bug = latest_evo_task.bug.id
    >>> logout()

Unsubscribing from a private bug redirects you to the bug listing (see
further down for an exception to this rule.) Let's demonstrate by having
Foo Bar, an admin, subscribe Sample Person to a private bug.

    >>> browser = setupBrowser(auth="Basic foo.bar@canonical.com:test")
    >>> add_subscriber_url = (
    ...     "http://launchpad.dev/ubuntu/+source/evolution/+bug/%s"
    ...     "/+addsubscriber" % latest_evo_bug)
    >>> browser.open(add_subscriber_url)
    >>> browser.getControl("Person").value = "name12"
    >>> browser.getControl("Subscribe user").click()
    >>> browser.url
    'http://bugs.launchpad.dev/ubuntu/+source/evolution/+bug/...'