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

IPackageReleationshipSet provides a single page, '+render-list', via
SimpleView class.
This page is incorporated in parent pages with a specific relationship
group. Some example of pages using it are:

 * +builds/+build/1234/$binaryname
 * $distroseries/+source/$sourcename

Let's fill a IPackageRelationshipSet:

  >>> from lp.soyuz.browser.packagerelationship import PackageRelationshipSet

  >>> relationship_set = PackageRelationshipSet()
  >>> relationship_set.add(
  ...    name="foobar",
  ...    operator=">=",
  ...    version="1.0.2",
  ...    url="http://whatever/")

  >>> relationship_set.add(
  ...    name="test",
  ...    operator="=",
  ...    version="1.0",
  ...    url=None)

Note that iterations over PackageRelationshipSet are sorted
alphabetically according the relationship 'name':

  >>> [relationship.name for relationship in relationship_set]
  ['foobar', 'test']

It will cause all the relationship contents to be rendered in this order.

Let's get the view class:

  >>> from zope.component import queryMultiAdapter
  >>> from zope.publisher.browser import TestRequest

  >>> request = TestRequest(form={})
  >>> pkg_rel_view = queryMultiAdapter(
  ...     (relationship_set, request), name="+render-list")

This view has no methods, so just demonstrate that it renders
correctly like:

  <ul>
     <li>
        <a href="package-one-lp-page">package-one [(operator version)]</a>
     </li>
     ...
     <li>
        package-two [(operator version)]
     </li>
  </ul>

  >>> from lp.testing.pages import (
  ...     parse_relationship_section)

  >>> parse_relationship_section(pkg_rel_view())
  LINK: "foobar (&gt;= 1.0.2)" -> http://whatever/
  TEXT: "test (= 1.0)"


Note that no link is rendered for IPackageReleationship where 'url' is
None.