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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
Components and Sections
^^^^^^^^^^^^^^^^^^^^^^^
Component refers to a group of packages within a DistroSeries that
are related by their need, shipment condition and/or license.
Zope auxiliary test toolchain:
>>> from zope.component import getUtility
>>> from lp.services.webapp.testing import verifyObject
Importing Component content class and its interface:
>>> from lp.soyuz.interfaces.component import IComponent
>>> from lp.soyuz.model.component import Component
Get an Component instance from the current sampledata:
>>> main = Component.get(1)
Test some attributes:
>>> print main.id, main.name
1 main
Check if the instance corresponds to the declared interface:
>>> verifyObject(IComponent, main)
True
Now perform the tests for the Component ContentSet class, ComponentSet.
Check if it can be imported:
>>> from lp.soyuz.interfaces.component import IComponentSet
Check we can use the set as a utility:
>>> component_set = getUtility(IComponentSet)
Test iteration over the sampledata default components:
>>> for c in component_set:
... print c.name
main
restricted
universe
multiverse
partner
by default, they are ordered by 'id'.
Test __getitem__ method, retrieving a component by name:
>>> print component_set['universe'].name
universe
Test get method, retrieving a component by its id:
>>> print component_set.get(2).name
restricted
New component creation for a given name:
>>> new_comp = component_set.new('test')
>>> print new_comp.id, new_comp.name
6 test
Ensuring a component (if not found, create it):
>>> component_set.ensure('test').id
6
>>> component_set.ensure('test2').id
7
Importing Section content class and its interface:
>>> from lp.soyuz.interfaces.section import ISection
>>> from lp.soyuz.model.section import Section
Get a Section instance from the current sampledata:
>>> base = Section.get(1)
Test some attributes:
>>> print base.id, base.name
1 base
Check if the instance corresponds to the declared interface:
>>> verifyObject(ISection, base)
True
Now perform the tests for the Section ContentSet class, SectionSet.
Check if it can be imported:
>>> from lp.soyuz.interfaces.section import ISectionSet
Check we can use the set as a utility:
>>> section_set = getUtility(ISectionSet)
Test iteration over the sampledata default sections:
>>> for s in section_set:
... print s.name
base
web
editors
admin
comm
debian-installer
devel
doc
games
gnome
graphics
interpreters
kde
libdevel
libs
mail
math
misc
net
news
oldlibs
otherosfs
perl
python
shells
sound
tex
text
translations
utils
x11
electronics
embedded
hamradio
science
by default they are ordered by 'id'.
Test __getitem__ method, retrieving a section by name:
>>> print section_set['science'].name
science
Test get method, retrieving a section by its id:
>>> print section_set.get(2).name
web
New section creation for a given name:
>>> new_sec = section_set.new('test')
>>> print new_sec.id, new_sec.name
36 test
Ensuring a section (if not found, create it):
>>> section_set.ensure('test').id
36
>>> section_set.ensure('test2').id
37
|