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

For all KarmaContexts we can see their top contributors.  That is, the
people with highest karma on that context.  We can see the top overall
contributors on a given context and the top contributors by category.

    >>> from canonical.launchpad.testing.pages import (
    ...     extract_text, find_tag_by_id)
    >>> from lp.registry.interfaces.product import IProductSet

    >>> product = getUtility(IProductSet).getByName('evolution')
    >>> user = product.owner
    >>> login_person(user)
    >>> view = create_initialized_view(
    ...     product, '+topcontributors', principal=user)
    >>> contributors = view._getTopContributorsWithLimit(limit=3)
    >>> [(contrib.person.name, contrib.karmavalue)
    ...     for contrib in contributors]
    [(u'name16', 175), (u'mark', 22), (u'carlos', 9)]

    >>> contributors = view.top_contributors_by_category
    >>> categories = sorted(contributors.keys())
    >>> for category in categories:
    ...     print category, [(contrib.person.name, contrib.karmavalue)
    ...                      for contrib in contributors[category]]
    Bug Management [(u'name16', 11)]
    Specification Tracking [(u'mark', 22)]
    Translations in Rosetta [(u'name16', 164), (u'carlos', 9)]

The view renders summaries by category.

    >>> content = find_tag_by_id(view.render(), 'maincontent')
    >>> print extract_text(find_tag_by_id(content, 'overall_top'))
    Person             Project Karma  Total Karma
    Foo Bar            175            241
    Mark Shuttleworth   22            130
    Carlos ...           9              9

    >>> print extract_text(find_tag_by_id(content, 'Bug Management'))
    Person   Bug Management Karma  Total Karma
    Foo Bar  11                     241

    >>> print extract_text(find_tag_by_id(content, 'Specification Tracking'))
    Person             Specification Tracking Karma  Total Karma
    Mark Shuttleworth  22                            130

    >>> print extract_text(find_tag_by_id(content, 'Translations in Rosetta'))
    Person      Translations in Rosetta Karma  Total Karma
    Foo Bar     164                            241
    Carlos ...    9                              9


Top contributors portlet
------------------------

The top contributors portlet shows the top contributors to a project

    >>> view = create_initialized_view(
    ...     product, name='+portlet-top-contributors', principal=user)
    >>> content = find_tag_by_id(view.render(), 'portlet-top-contributors')
    >>> print extract_text(content)
    More contributors Top contributors
    Foo Bar...
    Mark ...
    Carlos ...

It has a link to +topcontributors page.

    >>> css_class = {'class': 'menu-link-top_contributors sprite info'}
    >>> link = content.find('a', css_class)
    >>> print link['href']
    http://launchpad.dev/evolution/+topcontributors