~launchpad-pqm/launchpad/devel

2865.2.15 by Celso Providelo
add test for component & section classes and replacing flush_database_updates() with ordinary transaction.commit() in uploader-test
1
     Components and Sections
2
     ^^^^^^^^^^^^^^^^^^^^^^^
3
4285.2.1 by Mark Shuttleworth
Massive renaming of distrorelease to distroseries
4
Component refers to a group of packages within a DistroSeries that
3023.2.3 by Celso Providelo
Applying Review comments take 1
5
are related by their need, shipment condition and/or license.
2865.2.15 by Celso Providelo
add test for component & section classes and replacing flush_database_updates() with ordinary transaction.commit() in uploader-test
6
7
Zope auxiliary test toolchain:
8
11716.1.12 by Curtis Hovey
Sorted imports in doctests.
9
 >>> from zope.component import getUtility
4682.1.6 by Christian Reis
Use webapp.testing's verifyObject in all doctests, which copes with security-proxied objects, and remove the crack I added to the bug and bugtask uses of it.
10
 >>> from canonical.launchpad.webapp.testing import verifyObject
2865.2.15 by Celso Providelo
add test for component & section classes and replacing flush_database_updates() with ordinary transaction.commit() in uploader-test
11
12
Importing Component content class and its interface:
13
11716.1.12 by Curtis Hovey
Sorted imports in doctests.
14
 >>> from lp.soyuz.interfaces.component import IComponent
8294.6.8 by Julian Edwards
Section and component are now moved, and gina imports fixed.
15
 >>> from lp.soyuz.model.component import Component
2865.2.15 by Celso Providelo
add test for component & section classes and replacing flush_database_updates() with ordinary transaction.commit() in uploader-test
16
3023.2.3 by Celso Providelo
Applying Review comments take 1
17
Get an Component instance from the current sampledata:
2865.2.15 by Celso Providelo
add test for component & section classes and replacing flush_database_updates() with ordinary transaction.commit() in uploader-test
18
3023.2.3 by Celso Providelo
Applying Review comments take 1
19
 >>> main = Component.get(1)
2865.2.15 by Celso Providelo
add test for component & section classes and replacing flush_database_updates() with ordinary transaction.commit() in uploader-test
20
21
Test some attributes:
22
5821.10.3 by Celso Providelo
fixing components-and-sections.txt
23
 >>> print main.id, main.name
24
 1 main
2865.2.15 by Celso Providelo
add test for component & section classes and replacing flush_database_updates() with ordinary transaction.commit() in uploader-test
25
3023.2.3 by Celso Providelo
Applying Review comments take 1
26
Check if the instance corresponds to the declared interface:
2865.2.15 by Celso Providelo
add test for component & section classes and replacing flush_database_updates() with ordinary transaction.commit() in uploader-test
27
3023.2.3 by Celso Providelo
Applying Review comments take 1
28
 >>> verifyObject(IComponent, main)
2865.2.15 by Celso Providelo
add test for component & section classes and replacing flush_database_updates() with ordinary transaction.commit() in uploader-test
29
 True
30
31
Now perform the tests for the Component ContentSet class, ComponentSet.
32
33
Check if it can be imported:
34
8294.6.8 by Julian Edwards
Section and component are now moved, and gina imports fixed.
35
 >>> from lp.soyuz.interfaces.component import IComponentSet
2865.2.38 by Celso Providelo
merge from dsilvers' buildd-fixes, 3 conflicts solved and test fixes, 2 rosettatests remaing failing with new year's bug.
36
2865.2.15 by Celso Providelo
add test for component & section classes and replacing flush_database_updates() with ordinary transaction.commit() in uploader-test
37
Check we can use the set as a utility:
38
39
 >>> component_set = getUtility(IComponentSet)
40
3023.2.3 by Celso Providelo
Applying Review comments take 1
41
Test iteration over the sampledata default components:
2865.2.15 by Celso Providelo
add test for component & section classes and replacing flush_database_updates() with ordinary transaction.commit() in uploader-test
42
43
 >>> for c in component_set:
5821.10.3 by Celso Providelo
fixing components-and-sections.txt
44
 ...    print c.name
45
 main
46
 restricted
47
 universe
48
 multiverse
49
 partner
2865.2.15 by Celso Providelo
add test for component & section classes and replacing flush_database_updates() with ordinary transaction.commit() in uploader-test
50
3023.2.3 by Celso Providelo
Applying Review comments take 1
51
by default, they are ordered by 'id'.
52
2865.2.15 by Celso Providelo
add test for component & section classes and replacing flush_database_updates() with ordinary transaction.commit() in uploader-test
53
Test __getitem__ method, retrieving a component by name:
54
5821.10.3 by Celso Providelo
fixing components-and-sections.txt
55
 >>> print component_set['universe'].name
56
 universe
2865.2.15 by Celso Providelo
add test for component & section classes and replacing flush_database_updates() with ordinary transaction.commit() in uploader-test
57
58
Test get method, retrieving a component by its id:
59
5821.10.3 by Celso Providelo
fixing components-and-sections.txt
60
 >>> print component_set.get(2).name
61
 restricted
2865.2.15 by Celso Providelo
add test for component & section classes and replacing flush_database_updates() with ordinary transaction.commit() in uploader-test
62
63
New component creation for a given name:
64
65
 >>> new_comp = component_set.new('test')
5821.10.3 by Celso Providelo
fixing components-and-sections.txt
66
 >>> print new_comp.id, new_comp.name
67
 6 test
2865.2.15 by Celso Providelo
add test for component & section classes and replacing flush_database_updates() with ordinary transaction.commit() in uploader-test
68
69
Ensuring a component (if not found, create it):
70
71
 >>> component_set.ensure('test').id
5821.10.3 by Celso Providelo
fixing components-and-sections.txt
72
 6
2865.2.15 by Celso Providelo
add test for component & section classes and replacing flush_database_updates() with ordinary transaction.commit() in uploader-test
73
74
 >>> component_set.ensure('test2').id
5821.10.3 by Celso Providelo
fixing components-and-sections.txt
75
 7
2865.2.15 by Celso Providelo
add test for component & section classes and replacing flush_database_updates() with ordinary transaction.commit() in uploader-test
76
77
78
Importing Section content class and its interface:
79
11716.1.12 by Curtis Hovey
Sorted imports in doctests.
80
 >>> from lp.soyuz.interfaces.section import ISection
8294.6.8 by Julian Edwards
Section and component are now moved, and gina imports fixed.
81
 >>> from lp.soyuz.model.section import Section
2865.2.15 by Celso Providelo
add test for component & section classes and replacing flush_database_updates() with ordinary transaction.commit() in uploader-test
82
83
Get a Section instance from the current sampledata:
84
3023.2.3 by Celso Providelo
Applying Review comments take 1
85
 >>> base = Section.get(1)
2865.2.15 by Celso Providelo
add test for component & section classes and replacing flush_database_updates() with ordinary transaction.commit() in uploader-test
86
87
Test some attributes:
88
5821.10.3 by Celso Providelo
fixing components-and-sections.txt
89
 >>> print base.id, base.name
90
 1 base
2865.2.15 by Celso Providelo
add test for component & section classes and replacing flush_database_updates() with ordinary transaction.commit() in uploader-test
91
3023.2.3 by Celso Providelo
Applying Review comments take 1
92
Check if the instance corresponds to the declared interface:
2865.2.15 by Celso Providelo
add test for component & section classes and replacing flush_database_updates() with ordinary transaction.commit() in uploader-test
93
8303.14.17 by Julian Edwards
Fix the components-and-sections doctest.
94
 >>> verifyObject(ISection, base)
95
 True
2865.2.15 by Celso Providelo
add test for component & section classes and replacing flush_database_updates() with ordinary transaction.commit() in uploader-test
96
97
Now perform the tests for the Section ContentSet class, SectionSet.
98
99
Check if it can be imported:
100
8294.6.8 by Julian Edwards
Section and component are now moved, and gina imports fixed.
101
 >>> from lp.soyuz.interfaces.section import ISectionSet
2865.2.38 by Celso Providelo
merge from dsilvers' buildd-fixes, 3 conflicts solved and test fixes, 2 rosettatests remaing failing with new year's bug.
102
2865.2.15 by Celso Providelo
add test for component & section classes and replacing flush_database_updates() with ordinary transaction.commit() in uploader-test
103
Check we can use the set as a utility:
104
105
 >>> section_set = getUtility(ISectionSet)
106
107
Test iteration over the sampledata default sections:
108
109
 >>> for s in section_set:
5821.10.3 by Celso Providelo
fixing components-and-sections.txt
110
 ...    print s.name
111
 base
112
 web
113
 editors
114
 admin
115
 comm
116
 debian-installer
117
 devel
118
 doc
119
 games
120
 gnome
121
 graphics
122
 interpreters
123
 kde
124
 libdevel
125
 libs
126
 mail
127
 math
128
 misc
129
 net
130
 news
131
 oldlibs
132
 otherosfs
133
 perl
134
 python
135
 shells
136
 sound
137
 tex
138
 text
139
 translations
140
 utils
141
 x11
142
 electronics
143
 embedded
144
 hamradio
145
 science
2865.2.15 by Celso Providelo
add test for component & section classes and replacing flush_database_updates() with ordinary transaction.commit() in uploader-test
146
3023.2.3 by Celso Providelo
Applying Review comments take 1
147
by default they are ordered by 'id'.
148
2865.2.15 by Celso Providelo
add test for component & section classes and replacing flush_database_updates() with ordinary transaction.commit() in uploader-test
149
Test __getitem__ method, retrieving a section by name:
150
5821.10.3 by Celso Providelo
fixing components-and-sections.txt
151
 >>> print section_set['science'].name
152
 science
2865.2.15 by Celso Providelo
add test for component & section classes and replacing flush_database_updates() with ordinary transaction.commit() in uploader-test
153
154
Test get method, retrieving a section by its id:
155
5821.10.3 by Celso Providelo
fixing components-and-sections.txt
156
 >>> print section_set.get(2).name
157
 web
2865.2.15 by Celso Providelo
add test for component & section classes and replacing flush_database_updates() with ordinary transaction.commit() in uploader-test
158
159
New section creation for a given name:
160
161
 >>> new_sec = section_set.new('test')
5821.10.3 by Celso Providelo
fixing components-and-sections.txt
162
 >>> print new_sec.id, new_sec.name
163
 36 test
2865.2.15 by Celso Providelo
add test for component & section classes and replacing flush_database_updates() with ordinary transaction.commit() in uploader-test
164
165
Ensuring a section (if not found, create it):
166
167
 >>> section_set.ensure('test').id
5821.10.3 by Celso Providelo
fixing components-and-sections.txt
168
 36
2865.2.15 by Celso Providelo
add test for component & section classes and replacing flush_database_updates() with ordinary transaction.commit() in uploader-test
169
170
 >>> section_set.ensure('test2').id
5821.10.3 by Celso Providelo
fixing components-and-sections.txt
171
 37