~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
Announcement Pages
==================

Tests for breadcrumbs, menus, and pages.


Breadcrumbs
-----------

Announcement breadcrumbs use the announcement title.

    >>> from canonical.lazr.testing.menus import make_fake_request

    >>> product = factory.makeProduct(name='cube')
    >>> owner = product.owner
    >>> announcement = product.announce(
    ...     user=owner, title='A title', summary='A summary')
    >>> view = create_initialized_view(announcement, '+index')

    >>> request = make_fake_request(
    ...     'http://launchpad.dev/joy-of-cooking/spam',
    ...     [product, announcement, view])
    >>> hierarchy = create_initialized_view(
    ...     announcement, '+hierarchy', request=request)
    >>> hierarchy.items
    [<DisplaynameBreadcrumb ... text='Cube'>,
     <TitleBreadcrumb ... text='A title'>]


Menus
-----

The announcement module provides two menus. There is an edit menu for an
announcement.

    >>> from lp.registry.browser.announcement import (
    ...     AnnouncementEditNavigationMenu, AnnouncementCreateNavigationMenu)
    >>> from lp.testing.menu import check_menu_links

    >>> check_menu_links(AnnouncementEditNavigationMenu(announcement))
    True

There is a menu for views for IHasAnnouncements objects to list there
announcements. The product implements IHasAnnouncements.

    >>> check_menu_links(AnnouncementCreateNavigationMenu(product))
    True


Batching
--------

Announcements are presented in batches.  For launchpad.dev the batch size is
smaller than in production to ease testing.

    >>> from lp.registry.interfaces.announcement import IAnnouncementSet
    >>> announcement_set = getUtility(IAnnouncementSet)
    >>> view = create_initialized_view(
    ...     announcement_set, '+announcements')
    >>> print len(list(view.announcements))
    20
    >>> print view.batch_size
    4
    >>> batch = view.announcement_nav.currentBatch()
    >>> print len(list(batch))
    4