~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
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
Canonical URL examples
======================

Here we have a bunch of examples of canonical urls of database and other
objects.

Ideally, we'd check that the URLs we have here can be accessed through the
publisher.  We'll do that later.  For now, we'll just check that the URLs
are what we expect them to be for various example objects.

    >>> from zope.component import getUtility
    >>> from lp.services.webapp import canonical_url
    >>> from lp.app.interfaces.launchpad import ILaunchpadCelebrities
    >>> celebs = getUtility(ILaunchpadCelebrities)

The examples are divided into sections by theme.  Each section starts with
the imports necessary for that section, where further imports are needed.
The proceeds with an example of the IFooSet url, then its contents, and
so on.


Application homepages
---------------------

    >>> from lp.code.interfaces.codehosting import IBazaarApplication
    >>> from lp.services.webapp.interfaces import ILaunchpadRoot
    >>> from lp.answers.interfaces.questioncollection import IQuestionSet
    >>> from lp.bugs.interfaces.malone import IMaloneApplication

The Launchpad homepage.

    >>> canonical_url(getUtility(ILaunchpadRoot))
    u'http://launchpad.dev/'

The Malone homepage.

    >>> canonical_url(getUtility(IMaloneApplication))
    u'http://launchpad.dev/bugs'

The Bazaar homepage.

    >>> canonical_url(getUtility(IBazaarApplication))
    u'http://code.launchpad.dev/+code'

The Answer Tracker

    >>> canonical_url(getUtility(IQuestionSet))
    u'http://answers.launchpad.dev/questions'

Launchpad Translations (Rosetta) canonical_url examples are in
lib/lp/translations/doc/canonical_url_examples.txt.


Persons and Teams
-----------------

    >>> from lp.registry.interfaces.codeofconduct import (
    ...     ICodeOfConductSet,
    ...     ISignedCodeOfConductSet,
    ...     )
    >>> from lp.registry.interfaces.person import IPersonSet

The IPersonSet.

    >>> canonical_url(getUtility(IPersonSet))
    u'http://launchpad.dev/people'

An IPerson.

    >>> canonical_url(getUtility(IPersonSet).getByName('mark'))
    u'http://launchpad.dev/~mark'

An ITeam.

    >>> canonical_url(celebs.rosetta_experts)
    u'http://launchpad.dev/~rosetta-admins'

An ICodeOfConductSet

    >>> cocset = getUtility(ICodeOfConductSet)
    >>> canonical_url(cocset)
    u'http://launchpad.dev/codeofconduct'

An ISignedCodeOfConductSet

    >>> signedcocset = getUtility(ISignedCodeOfConductSet)
    >>> canonical_url(signedcocset)
    u'http://launchpad.dev/codeofconduct/console'

An ISignedCodeOfConduct

    >>> canonical_url(signedcocset['1'])
    u'http://launchpad.dev/codeofconduct/console/1'

An ICodeOfConduct

    >>> canonical_url(cocset['1.1'])
    u'http://launchpad.dev/codeofconduct/1.1'


Distributions, distroseriess and so on
--------------------------------------

    >>> from lp.registry.interfaces.distribution import IDistributionSet

The IDistributionSet.

    >>> distroset = getUtility(IDistributionSet)

    >>> canonical_url(distroset)
    u'http://launchpad.dev/distros'

An IDistribution.

    >>> canonical_url(celebs.ubuntu)
    u'http://launchpad.dev/ubuntu'

An IDistroSeries.

    >>> hoary = celebs.ubuntu.getSeries('hoary')
    >>> canonical_url(hoary)
    u'http://launchpad.dev/ubuntu/hoary'

An ISourcePackage.

    >>> canonical_url(hoary.getSourcePackage('evolution'))
    u'http://launchpad.dev/ubuntu/hoary/+source/evolution'

An IDistributionSourcePackage.

    >>> from lp.registry.interfaces.sourcepackagename import (
    ...     ISourcePackageNameSet)
    >>> sourcepackagenameset = getUtility(ISourcePackageNameSet)
    >>> ubuntu_firefox = celebs.ubuntu.getSourcePackage(
    ...     sourcepackagenameset['mozilla-firefox'])
    >>> canonical_url(ubuntu_firefox)
    u'http://launchpad.dev/ubuntu/+source/mozilla-firefox'


Projects groups and products
----------------------------

    >>> from lp.registry.interfaces.product import IProductSet
    >>> from lp.registry.interfaces.projectgroup import IProjectGroupSet

The IProjectGroupSet.

    >>> canonical_url(getUtility(IProjectGroupSet))
    u'http://launchpad.dev/projectgroups'

An IProjectGroup.

    >>> canonical_url(getUtility(IProjectGroupSet)['apache'])
    u'http://launchpad.dev/apache'

The IProductSet.

    >>> productset = getUtility(IProductSet)
    >>> canonical_url(productset)
    u'http://launchpad.dev/projects'

An IProduct.

    >>> evolution_product = productset['evolution']
    >>> canonical_url(evolution_product)
    u'http://launchpad.dev/evolution'

An IProductSeries.

    >>> evolution_trunk_series = evolution_product.getSeries('trunk')
    >>> canonical_url(evolution_trunk_series)
    u'http://launchpad.dev/evolution/trunk'

An IProductRelease.

    >>> evolution_release = evolution_trunk_series.getRelease('2.1.6')
    >>> canonical_url(evolution_release)
    u'http://launchpad.dev/evolution/trunk/2.1.6'


Bugs and bugtasks
-----------------

    >>> from lp.bugs.interfaces.bug import IBugSet
    >>> from lp.bugs.interfaces.bugtask import IBugTaskSet

The IBugSet.

    >>> canonical_url(getUtility(IBugSet))
    u'http://launchpad.dev/bugs/bugs'

An IBug.

    >>> canonical_url(getUtility(IBugSet).get(1))
    u'http://bugs.launchpad.dev/bugs/1'

An IBugTask on a product.

    >>> canonical_url(getUtility(IBugTaskSet).get(2))
    u'http://bugs.launchpad.dev/firefox/+bug/1'

An IMessage on a bug.

    >>> canonical_url(getUtility(IBugSet).get(1).messages[0])
    u'http://bugs.launchpad.dev/firefox/+bug/1/comments/0'

An IMessage on a question.

    >>> canonical_url(getUtility(IQuestionSet).get(6).messages[0])
    u'http://answers.launchpad.dev/firefox/+question/6/messages/1'

An IBugTask on a distribution source package.

    >>> distro_task = getUtility(IBugTaskSet).get(4)
    >>> canonical_url(distro_task)
    u'http://bugs.launchpad.dev/debian/+source/mozilla-firefox/+bug/1'

An IBugTask on a distribution without a sourcepackage.

    >>> from lp.testing import login
    >>> login("foo.bar@canonical.com")

    >>> temp_target = distro_task.target
    >>> distro_task.transitionToTarget(distro_task.target.distribution)
    >>> canonical_url(distro_task)
    u'http://bugs.launchpad.dev/debian/+bug/1'
    >>> distro_task.transitionToTarget(temp_target)

An IBugTask on a distribution series source package.

    >>> distro_series_task = getUtility(IBugTaskSet).get(19)
    >>> canonical_url(distro_series_task)
    u'http://bugs.launchpad.dev/debian/sarge/+source/mozilla-firefox/+bug/3'

An IBugTask on a distribution series without a sourcepackage.

    >>> temp_target = distro_series_task.target
    >>> distro_series_task.transitionToTarget(
    ...     distro_series_task.target.distroseries)
    >>> canonical_url(distro_series_task)
    u'http://bugs.launchpad.dev/debian/sarge/+bug/3'
    >>> distro_series_task.transitionToTarget(temp_target)

A private bug, as an anonymous user! (We'll temporarily subscribe to the bug,
to ensure that at least one person has the perms to edit it while it's set
private.)

    >>> from lp.services.webapp.interfaces import ILaunchBag
    >>> current_user = getUtility(ILaunchBag).user
    >>> subscription = distro_series_task.bug.subscribe(
    ...     current_user, current_user)

    >>> distro_series_task.bug.setPrivate(True, getUtility(ILaunchBag).user)
    True

    >>> login(ANONYMOUS)

    >>> canonical_url(distro_series_task.bug)
    u'http://bugs.launchpad.dev/bugs/3'

A private bugtask, as an anonymous user.

    >>> canonical_url(distro_series_task)
    u'http://bugs.launchpad.dev/debian/sarge/+source/mozilla-firefox/+bug/3'

    >>> login("foo.bar@canonical.com")
    >>> distro_series_task.bug.setPrivate(False, getUtility(ILaunchBag).user)
    True
    >>> distro_series_task.bug.unsubscribe(current_user, current_user)

An IBugWatchSet.

    This doesn't work, because BugWatchSet.bug is an int, not an IBug object.

    xxx bug_one_watches = BugWatchSet(bug=1)
    xxx canonical_url(bug_one_watches)
    u'http://launchpad.dev/bugs/1/watches'

An IBugComment.

    >>> from lp.bugs.browser.bugcomment import BugComment
    >>> bug_one = getUtility(IBugSet).get(1)
    >>> bugtask_one = bug_one.bugtasks[0]
    >>> bug_comment = BugComment(
    ...     1, bug_one.initial_message, bugtask_one, True)
    >>> canonical_url(bug_comment)
    u'http://bugs.launchpad.dev/firefox/+bug/1/comments/1'

An IBugNomination.

    >>> from lp.bugs.interfaces.bugnomination import IBugNominationSet
    >>> bug_nomination = getUtility(IBugNominationSet).get(1)
    >>> canonical_url(bug_nomination)
    u'http://bugs.launchpad.dev/bugs/1/nominations/1'


Remote Bug Trackers and Remote Bugs
-----------------------------------

    >>> from lp.bugs.browser.bugtracker import RemoteBug
    >>> from lp.bugs.interfaces.bugtracker import IBugTrackerSet

An IBugTrackerSet.

    >>> canonical_url(getUtility(IBugTrackerSet))
    u'http://bugs.launchpad.dev/bugs/bugtrackers'

A remote bug tracker.

    >>> mozilla_bugtracker = getUtility(IBugTrackerSet)['mozilla.org']
    >>> canonical_url(mozilla_bugtracker)
    u'http://bugs.launchpad.dev/bugs/bugtrackers/mozilla.org'

A bug from a remote bug tracker.

    >>> remote_bug = RemoteBug(mozilla_bugtracker, '42',
    ...                        mozilla_bugtracker.getBugsWatching('42'))
    >>> canonical_url(remote_bug)
    u'http://bugs.launchpad.dev/bugs/bugtrackers/mozilla.org/42'


Branches
--------

An IBranch.

    >>> from lp.code.interfaces.branchlookup import IBranchLookup

    >>> branch = getUtility(IBranchLookup).get(10)

    >>> canonical_url(branch)
    u'http://code.launchpad.dev/~mark/firefox/release-0.9.2'

An IBugBranch.

    >>> bug = getUtility(IBugSet).get(1)
    >>> bug_branch = bug.linkBranch(
    ...     branch, getUtility(IPersonSet).getByName('mark'))

    >>> canonical_url(bug_branch)
    u'http://launchpad.dev/~mark/firefox/release-0.9.2/+bug/1'


BranchMergeProposals
--------------------

Set up example Branch Merge Proposal

    >>> mainline = getUtility(IBranchLookup).get(15)
    >>> release26 = getUtility(IBranchLookup).get(16)
    >>> merge_proposal = mainline.addLandingTarget(mainline.owner, release26)

Branch merge proposals should have a canonical URL.  (Based on their source
branch.)

    >>> print canonical_url(merge_proposal)
    http://code.launchpad.dev/~name12/gnome-terminal/main/+merge/...

Create example CodeReviewComment.

    >>> comment = merge_proposal.createComment(
    ...     release26.owner, 'My subject', 'My content')

CodeReviewComment should have a canonical URL.  (It should extend the URL of
the merge proposal)

    >>> print canonical_url(comment)
    http://code....dev/~name12/gnome-terminal/main/+merge/.../comments/...


Code Imports
------------

Code imports have a canonical URL which is a subordinate of the branch
that they import to.

    >>> from lp.code.interfaces.codeimport import ICodeImportSet
    >>> code_import = getUtility(ICodeImportSet).get(1)
    >>> print canonical_url(code_import)
    http://code.launchpad.dev/~vcs-imports/gnome-terminal/import/+code-import

Specifications
--------------

    >>> from lp.blueprints.interfaces.specification import ISpecificationSet
    >>> spec_set = getUtility(ISpecificationSet)
    >>> canonical_url(spec_set)
    u'http://blueprints.launchpad.dev/'

    >>> canonical_url(celebs.ubuntu.getSpecification('media-integrity-check'))
    u'http://blueprints.launchpad.dev/ubuntu/+spec/media-integrity-check'