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
|
= BinaryPackageRelease Pages =
>>> from zope.component import getMultiAdapter
>>> from canonical.launchpad.webapp.servers import LaunchpadTestRequest
>>> from lp.soyuz.model.binarypackagerelease import BinaryPackageRelease
>>> pmount_bin = BinaryPackageRelease.get(15)
>>> pmount_bin.name
u'pmount'
>>> pmount_bin.version
u'0.1-1'
Get a "mock" request:
>>> mock_form = {}
>>> request = LaunchpadTestRequest(form=mock_form)
Let's instantiate the view for +portlet-details:
>>> pmount_view = getMultiAdapter(
... (pmount_bin, request), name="+portlet-details")
Main functionality of this class is to provide abstracted model of the
stored package relationships. They are provided as a
IPackageRelationshipSet. (see package-relationship.txt).
>>> pmount_deps = pmount_view.depends()
>>> from lp.soyuz.interfaces.packagerelationship import IPackageRelationshipSet
>>> from canonical.launchpad.webapp.testing import verifyObject
>>> verifyObject(IPackageRelationshipSet, pmount_deps)
True
Let's check the rendering parameters for a specific dep:
Note that the 'url' attribute points to the
IDistroArchSeriesBinaryPackage for 'at'.
Besides that, 'operator' can be null regarding the given relationship,
it automatically means that 'version' will be an empty string.
Another possible case is the binary package mentioned in
package relationship isn't present in the DistroArchSeries in
question. In this case 'url' will be None, which indicates no link
should be rendered for this dependency.
>>> for dep in pmount_deps:
... dep.name, dep.operator, dep.version, dep.url
('at', '>=', '3.14156', u'http://launchpad.dev/ubuntu/hoary/i386/at')
('linux-2.6.12', None, '', u'http://launchpad.dev/ubuntu/hoary/i386/linux-2.6.12')
('tramp-package', None, '', None)
Other relationship groups use the same mechanism.
|