~launchpad-pqm/launchpad/devel

9116.1.5 by Curtis Hovey
Updated the sourcepackage uptream series form to UI 3.0.
1
SourcePackage views
2
===================
3
10212.1.2 by Brad Crittenden
Add upstream associations portlet to display upstream info or give the user a chance to make the connection.
4
Edit packaging view
10212.1.6 by Brad Crittenden
Fixes from code review.
5
-------------------
9116.1.5 by Curtis Hovey
Updated the sourcepackage uptream series form to UI 3.0.
6
7
    >>> product = factory.makeProduct(name='bonkers', displayname='Bonkers')
8
    >>> productseries = factory.makeProductSeries(
9
    ...     name='crazy', product=product)
10
    >>> distribution = factory.makeDistribution(
11
    ...     name='youbuntu', displayname='Youbuntu')
13597.1.1 by Jeroen Vermeulen
Get rid of factory.make[Ubuntu]DistroRelease. And some lint.
12
    >>> distroseries = factory.makeDistroSeries(
13
    ...     name='busy', distribution=distribution)
9116.1.5 by Curtis Hovey
Updated the sourcepackage uptream series form to UI 3.0.
14
    >>> sourcepackagename = factory.makeSourcePackageName(name='bonkers')
15
    >>> package = factory.makeSourcePackage(
16
    ...     sourcepackagename=sourcepackagename, distroseries=distroseries)
17
9772.7.3 by Curtis Hovey
Fixed the +edit-package field description. Recreated the field to make it required. Added a rule to set the default value of the field's widget.
18
    >>> view = create_initialized_view(package, name='+edit-packaging')
9116.1.5 by Curtis Hovey
Updated the sourcepackage uptream series form to UI 3.0.
19
    >>> print view.label
9772.7.3 by Curtis Hovey
Fixed the +edit-package field description. Recreated the field to make it required. Added a rule to set the default value of the field's widget.
20
    Link to an upstream project
9116.1.5 by Curtis Hovey
Updated the sourcepackage uptream series form to UI 3.0.
21
22
    >>> print view.page_title
9772.7.3 by Curtis Hovey
Fixed the +edit-package field description. Recreated the field to make it required. Added a rule to set the default value of the field's widget.
23
    Link to an upstream project
9116.1.5 by Curtis Hovey
Updated the sourcepackage uptream series form to UI 3.0.
24
10304.4.8 by Edwin Grubbs
Fixed tests.
25
    >>> print view.view.cancel_url
9116.1.5 by Curtis Hovey
Updated the sourcepackage uptream series form to UI 3.0.
26
    http://launchpad.dev/youbuntu/busy/+source/bonkers
27
9772.7.3 by Curtis Hovey
Fixed the +edit-package field description. Recreated the field to make it required. Added a rule to set the default value of the field's widget.
28
10304.4.8 by Edwin Grubbs
Fixed tests.
29
The view allows the logged in user to change product series field. The
30
value of the product field is None by default because it is not required
31
to create a source package.
32
33
    # The product field is added in setUpFields().
34
    >>> view.view.field_names
35
    ['__visited_steps__']
36
    >>> [form_field.__name__ for form_field in view.view.form_fields]
37
    ['__visited_steps__', 'product']
38
39
    >>> print view.view.widgets.get('product')._getFormValue()
9772.7.3 by Curtis Hovey
Fixed the +edit-package field description. Recreated the field to make it required. Added a rule to set the default value of the field's widget.
40
    <BLANKLINE>
41
9116.1.5 by Curtis Hovey
Updated the sourcepackage uptream series form to UI 3.0.
42
    >>> print package.productseries
43
    None
44
10304.4.8 by Edwin Grubbs
Fixed tests.
45
This is a multistep view. In the first step, the product is specified.
46
47
    >>> print view.view.__class__.__name__
48
    SourcePackageChangeUpstreamStepOne
49
    >>> print view.view.request.form
50
    {'field.__visited_steps__': 'sourcepackage_change_upstream_step1'}
51
9116.1.5 by Curtis Hovey
Updated the sourcepackage uptream series form to UI 3.0.
52
    >>> login_person(product.owner)
53
    >>> form = {
10304.4.8 by Edwin Grubbs
Fixed tests.
54
    ...     'field.product': 'bonkers',
55
    ...     'field.actions.continue': 'Continue',
9116.1.5 by Curtis Hovey
Updated the sourcepackage uptream series form to UI 3.0.
56
    ...     }
10304.4.8 by Edwin Grubbs
Fixed tests.
57
    >>> form.update(view.view.request.form)
9116.1.5 by Curtis Hovey
Updated the sourcepackage uptream series form to UI 3.0.
58
    >>> view = create_initialized_view(
59
    ...     package, name='+edit-packaging', form=form,
60
    ...     principal=product.owner)
10304.4.8 by Edwin Grubbs
Fixed tests.
61
    >>> view.view.errors
9116.1.5 by Curtis Hovey
Updated the sourcepackage uptream series form to UI 3.0.
62
    []
63
10304.4.8 by Edwin Grubbs
Fixed tests.
64
In the second step, one of the series of the previously selected
65
product can be chosen from a list of options.
66
67
    >>> print view.view.__class__.__name__
68
    SourcePackageChangeUpstreamStepTwo
69
    >>> print view.view.request.form['field.__visited_steps__']
70
    sourcepackage_change_upstream_step1|sourcepackage_change_upstream_step2
71
    >>> [term.token for term in view.view.widgets['productseries'].vocabulary]
72
    ['trunk', 'crazy']
73
74
    >>> form = {
75
    ...     'field.__visited_steps__': 'sourcepackage_change_upstream_step2',
76
    ...     'field.product': 'bonkers',
77
    ...     'field.productseries': 'crazy',
78
    ...     'field.actions.continue': 'continue',
79
    ...     }
80
    >>> view = create_initialized_view(
81
    ...     package, name='+edit-packaging', form=form,
82
    ...     principal=product.owner)
83
84
    >>> ignored = view.view.render()
85
    >>> print view.view.next_url
9116.1.5 by Curtis Hovey
Updated the sourcepackage uptream series form to UI 3.0.
86
    http://launchpad.dev/youbuntu/busy/+source/bonkers
87
88
    >>> for notification in view.request.response.notifications:
89
    ...     print notification.message
90
    Upstream link updated.
91
92
    >>> print package.productseries.name
93
    crazy
9772.7.1 by Curtis Hovey
Validate the sourcepackage +edit-packaging form.
94
9772.7.2 by Curtis Hovey
Do not state the upstream link was updated if nothing was changed.
95
    >>> transaction.commit()
96
10304.4.8 by Edwin Grubbs
Fixed tests.
97
The form shows the current product if it is set.
9772.7.3 by Curtis Hovey
Fixed the +edit-package field description. Recreated the field to make it required. Added a rule to set the default value of the field's widget.
98
99
    >>> view = create_initialized_view(package, name='+edit-packaging')
10304.4.8 by Edwin Grubbs
Fixed tests.
100
101
    >>> print view.view.widgets.get('product')._getFormValue().name
102
    bonkers
103
104
If the same product as the current product series is selected,
105
then the current product series will be the selected option.
106
107
    >>> form = {
108
    ...     'field.product': 'bonkers',
109
    ...     'field.actions.continue': 'Continue',
110
    ...     }
111
    >>> form.update(view.view.request.form)
112
    >>> view = create_initialized_view(
113
    ...     package, name='+edit-packaging', form=form,
114
    ...     principal=product.owner)
115
    >>> print view.view.widgets.get('productseries')._getFormValue().name
9772.7.3 by Curtis Hovey
Fixed the +edit-package field description. Recreated the field to make it required. Added a rule to set the default value of the field's widget.
116
    crazy
117
10304.4.8 by Edwin Grubbs
Fixed tests.
118
The form requires a product. An error is raised if the field is left
9772.7.1 by Curtis Hovey
Validate the sourcepackage +edit-packaging form.
119
empty.
120
121
    >>> form = {
11275.1.3 by Edwin Grubbs
Make multistep tests safer.
122
    ...     'field.__visited_steps__': 'sourcepackage_change_upstream_step1',
10304.4.8 by Edwin Grubbs
Fixed tests.
123
    ...     'field.product': '',
124
    ...     'field.actions.continue': 'Continue',
9772.7.1 by Curtis Hovey
Validate the sourcepackage +edit-packaging form.
125
    ...     }
126
    >>> view = create_initialized_view(
127
    ...     package, name='+edit-packaging', form=form,
128
    ...     principal=product.owner)
10304.4.8 by Edwin Grubbs
Fixed tests.
129
    >>> for error in view.view.errors:
9772.7.1 by Curtis Hovey
Validate the sourcepackage +edit-packaging form.
130
    ...     print error
10304.4.8 by Edwin Grubbs
Fixed tests.
131
    ('product', u'Project', RequiredMissing())
9772.7.2 by Curtis Hovey
Do not state the upstream link was updated if nothing was changed.
132
133
Submitting the same product series as the current packaging is not an error,
134
but there is no notification message that the upstream link was updated.
135
136
    >>> form = {
11275.1.3 by Edwin Grubbs
Make multistep tests safer.
137
    ...     'field.__visited_steps__': 'sourcepackage_change_upstream_step2',
138
    ...     'field.product': 'bonkers',
139
    ...     'field.productseries': 'crazy',
140
    ...     'field.actions.continue': 'Continue',
9772.7.2 by Curtis Hovey
Do not state the upstream link was updated if nothing was changed.
141
    ...     }
142
    >>> view = create_initialized_view(
143
    ...     package, name='+edit-packaging', form=form,
144
    ...     principal=product.owner)
11275.1.3 by Edwin Grubbs
Make multistep tests safer.
145
    >>> print view.view
146
    <...SourcePackageChangeUpstreamStepTwo object...>
147
    >>> print view.view.next_url
148
    http://launchpad.dev/youbuntu/busy/+source/bonkers
10304.4.8 by Edwin Grubbs
Fixed tests.
149
    >>> view.view.errors
9772.7.2 by Curtis Hovey
Do not state the upstream link was updated if nothing was changed.
150
    []
151
152
    >>> print view.request.response.notifications
153
    []
10212.1.2 by Brad Crittenden
Add upstream associations portlet to display upstream info or give the user a chance to make the connection.
154
10374.2.6 by Edwin Grubbs
Added test for removing packaging.
155
10212.1.2 by Brad Crittenden
Add upstream associations portlet to display upstream info or give the user a chance to make the connection.
156
Upstream associations portlet
157
-----------------------------
158
159
The upstreams associations portlet either displays the upstream
160
information if it is already set or gives the user the opportunity to
161
suggest the association.  The suggestion is based on a
162
ProductVocabulary query using the source package name.
163
164
Since the bonkers source project was associated previously with the
165
bonkers project, the portlet will display that information.
166
167
    >>> view = create_initialized_view(package, name='+portlet-associations')
168
    >>> for product in view.product_suggestions:
169
    ...     print product.name
170
    bonkers
171
172
    >>> from canonical.launchpad.testing.pages import (
173
    ...     extract_text, find_tag_by_id)
10374.2.6 by Edwin Grubbs
Added test for removing packaging.
174
    >>> content = find_tag_by_id(view.render(), 'upstreams')
175
    >>> for link in content.findAll('a'):
176
    ...     print link['href']
177
    /bonkers
178
    /bonkers/crazy
179
    .../+source/bonkers/+edit-packaging
180
    .../+source/bonkers/+remove-packaging
181
182
    >>> print extract_text(content)
10374.2.5 by Edwin Grubbs
Fixed tests.
183
    Bonkers...crazy...
10304.2.3 by Brad Crittenden
Test fixes for new portlet information
184
    Bug supervisor: no
185
    Bug tracker: no
186
    Branch: no
11869.10.15 by Curtis Hovey
Removed duplicate tests. Updated tests to verify the message to package a new upstream release.
187
    There are no registered releases for the Bonkers &rArr; crazy.
10212.1.2 by Brad Crittenden
Add upstream associations portlet to display upstream info or give the user a chance to make the connection.
188
189
A new source project that is not linked to an upstream will result in
190
the portlet showing the suggested project.
191
192
    >>> product = factory.makeProduct(name='lernid', displayname='Lernid')
193
    >>> sourcepackagename = factory.makeSourcePackageName(name='lernid')
194
    >>> package = factory.makeSourcePackage(
195
    ...     sourcepackagename=sourcepackagename, distroseries=distroseries)
196
197
    >>> view = create_initialized_view(package, name='+portlet-associations')
198
    >>> for product in view.product_suggestions:
199
    ...     print product.name
200
    lernid
201
202
    >>> content = extract_text(find_tag_by_id(view.render(), 'no-upstreams'))
203
    >>> print content
204
    Launchpad doesn&#8217;t know which project and series this
205
    package belongs to. ...
206
    Is the following project the upstream for this source package?
10212.1.6 by Brad Crittenden
Fixes from code review.
207
    Registered upstream project:
10850.6.2 by Curtis Hovey
Update the SP upstream project suggestions to look like the project package suggestions.
208
    Lernid
209
    Choose another upstream project
11275.1.2 by Edwin Grubbs
Fixed tests.
210
    Register the upstream project
10850.6.2 by Curtis Hovey
Update the SP upstream project suggestions to look like the project package suggestions.
211
212
The form does not steal focus because it is not the primary purpose of the
213
page.
214
215
    >>> print view.initial_focus_widget
216
    None
217
218
If there are multiple potential matches, the first 9 are shown. The 10th
219
item is reserved for the "Choose another upstream project" option.
220
221
    >>> product = factory.makeProduct(
222
    ...     name='lernid-dev', displayname='Lernid Dev')
10212.1.2 by Brad Crittenden
Add upstream associations portlet to display upstream info or give the user a chance to make the connection.
223
    >>> view = create_initialized_view(package, name='+portlet-associations')
224
    >>> for product in view.product_suggestions:
225
    ...     print product.name
226
    lernid
227
    lernid-dev
228
10850.6.2 by Curtis Hovey
Update the SP upstream project suggestions to look like the project package suggestions.
229
    >>> view.max_suggestions
230
    9
231
10212.1.2 by Brad Crittenden
Add upstream associations portlet to display upstream info or give the user a chance to make the connection.
232
    >>> content = extract_text(find_tag_by_id(view.render(), 'no-upstreams'))
233
    >>> print content
234
    Launchpad doesn&#8217;t know which project and series this
235
    package belongs to. ...
236
    Is one of these projects the upstream for this source package?
10212.1.6 by Brad Crittenden
Fixes from code review.
237
    Registered upstream project:
10212.1.3 by Brad Crittenden
Fixed test failures do to output change.
238
    Lernid...
239
    Lernid Dev...
10850.6.2 by Curtis Hovey
Update the SP upstream project suggestions to look like the project package suggestions.
240
    Choose another upstream project
11275.1.2 by Edwin Grubbs
Fixed tests.
241
    Register the upstream project
10850.6.2 by Curtis Hovey
Update the SP upstream project suggestions to look like the project package suggestions.
242
243
Choosing the "Choose another upstream project" option redirects the user
244
to the +edit-packaging page where the user can search for a project.
245
246
    >>> form = {
247
    ...     'field.upstream': 'OTHER_UPSTREAM',
248
    ...     'field.actions.link': 'Link to Upstream Project',
249
    ...     }
250
    >>> view = create_initialized_view(
251
    ...     package, name='+portlet-associations', form=form)
252
    >>> view.errors
253
    []
254
    >>> print view.next_url
255
    http://launchpad.dev/youbuntu/busy/+source/lernid/+edit-packaging
10304.2.4 by Brad Crittenden
Changes from review. Added link to edit product series. Added test for the new view property 'has_bugtracker'.
256
257
10374.2.11 by Edwin Grubbs
Fixed tests.
258
Upstream connections view
259
-------------------------
260
10304.2.4 by Brad Crittenden
Changes from review. Added link to edit product series. Added test for the new view property 'has_bugtracker'.
261
The view includes a property for determining if the project has a bug
262
tracker, though the rules are somewhat complicated.
263
264
If the view's package has no productseries set then has_bugtracker is False.
265
266
267
    >>> product = factory.makeProduct(name='stinky', displayname='Stinky')
268
    >>> productseries = factory.makeProductSeries(
269
    ...     name='stinkyseries', product=product)
13597.1.1 by Jeroen Vermeulen
Get rid of factory.make[Ubuntu]DistroRelease. And some lint.
270
    >>> distroseries = factory.makeDistroSeries(
271
    ...     name='wonky', distribution=distribution)
11275.1.3 by Edwin Grubbs
Make multistep tests safer.
272
    >>> sourcepackagename = factory.makeSourcePackageName(
273
    ...     name='stinkypackage')
10304.2.4 by Brad Crittenden
Changes from review. Added link to edit product series. Added test for the new view property 'has_bugtracker'.
274
    >>> package = factory.makeSourcePackage(
275
    ...     sourcepackagename=sourcepackagename, distroseries=distroseries)
276
10374.2.11 by Edwin Grubbs
Fixed tests.
277
    >>> view = create_initialized_view(
278
    ...     package, name='+upstream-connections')
10304.2.4 by Brad Crittenden
Changes from review. Added link to edit product series. Added test for the new view property 'has_bugtracker'.
279
280
    >>> print package.productseries
281
    None
282
    >>> print view.has_bugtracker
283
    False
284
285
So let's set the product series so we can do more interesting testing.
286
10304.2.5 by Brad Crittenden
More test and template tweaking.
287
    >>> package.setPackaging(productseries, product.owner)
10304.2.4 by Brad Crittenden
Changes from review. Added link to edit product series. Added test for the new view property 'has_bugtracker'.
288
    >>> print package.productseries.name
289
    stinkyseries
290
291
If a product is not part of a project group and its bug tracker is not
292
set then the view property is false.
293
10374.2.11 by Edwin Grubbs
Fixed tests.
294
    >>> view = create_initialized_view(
295
    ...     package, name='+upstream-connections')
10304.2.4 by Brad Crittenden
Changes from review. Added link to edit product series. Added test for the new view property 'has_bugtracker'.
296
11411.7.21 by j.c.sackett
Fixed another bad reference re: involvment.
297
    >>> print product.bug_tracking_usage.name
298
    UNKNOWN
10304.2.4 by Brad Crittenden
Changes from review. Added link to edit product series. Added test for the new view property 'has_bugtracker'.
299
    >>> print product.bugtracker
300
    None
301
    >>> print view.has_bugtracker
302
    False
303
304
Having official_malone set results in has_bugtracker being true.
305
10304.2.5 by Brad Crittenden
More test and template tweaking.
306
    >>> login_person(product.owner)
10304.2.4 by Brad Crittenden
Changes from review. Added link to edit product series. Added test for the new view property 'has_bugtracker'.
307
    >>> product.official_malone = True
308
    >>> print view.has_bugtracker
309
    True
310
311
Having a bug_tracker set also results in has_bugtracker being true (a
312
bit of a tautology you'd think).
313
314
    >>> product.official_malone = False
10304.2.5 by Brad Crittenden
More test and template tweaking.
315
    >>> bugtracker = factory.makeBugTracker()
316
    >>> product.bugtracker = bugtracker
10304.2.4 by Brad Crittenden
Changes from review. Added link to edit product series. Added test for the new view property 'has_bugtracker'.
317
    >>> print view.has_bugtracker
318
    True
319
320
If the product has no bug tracker and is in a project group with no
321
bug tracker then the property is false.
322
323
    >>> product.bugtracker = None
324
    >>> project = factory.makeProject()
325
    >>> print project.bugtracker
326
    None
327
    >>> product.project = project
328
    >>> print view.has_bugtracker
329
    False
330
331
If the product's project does have a bug tracker then the product
332
inherits it.
333
334
    >>> login_person(project.owner)
10304.2.5 by Brad Crittenden
More test and template tweaking.
335
    >>> project.bugtracker = bugtracker
10304.2.4 by Brad Crittenden
Changes from review. Added link to edit product series. Added test for the new view property 'has_bugtracker'.
336
    >>> print view.has_bugtracker
337
    True
10374.2.6 by Edwin Grubbs
Added test for removing packaging.
338
339
340
Remove packaging view
341
---------------------
342
343
This view allows removal of the packaging link from the sourcepackage
344
to the project series.
345
346
    >>> view = create_initialized_view(package, name='+remove-packaging')
347
    >>> print view.label
348
    Unlink an upstream project
349
350
    >>> print view.page_title
351
    Unlink an upstream project
352
353
    >>> print view.cancel_url
354
    http://launchpad.dev/youbuntu/wonky/+source/stinkypackage
355
12818.1.1 by Abel Deuring
avoid an OOPS when somebody tries to delete a packaging link more than once.
356
    >>> user = package.packaging.owner
357
    >>> login_person(user)
10374.2.6 by Edwin Grubbs
Added test for removing packaging.
358
    >>> form = {'field.actions.unlink': 'Unlink'}
359
    >>> view = create_initialized_view(
12818.1.1 by Abel Deuring
avoid an OOPS when somebody tries to delete a packaging link more than once.
360
    ...     package, name='+remove-packaging', form=form, principal=user)
10374.2.6 by Edwin Grubbs
Added test for removing packaging.
361
    >>> view.errors
362
    []
363
364
    >>> for notification in view.request.response.notifications:
365
    ...     print notification.message
10374.2.11 by Edwin Grubbs
Fixed tests.
366
    Removed upstream association between Stinky stinkyseries series and Wonky.
10374.2.6 by Edwin Grubbs
Added test for removing packaging.
367
12818.1.1 by Abel Deuring
avoid an OOPS when somebody tries to delete a packaging link more than once.
368
If somebody attempts to remove this packaging link a second time,
369
they get a message telling them that the link has already been
370
deleted.
371
372
    >>> view = create_initialized_view(
373
    ...     package, name='+remove-packaging', form=form, principal=user)
374
    >>> view.errors
375
    []
376
377
    >>> for notification in view.request.response.notifications:
378
    ...     print notification.message
379
    The packaging link has already been deleted.
380
10374.2.6 by Edwin Grubbs
Added test for removing packaging.
381
    >>> view = create_initialized_view(package, name='+portlet-associations')
382
    >>> print extract_text(find_tag_by_id(view.render(), 'no-upstreams'))
10850.6.2 by Curtis Hovey
Update the SP upstream project suggestions to look like the project package suggestions.
383
    Launchpad doesn&#8217;t know which project ...
10374.2.6 by Edwin Grubbs
Added test for removing packaging.
384
    There are no projects registered in Launchpad that are a potential
385
    match for this source package. Can you help us find one?
10850.6.2 by Curtis Hovey
Update the SP upstream project suggestions to look like the project package suggestions.
386
    Registered upstream project:
387
    Choose another upstream project
11275.1.2 by Edwin Grubbs
Fixed tests.
388
    Register the upstream project