~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
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
Packaging views
===============

Packaging links connect a sourcepackage to a distroseries and a productseries.


Productseries linking packages
------------------------------

Distro series sourcepackages can be linked to product series using the
+ubuntupkg named view.

    >>> from lp.app.interfaces.launchpad import ILaunchpadCelebrities

    >>> ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
    >>> hoary = ubuntu.getSeries('hoary')
    >>> sourcepackagename = factory.makeSourcePackageName('hot')
    >>> sourcepackage = factory.makeSourcePackage(
    ...     sourcepackagename=sourcepackagename, distroseries=hoary)
    >>> spph = factory.makeSourcePackagePublishingHistory(
    ...     sourcepackagename=sourcepackagename, distroseries=hoary)
    >>> product = factory.makeProduct(name="hot", displayname='Hot')
    >>> productseries = factory.makeProductSeries(
    ...     product=product, name='hotter')
    >>> productseries.sourcepackages
    []
    >>> transaction.commit()

The view has a label and requires a distro series and a source package name.
The distroseries field's vocabulary is the same as the ubuntu.series
attribute.

    >>> view = create_view(productseries, '+ubuntupkg')
    >>> print view.label
    Ubuntu source packaging

    >>> print view.page_title
    Ubuntu source packaging

    >>> print view.field_names
    ['sourcepackagename', 'distroseries']

    >>> print view.cancel_url
    http://launchpad.dev/hot/hotter

    >>> for series in ubuntu.series:
    ...     print series.name
    breezy-autotest
    grumpy
    hoary
    warty
    >>> view.setUpFields()
    >>> for term in view.form_fields['distroseries'].field.vocabulary:
    ...     print term.token
    breezy-autotest
    grumpy
    hoary
    warty

    >>> form = {
    ...     'field.distroseries': 'hoary',
    ...     'field.sourcepackagename': 'hot',
    ...     'field.packaging': 'Primary Project',
    ...     'field.actions.continue': 'Continue',
    ...     }
    >>> view = create_initialized_view(
    ...     productseries, '+ubuntupkg', form=form)
    >>> view.errors
    []
    >>> for package in productseries.sourcepackages:
    ...     print package.name
    hot

    >>> transaction.commit()


Productseries linking Ubuntu packages
-------------------------------------

The +ubuntupkg named view allows the user to update the current linked
Ubuntu package.

    >>> view = create_initialized_view(productseries, '+ubuntupkg')

    >>> print view.label
    Ubuntu source packaging

    >>> print view.page_title
    Ubuntu source packaging

    >>> print view.field_names
    ['sourcepackagename', 'distroseries']

    >>> print view.cancel_url
    http://launchpad.dev/hot/hotter

The view restricts the packaging to Ubuntu series, and default is the current
Ubuntu series.

    >>> print view.default_distroseries.name
    hoary

    >>> print view.widgets['distroseries']._getDefault().name
    hoary

    >>> for term in view.widgets['distroseries'].vocabulary:
    ...     print term.title
    Breezy Badger Autotest (6.6.6)
    Grumpy (5.10)
    Hoary (5.04)
    Warty (4.10)

The sourcepackagename is None if the package link was never set. The view's
packaging history is empty, and the sourcepackagename widget is empty.

    >>> new_productseries = factory.makeProductSeries(
    ...     product=product, name='cold')
    >>> view = create_initialized_view(new_productseries, '+ubuntupkg')

    >>> print view.default_sourcepackagename
    None

    >>> print view.widgets.get('sourcepackagename')._getFormValue()
    <BLANKLINE>

    >>> print view.ubuntu_history
    []

Series have been packaged in Ubuntu do have the current information and
a history.

    >>> view = create_initialized_view(productseries, '+ubuntupkg')
    >>> print view.default_sourcepackagename.name
    hot

    >>> print view.widgets.get('sourcepackagename')._getFormValue().name
    hot

    >>> for packaging in view.ubuntu_history:
    ...     print packaging.distroseries.name
    ...     print packaging.sourcepackagename.name
    hoary hot

The package in the current Ubuntu series can be updated.

    >>> thunderbird_spn = factory.getOrMakeSourcePackageName('thunderbird')
    >>> spph = factory.makeSourcePackagePublishingHistory(
    ...     sourcepackagename=thunderbird_spn, distroseries=hoary)

    >>> form = {
    ...     'field.sourcepackagename': 'thunderbird',
    ...     'field.actions.continue': 'Update',
    ...     }
    >>> view = create_initialized_view(
    ...     productseries, '+ubuntupkg', form=form)
    >>> view.errors
    []

We now have two source packages linked to our productseries.

    >>> for packaging in view.ubuntu_history:
    ...     print packaging.distroseries.name
    ...     print packaging.sourcepackagename.name
    hoary thunderbird
    hoary hot

It is not an error to submit the same sourcepackagename information, the
action is ignored because there is no change

    >>> form = {
    ...     'field.sourcepackagename': 'thunderbird',
    ...     'field.actions.continue': 'Update',
    ...     }
    >>> view = create_initialized_view(
    ...     productseries, '+ubuntupkg', form=form)
    >>> view.errors
    []

    >>> for packaging in view.ubuntu_history:
    ...     print packaging.distroseries.name
    ...     print packaging.sourcepackagename.name
    hoary thunderbird
    hoary hot

When the current Ubuntu series changes, the sourcepackagename is not known,
and a new entry can be added to the packaging history.

    >>> from lp.registry.interfaces.series import SeriesStatus

    >>> login('admin@canonical.com')
    >>> hoary.status = SeriesStatus.CURRENT
    >>> grumpy_series = ubuntu.getSeries('grumpy')
    >>> spph = factory.makeSourcePackagePublishingHistory(
    ...     sourcepackagename=sourcepackagename, distroseries=grumpy_series)
    >>> grumpy_series.status = SeriesStatus.FROZEN

    >>> a_user = factory.makePerson(name="hedgehog")
    >>> login_person(a_user)
    >>> form = {
    ...     'field.sourcepackagename': 'hot',
    ...     'field.actions.continue': 'Update',
    ...     }
    >>> view = create_initialized_view(
    ...     productseries, '+ubuntupkg', form=form)
    >>> view.errors
    []

    >>> print view.default_distroseries.name
    grumpy

    >>> print view.default_sourcepackagename
    None

    >>> for packaging in view.ubuntu_history:
    ...     print packaging.distroseries.name
    ...     print packaging.sourcepackagename.name
    grumpy hot
    hoary thunderbird
    hoary hot


Product packages view
----------------------

The +packages named view displays the packages links to the product's series.

    >>> view = create_initialized_view(product, name='+packages')
    >>> print view.label
    Linked packages

The view provides the series_batch property.

    >>> def print_packages(view):
    ...     for series in view.series_batch.batch:
    ...         print series.name
    ...         for package in series.packagings:
    ...             print '  Package %s: %s' % (
    ...                 package.sourcepackagename.name,
    ...                 package.distroseries.name)
    >>> print_packages(view)
    trunk
    hotter
      Package hot: grumpy
      Package thunderbird: hoary
      Package hot: hoary
    cold

The view provides the distro_packaging property that is a list of
dictionaries for the distributions and their packaging.  The list is
sorted by distribution with Ubuntu first and the rest in alphabetic
order.

    >>> for distro_dict in view.distro_packaging:
    ...     print distro_dict['distribution'].name
    ubuntu

A packaging link can be deleted if the owner believes it is an error. The
package linked to hoary is wrong; thunderbird is the wrong sourcepackage.
(Note that the packaging link for thunderbird in the sample data does not
have an owner, so we login as a member of distribution owner team
instead.)

    >>> from canonical.launchpad.testing.pages import find_tag_by_id
    >>> from lp.registry.interfaces.person import IPersonSet
    >>> steve_a = getUtility(IPersonSet).getByName('stevea')
    >>> login_person(steve_a)
    >>> view = create_initialized_view(
    ...     product, name='+packages', principal=steve_a)
    >>> print_packages(view)
    trunk
    hotter
      Package hot: grumpy
      Package thunderbird: hoary
      Package hot: hoary
    cold

    # There are links to the +remove-packaging page.
    >>> table = find_tag_by_id(view.render(), 'packages-hotter')
    >>> for link in table.findAll('a'):
    ...     if '+remove-packaging' in link['href']:
    ...         print link['href']
    http://launchpad.dev/ubuntu/grumpy/+source/hot/+remove-packaging
    http://launchpad.dev/ubuntu/hoary/+source/thunderbird/+remove-packaging
    http://launchpad.dev/ubuntu/hoary/+source/hot/+remove-packaging

    >>> [hoary_package] = [
    ...     package for series in view.series_batch.batch
    ...     for package in series.packagings
    ...     if package.distroseries.name == 'hoary' and
    ...         package.sourcepackagename.name == 'thunderbird']
    >>> form = {'field.actions.unlink': 'Unlink'}
    >>> unlink_view = create_initialized_view(
    ...     hoary_package.sourcepackage, name='+remove-packaging', form=form,
    ...     principal=steve_a)
    >>> unlink_view.errors
    []

    # The view has to be reloaded since view.series_batch is cached.
    >>> view = create_initialized_view(product, name='+packages')
    >>> print_packages(view)
    trunk
    hotter
      Package hot: grumpy
      Package hot: hoary
    cold


Distro series +packaging view
-----------------------------

The DistroSeriesPackagesView shows the packages in a distro series that
are linked to upstream projects.

    >>> view = create_initialized_view(hoary, name='+packaging')
    >>> print view.label
    All series packages linked to upstream project series

    >>> print view.page_title
    All upstream links

The view provides a property to get prioritized list of series packagings.
The packages that most need more information to send bugs upstream, build
packages, and sync translations are listed first. A distro series can have
thousands of upstream packaging links. The view provides a batch navigator
to access the packagings. The default batch size is 20.

    >>> batch_navigator = view.cached_packagings
    >>> batch_navigator.default_size
    20

    >>> print batch_navigator.heading
    packagings

    >>> for packaging in batch_navigator.batch:
    ...     print packaging.sourcepackagename.name
    netapplet
    evolution
    hot


Distro series +needs-packaging view
-----------------------------------

The +needs-packaging view lists the source packages that needs packaging
links to an upstream project.

    >>> view = create_initialized_view(hoary, name='+needs-packaging')
    >>> print view.label
    Packages that need upstream packaging links

    >>> print view.page_title
    Needs upstream links

The view provides the cached_unlinked_packages property to access a
`BatchNavigator` of `ISourcePackages`.

    >>> batch_navigator = view.cached_unlinked_packages
    >>> batch_navigator.default_size
    20

    >>> print batch_navigator.heading
    packages

    >>> for summary in batch_navigator.batch:
    ...     print summary['package'].name
    pmount
    alsa-utils
    cnews
    libstdc++
    linux-source-2.6.15
    thunderbird