4
4
This test covers the use case when a package includes translations and is
5
5
uploaded into the system.
7
>>> from lp.registry.model.gpgkey import GPGKey
8
>>> from lp.soyuz.model.component import Component
9
>>> from lp.soyuz.model.processor import ProcessorFamily
10
>>> from lp.soyuz.model.section import Section
11
>>> from lp.soyuz.model.publishing import (
12
... SourcePackagePublishingHistory)
13
>>> from lp.registry.interfaces.distribution import IDistributionSet
14
>>> from lp.registry.interfaces.distroseries import IDistroSeriesSet
15
>>> from lp.registry.interfaces.pocket import PackagePublishingPocket
16
>>> from lp.soyuz.interfaces.component import IComponentSet
17
>>> from lp.soyuz.enums import (
18
... PackagePublishingStatus)
19
>>> from lp.registry.interfaces.sourcepackagename import (
20
... ISourcePackageNameSet)
22
>>> from lp.archiveuploader.nascentupload import NascentUpload
23
>>> from lp.archiveuploader.tests import datadir, getPolicy
25
>>> from canonical.launchpad.ftests import import_public_test_keys
26
>>> import_public_test_keys()
28
>>> from canonical.database.constants import UTC_NOW
29
>>> from lp.registry.interfaces.sourcepackage import SourcePackageUrgency
32
>>> login('foo.bar@canonical.com')
34
# We need to setup our test environment and create the needed objects.
35
>>> distro_series_set = getUtility(IDistroSeriesSet)
36
>>> ubuntu = getUtility(IDistributionSet)['ubuntu']
37
>>> hoary = distro_series_set.queryByName(ubuntu, 'hoary')
39
# Create the Dapper distro series.
40
>>> dapper = ubuntu.newSeries(
41
... 'dapper', 'Dapper', 'Dapper',
42
... 'Dapper', 'Dapper', '06.04', hoary, hoary.owner)
44
# And an AMD 64 arch series.
45
>>> dapper_amd64 = dapper.newArch('amd64', ProcessorFamily.get(3), True,
7
>>> from lp.registry.model.gpgkey import GPGKey
8
>>> from lp.soyuz.model.component import Component
9
>>> from lp.soyuz.model.processor import ProcessorFamily
10
>>> from lp.soyuz.model.section import Section
11
>>> from lp.soyuz.model.publishing import (
12
... SourcePackagePublishingHistory)
13
>>> from lp.registry.interfaces.distribution import IDistributionSet
14
>>> from lp.registry.interfaces.distroseries import IDistroSeriesSet
15
>>> from lp.registry.interfaces.pocket import PackagePublishingPocket
16
>>> from lp.soyuz.interfaces.component import IComponentSet
17
>>> from lp.soyuz.enums import (
18
... PackagePublishingStatus)
19
>>> from lp.registry.interfaces.sourcepackagename import (
20
... ISourcePackageNameSet)
22
>>> from lp.archiveuploader.nascentupload import NascentUpload
23
>>> from lp.archiveuploader.tests import datadir, getPolicy
25
>>> from canonical.launchpad.ftests import import_public_test_keys
26
>>> import_public_test_keys()
28
>>> from canonical.database.constants import UTC_NOW
29
>>> from lp.registry.interfaces.sourcepackage import SourcePackageUrgency
32
>>> login('foo.bar@canonical.com')
34
# We need to setup our test environment and create the needed objects.
35
>>> distro_series_set = getUtility(IDistroSeriesSet)
36
>>> ubuntu = getUtility(IDistributionSet)['ubuntu']
37
>>> hoary = distro_series_set.queryByName(ubuntu, 'hoary')
39
# Create the Dapper distro series.
40
>>> dapper = ubuntu.newSeries(
41
... 'dapper', 'Dapper', 'Dapper',
42
... 'Dapper', 'Dapper', '06.04', hoary, hoary.owner)
44
# And an AMD 64 arch series.
45
>>> dapper_amd64 = dapper.newArch('amd64', ProcessorFamily.get(3), True,
48
48
Only uploads to the RELEASE, UPDATES, SECURITY and PROPOSED pockets are
49
49
considered for import. An upload to the BACKPORT pocket won't appear in the
52
# We are going to import the pmount build into RELEASE pocket.
53
>>> pmount_sourcepackagename = getUtility(ISourcePackageNameSet)['pmount']
54
>>> source_package_release = dapper.createUploadedSourcePackageRelease(
55
... pmount_sourcepackagename, "0.9.7-2ubuntu2", dapper.owner,
56
... None, None, 'i386', Component.get(1), dapper.owner,
57
... SourcePackageUrgency.LOW, None, None, None, GPGKey.get(1),
58
... Section.get(1), '', '', '', '', dapper.main_archive,
59
... 'copyright ?!', '', '')
61
>>> publishing_history = SourcePackagePublishingHistory(
62
... distroseries=dapper.id,
63
... sourcepackagerelease=source_package_release.id,
64
... component=source_package_release.component.id,
65
... section=source_package_release.section.id,
66
... status=PackagePublishingStatus.PUBLISHED,
67
... datecreated=UTC_NOW,
68
... pocket=PackagePublishingPocket.RELEASE,
69
... archive=dapper.main_archive)
71
# Do the upload into the system.
73
>>> build = source_package_release.createBuild(
74
... dapper_amd64, PackagePublishingPocket.RELEASE, dapper.main_archive)
76
>>> buildd_policy = getPolicy(
77
... name='buildd', distro='ubuntu', distroseries='dapper')
79
>>> from lp.services.log.logger import FakeLogger
80
>>> pmount_upload = NascentUpload.from_changesfile_path(
81
... datadir('pmount_0.9.7-2ubuntu2_amd64.changes'),
82
... buildd_policy, FakeLogger())
83
DEBUG pmount_0.9.7-2ubuntu2_amd64.changes can be unsigned.
85
>>> pmount_upload.process(build=build)
86
DEBUG Beginning processing.
87
DEBUG Verifying the changes file.
88
DEBUG Verifying files in upload.
89
DEBUG Verifying binary pmount_0.9.7-2ubuntu2_amd64.deb
90
DEBUG Verifying timestamps in pmount_0.9.7-2ubuntu2_amd64.deb
91
DEBUG Finding and applying overrides.
92
DEBUG Checking for pmount/0.9.7-2ubuntu2/amd64 binary ancestry
93
DEBUG pmount: (binary) NEW
94
DEBUG Finished checking upload.
96
# It was not rejected.
97
>>> pmount_upload.is_rejected
52
# We are going to import the pmount build into RELEASE pocket.
53
>>> pmount_sourcepackagename = getUtility(ISourcePackageNameSet)['pmount']
54
>>> source_package_release = dapper.createUploadedSourcePackageRelease(
55
... pmount_sourcepackagename, "0.9.7-2ubuntu2", dapper.owner,
56
... None, None, 'i386', Component.get(1), dapper.owner,
57
... SourcePackageUrgency.LOW, None, None, None, GPGKey.get(1),
58
... Section.get(1), '', '', '', '', dapper.main_archive,
59
... 'copyright ?!', '', '')
61
>>> publishing_history = SourcePackagePublishingHistory(
62
... distroseries=dapper.id,
63
... sourcepackagerelease=source_package_release.id,
64
... component=source_package_release.component.id,
65
... section=source_package_release.section.id,
66
... status=PackagePublishingStatus.PUBLISHED,
67
... datecreated=UTC_NOW,
68
... pocket=PackagePublishingPocket.RELEASE,
69
... archive=dapper.main_archive)
71
# Do the upload into the system.
73
>>> build = source_package_release.createBuild(
74
... dapper_amd64, PackagePublishingPocket.RELEASE,
75
... dapper.main_archive)
77
>>> buildd_policy = getPolicy(
78
... name='buildd', distro='ubuntu', distroseries='dapper')
80
>>> from lp.services.log.logger import FakeLogger
81
>>> pmount_upload = NascentUpload.from_changesfile_path(
82
... datadir('pmount_0.9.7-2ubuntu2_amd64.changes'),
83
... buildd_policy, FakeLogger())
84
DEBUG pmount_0.9.7-2ubuntu2_amd64.changes can be unsigned.
86
>>> pmount_upload.process(build=build)
87
DEBUG Beginning processing.
88
DEBUG Verifying the changes file.
89
DEBUG Verifying files in upload.
90
DEBUG Verifying binary pmount_0.9.7-2ubuntu2_amd64.deb
91
DEBUG Verifying timestamps in pmount_0.9.7-2ubuntu2_amd64.deb
92
DEBUG Finding and applying overrides.
93
DEBUG Checking for pmount/0.9.7-2ubuntu2/amd64 binary ancestry
94
DEBUG pmount: (binary) NEW
95
DEBUG Finished checking upload.
97
# It was not rejected.
98
>>> pmount_upload.is_rejected
100
101
At this point, no translations uploads have been registered for this
103
>>> from lp.registry.model.sourcepackage import SourcePackage
104
>>> dapper_pmount = SourcePackage(pmount_sourcepackagename, dapper)
105
>>> print len(dapper_pmount.getLatestTranslationsUploads())
108
>>> success = pmount_upload.do_accept(build=build)
109
DEBUG Creating queue entry
112
# And all things worked.
116
# Ensure 'deb' is NEW and 'translation' is recognized, i.e., ACCEPTED
117
# XXX julian 2007-05-27 Commented out for now because getNotificationSummary
118
# no longer exists and this content is impossible to check at the moment
119
# since no email is generated because the recipients are not LP Persons.
120
# (So why is it being checked in the first place?)
121
#>>> print pmount_upload.getNotificationSummary()
122
#NEW: pmount_0.9.7-2ubuntu2_amd64.deb
123
#OK: pmount_0.9.7-2ubuntu2_amd64_translations.tar.gz
104
>>> from lp.registry.model.sourcepackage import SourcePackage
105
>>> dapper_pmount = SourcePackage(pmount_sourcepackagename, dapper)
106
>>> print len(dapper_pmount.getLatestTranslationsUploads())
109
>>> success = pmount_upload.do_accept(build=build)
110
DEBUG Creating queue entry
113
# And all things worked.
117
# Ensure 'deb' is NEW and 'translation' is recognized, i.e., ACCEPTED
118
# XXX julian 2007-05-27 Commented out for now because getNotificationSummary
119
# no longer exists and this content is impossible to check at the moment
120
# since no email is generated because the recipients are not LP Persons.
121
# (So why is it being checked in the first place?)
122
#>>> print pmount_upload.getNotificationSummary()
123
#NEW: pmount_0.9.7-2ubuntu2_amd64.deb
124
#OK: pmount_0.9.7-2ubuntu2_amd64_translations.tar.gz
125
126
The upload now shows up as the latest translations upload for the
128
>>> latest_translations_uploads = list(
129
... dapper_pmount.getLatestTranslationsUploads())
130
>>> print len(latest_translations_uploads)
129
>>> latest_translations_uploads = list(
130
... dapper_pmount.getLatestTranslationsUploads())
131
>>> print len(latest_translations_uploads)
133
134
We'll get back to that uploaded file later.
135
>>> latest_translations_upload = latest_translations_uploads[0]
137
# Check the import queue content, it should be empty.
138
>>> from lp.translations.interfaces.translationimportqueue import (
139
... ITranslationImportQueue)
140
>>> translation_import_queue = getUtility(ITranslationImportQueue)
141
>>> translation_import_queue.getAllEntries(target=ubuntu).count()
144
# We need to commit the transaction to be able to use the librarian files.
145
>>> import transaction
146
>>> transaction.commit()
136
>>> latest_translations_upload = latest_translations_uploads[0]
138
# Check the import queue content, it should be empty.
139
>>> from lp.translations.interfaces.translationimportqueue import (
140
... ITranslationImportQueue)
141
>>> translation_import_queue = getUtility(ITranslationImportQueue)
142
>>> translation_import_queue.getAllEntries(target=ubuntu).count()
145
# We need to commit the transaction to be able to use the librarian files.
146
>>> import transaction
147
>>> transaction.commit()
148
149
An upload to the RELEASE pocket will add items to the import queue:
150
>>> from lp.soyuz.enums import PackageUploadStatus
151
>>> queue_item = dapper.getQueueItems(
152
... status=PackageUploadStatus.NEW)[0]
153
>>> queue_item.customfiles[0].publish()
151
>>> from lp.soyuz.enums import PackageUploadStatus
152
>>> queue_item = dapper.getQueueItems(
153
... status=PackageUploadStatus.NEW)[0]
154
>>> queue_item.customfiles[0].publish()
155
156
As we can see from the translation import queue content.
157
>>> for entry in translation_import_queue.getAllEntries(target=ubuntu):
158
... print '%s/%s by %s: %s' % (
159
... entry.distroseries.name, entry.sourcepackagename.name,
160
... entry.importer.name, entry.path)
161
dapper/pmount by ubuntu-team: po/es_ES.po
162
dapper/pmount by ubuntu-team: po/ca.po
163
dapper/pmount by ubuntu-team: po/de.po
164
dapper/pmount by ubuntu-team: po/cs.po
165
dapper/pmount by ubuntu-team: po/es.po
166
dapper/pmount by ubuntu-team: po/fr.po
167
dapper/pmount by ubuntu-team: po/hr.po
168
dapper/pmount by ubuntu-team: po/nb.po
169
dapper/pmount by ubuntu-team: po/pmount.pot
170
dapper/pmount by ubuntu-team: po/it_IT.po
172
# Abort the transaction so we can check the same upload in a different
174
>>> transaction.abort()
176
# The import queue content should be empty now that the transaction is
178
>>> translation_import_queue.getAllEntries(target=ubuntu).count()
158
>>> for entry in translation_import_queue.getAllEntries(target=ubuntu):
159
... print '%s/%s by %s: %s' % (
160
... entry.distroseries.name, entry.sourcepackagename.name,
161
... entry.importer.name, entry.path)
162
dapper/pmount by ubuntu-team: po/es_ES.po
163
dapper/pmount by ubuntu-team: po/ca.po
164
dapper/pmount by ubuntu-team: po/de.po
165
dapper/pmount by ubuntu-team: po/cs.po
166
dapper/pmount by ubuntu-team: po/es.po
167
dapper/pmount by ubuntu-team: po/fr.po
168
dapper/pmount by ubuntu-team: po/hr.po
169
dapper/pmount by ubuntu-team: po/nb.po
170
dapper/pmount by ubuntu-team: po/pmount.pot
171
dapper/pmount by ubuntu-team: po/it_IT.po
173
# Abort the transaction so we can check the same upload in a different
175
>>> transaction.abort()
177
# The import queue content should be empty now that the transaction is
179
>>> translation_import_queue.getAllEntries(target=ubuntu).count()
181
182
An upload to the BACKPORTS pocket will not add items to the import queue:
183
>>> ubuntu = getUtility(IDistributionSet)['ubuntu']
184
>>> dapper = distro_series_set.queryByName(ubuntu, 'dapper')
185
>>> queue_item = dapper.getQueueItems(status=PackageUploadStatus.NEW)[0]
186
>>> queue_item.pocket = PackagePublishingPocket.BACKPORTS
187
>>> queue_item.customfiles[0].publish()
189
# And this time, we see that there are no entries imported in the queue.
190
>>> translation_import_queue.getAllEntries(target=ubuntu).count()
193
# Let's abort the transaction so we can check the same upload in a different
195
>>> transaction.abort()
184
>>> ubuntu = getUtility(IDistributionSet)['ubuntu']
185
>>> dapper = distro_series_set.queryByName(ubuntu, 'dapper')
186
>>> queue_item = dapper.getQueueItems(status=PackageUploadStatus.NEW)[0]
187
>>> queue_item.pocket = PackagePublishingPocket.BACKPORTS
188
>>> queue_item.customfiles[0].publish()
190
# And this time, we see that there are no entries imported in the queue.
191
>>> translation_import_queue.getAllEntries(target=ubuntu).count()
194
# Let's abort the transaction so we can check the same upload in a different
196
>>> transaction.abort()
197
198
But an upload to the UPDATE pocket will add items to the import queue:
199
>>> ubuntu = getUtility(IDistributionSet)['ubuntu']
200
>>> dapper = distro_series_set.queryByName(ubuntu, 'dapper')
201
>>> queue_item = dapper.getQueueItems(status=PackageUploadStatus.NEW)[0]
202
>>> queue_item.pocket = PackagePublishingPocket.UPDATES
203
>>> queue_item.customfiles[0].publish()
200
>>> ubuntu = getUtility(IDistributionSet)['ubuntu']
201
>>> dapper = distro_series_set.queryByName(ubuntu, 'dapper')
202
>>> queue_item = dapper.getQueueItems(status=PackageUploadStatus.NEW)[0]
203
>>> queue_item.pocket = PackagePublishingPocket.UPDATES
204
>>> queue_item.customfiles[0].publish()
205
206
As we can see from the translation import queue content.
207
>>> for entry in translation_import_queue.getAllEntries(target=ubuntu):
208
... print '%s/%s by %s: %s' % (
209
... entry.distroseries.name, entry.sourcepackagename.name,
210
... entry.importer.name, entry.path)
211
dapper/pmount by ubuntu-team: po/es_ES.po
212
dapper/pmount by ubuntu-team: po/ca.po
213
dapper/pmount by ubuntu-team: po/de.po
214
dapper/pmount by ubuntu-team: po/cs.po
215
dapper/pmount by ubuntu-team: po/es.po
216
dapper/pmount by ubuntu-team: po/fr.po
217
dapper/pmount by ubuntu-team: po/hr.po
218
dapper/pmount by ubuntu-team: po/nb.po
219
dapper/pmount by ubuntu-team: po/pmount.pot
220
dapper/pmount by ubuntu-team: po/it_IT.po
208
>>> for entry in translation_import_queue.getAllEntries(target=ubuntu):
209
... print '%s/%s by %s: %s' % (
210
... entry.distroseries.name, entry.sourcepackagename.name,
211
... entry.importer.name, entry.path)
212
dapper/pmount by ubuntu-team: po/es_ES.po
213
dapper/pmount by ubuntu-team: po/ca.po
214
dapper/pmount by ubuntu-team: po/de.po
215
dapper/pmount by ubuntu-team: po/cs.po
216
dapper/pmount by ubuntu-team: po/es.po
217
dapper/pmount by ubuntu-team: po/fr.po
218
dapper/pmount by ubuntu-team: po/hr.po
219
dapper/pmount by ubuntu-team: po/nb.po
220
dapper/pmount by ubuntu-team: po/pmount.pot
221
dapper/pmount by ubuntu-team: po/it_IT.po
222
# Let's abort the transaction so we can check the same upload in a different
224
>>> transaction.abort()
223
# Let's abort the transaction so we can check the same upload in a different
225
>>> transaction.abort()
226
227
Uploads to restricted component are accepted too.
228
>>> ubuntu = getUtility(IDistributionSet)['ubuntu']
229
>>> dapper = distro_series_set.queryByName(ubuntu, 'dapper')
230
>>> restricted_component = getUtility(IComponentSet)['restricted']
231
>>> queue_item = dapper.getQueueItems(status=PackageUploadStatus.NEW)[0]
229
>>> ubuntu = getUtility(IDistributionSet)['ubuntu']
230
>>> dapper = distro_series_set.queryByName(ubuntu, 'dapper')
231
>>> restricted_component = getUtility(IComponentSet)['restricted']
232
>>> queue_item = dapper.getQueueItems(status=PackageUploadStatus.NEW)[0]
233
# Change the component where this package was attached.
234
>>> queue_item.builds[0].build.source_package_release.override(
235
... component=restricted_component)
236
>>> queue_item.customfiles[0].publish()
234
# Change the component where this package was attached.
235
>>> queue_item.builds[0].build.source_package_release.override(
236
... component=restricted_component)
237
>>> queue_item.customfiles[0].publish()
238
239
As we can see from the translation import queue content.
240
>>> for entry in translation_import_queue.getAllEntries(target=ubuntu):
241
... print '%s/%s by %s: %s' % (
242
... entry.distroseries.name, entry.sourcepackagename.name,
243
... entry.importer.name, entry.path)
244
dapper/pmount by ubuntu-team: po/es_ES.po
245
dapper/pmount by ubuntu-team: po/ca.po
246
dapper/pmount by ubuntu-team: po/de.po
247
dapper/pmount by ubuntu-team: po/cs.po
248
dapper/pmount by ubuntu-team: po/es.po
249
dapper/pmount by ubuntu-team: po/fr.po
250
dapper/pmount by ubuntu-team: po/hr.po
251
dapper/pmount by ubuntu-team: po/nb.po
252
dapper/pmount by ubuntu-team: po/pmount.pot
253
dapper/pmount by ubuntu-team: po/it_IT.po
241
>>> for entry in translation_import_queue.getAllEntries(target=ubuntu):
242
... print '%s/%s by %s: %s' % (
243
... entry.distroseries.name, entry.sourcepackagename.name,
244
... entry.importer.name, entry.path)
245
dapper/pmount by ubuntu-team: po/es_ES.po
246
dapper/pmount by ubuntu-team: po/ca.po
247
dapper/pmount by ubuntu-team: po/de.po
248
dapper/pmount by ubuntu-team: po/cs.po
249
dapper/pmount by ubuntu-team: po/es.po
250
dapper/pmount by ubuntu-team: po/fr.po
251
dapper/pmount by ubuntu-team: po/hr.po
252
dapper/pmount by ubuntu-team: po/nb.po
253
dapper/pmount by ubuntu-team: po/pmount.pot
254
dapper/pmount by ubuntu-team: po/it_IT.po
255
# Let's abort the transaction so we can check the same upload in a different
257
>>> transaction.abort()
256
# Let's abort the transaction so we can check the same upload in a different
258
>>> transaction.abort()
259
260
But the ones into universe are not accepted.
261
>>> ubuntu = getUtility(IDistributionSet)['ubuntu']
262
>>> dapper = distro_series_set.queryByName(ubuntu, 'dapper')
263
>>> universe_component = getUtility(IComponentSet)['universe']
264
>>> queue_item = dapper.getQueueItems(status=PackageUploadStatus.NEW)[0]
262
>>> ubuntu = getUtility(IDistributionSet)['ubuntu']
263
>>> dapper = distro_series_set.queryByName(ubuntu, 'dapper')
264
>>> universe_component = getUtility(IComponentSet)['universe']
265
>>> queue_item = dapper.getQueueItems(status=PackageUploadStatus.NEW)[0]
266
# Change the component where this package was attached.
267
>>> queue_item.builds[0].build.source_package_release.override(
268
... component=universe_component)
269
>>> queue_item.customfiles[0].publish()
267
# Change the component where this package was attached.
268
>>> queue_item.builds[0].build.source_package_release.override(
269
... component=universe_component)
270
>>> queue_item.customfiles[0].publish()
271
272
This time, we don't get any entry in the import queue.
273
>>> translation_import_queue.getAllEntries(target=ubuntu).count()
274
>>> translation_import_queue.getAllEntries(target=ubuntu).count()
276
# Let's abort the transaction so we can check the same upload in a different
278
>>> transaction.abort()
277
# Let's abort the transaction so we can check the same upload in a different
279
>>> transaction.abort()
281
282
Translations from PPA build
341
344
PackageUploadCustom: these will emulate everything we need to document
342
345
different interpretations of "importer" in attachTranslationFiles.
344
>>> from zope.interface import implements
345
>>> from lp.app.interfaces.launchpad import ILaunchpadCelebrities
346
>>> from lp.soyuz.model.queue import PackageUploadCustom
347
>>> from lp.soyuz.interfaces.archive import (
348
... IArchive, ArchivePurpose)
349
>>> from lp.soyuz.interfaces.queue import (
350
... IPackageUpload, IPackageUploadCustom)
351
>>> from lp.registry.interfaces.person import IPerson
352
>>> from lp.soyuz.enums import PackageUploadCustomFormat
353
>>> from lp.soyuz.interfaces.component import IComponentSet
354
>>> from lp.soyuz.interfaces.sourcepackagerelease import (
355
... ISourcePackageRelease)
356
>>> from lp.registry.interfaces.pocket import PackagePublishingPocket
358
>>> class MockArchive:
359
... implements(IArchive)
360
... def __init__(self, purpose):
361
... self.purpose = purpose
363
>>> class MockSourcePackageRelease:
364
... implements(ISourcePackageRelease)
365
... def __init__(self, component, creator):
366
... self.component = getUtility(IComponentSet)[component]
367
... self.creator = creator
368
... self.packageupload = 1
370
... def attachTranslationFiles(self, file, imported, importer):
371
... if (importer is not None and
372
... not IPerson.providedBy(importer)):
373
... print "`importer` not a person!"
374
... print "Imported by: %s" % (getattr(importer, "name", "None"))
376
>>> class MockPackageUpload:
377
... implements(IPackageUpload)
378
... def __init__(self, pocket, auto_sync, sourcepackagerelease,
381
... self.pocket = pocket
382
... self.auto_sync = auto_sync
383
... self.sourcepackagerelease = sourcepackagerelease
384
... self.archive = archive
386
... def isAutoSyncUpload(self, changed_by_email=None):
387
... return self.auto_sync
389
>>> class MockPackageUploadCustom(PackageUploadCustom):
390
... implements(IPackageUploadCustom)
391
... packageupload = None
393
... def __init__(self):
394
... self.customformat = (
395
... PackageUploadCustomFormat.ROSETTA_TRANSLATIONS)
347
>>> from zope.interface import implements
348
>>> from lp.app.interfaces.launchpad import ILaunchpadCelebrities
349
>>> from lp.soyuz.model.queue import PackageUploadCustom
350
>>> from lp.soyuz.interfaces.archive import (
351
... IArchive, ArchivePurpose)
352
>>> from lp.soyuz.interfaces.queue import (
353
... IPackageUpload, IPackageUploadCustom)
354
>>> from lp.registry.interfaces.person import IPerson
355
>>> from lp.soyuz.enums import PackageUploadCustomFormat
356
>>> from lp.soyuz.interfaces.component import IComponentSet
357
>>> from lp.soyuz.interfaces.sourcepackagerelease import (
358
... ISourcePackageRelease)
359
>>> from lp.registry.interfaces.pocket import PackagePublishingPocket
361
>>> class MockArchive:
362
... implements(IArchive)
363
... def __init__(self, purpose):
364
... self.purpose = purpose
366
>>> class MockSourcePackageRelease:
367
... implements(ISourcePackageRelease)
368
... def __init__(self, component, creator):
369
... self.component = getUtility(IComponentSet)[component]
370
... self.creator = creator
371
... self.packageupload = 1
373
... def attachTranslationFiles(self, file, imported, importer):
374
... if (importer is not None and
375
... not IPerson.providedBy(importer)):
376
... print "`importer` not a person!"
377
... print "Imported by: %s" % (
378
... getattr(importer, "name", "None"))
380
>>> class MockPackageUpload:
381
... implements(IPackageUpload)
382
... def __init__(self, pocket, auto_sync, sourcepackagerelease,
385
... self.pocket = pocket
386
... self.auto_sync = auto_sync
387
... self.sourcepackagerelease = sourcepackagerelease
388
... self.archive = archive
390
... def isAutoSyncUpload(self, changed_by_email=None):
391
... return self.auto_sync
393
>>> class MockPackageUploadCustom(PackageUploadCustom):
394
... implements(IPackageUploadCustom)
395
... packageupload = None
397
... def __init__(self):
398
... self.customformat = (
399
... PackageUploadCustomFormat.ROSETTA_TRANSLATIONS)
397
401
For translations from auto-synced packages we consider the importer to be
398
402
'katie' (archive@ubuntu.com).
400
>>> katie = getUtility(ILaunchpadCelebrities).katie
401
>>> release_pocket = PackagePublishingPocket.RELEASE
402
>>> archive = MockArchive(ArchivePurpose.PRIMARY)
404
>>> katie = getUtility(ILaunchpadCelebrities).katie
405
>>> release_pocket = PackagePublishingPocket.RELEASE
406
>>> archive = MockArchive(ArchivePurpose.PRIMARY)
404
>>> katie_sourcepackagerelease = MockSourcePackageRelease('main', katie)
405
>>> sync_package_upload = MockPackageUpload(
406
... release_pocket, True, katie_sourcepackagerelease, archive)
407
>>> sync_package_upload.isAutoSyncUpload()
409
>>> translations_upload = MockPackageUploadCustom()
410
>>> translations_upload.packageupload = sync_package_upload
411
>>> translations_upload.publishRosettaTranslations()
408
>>> katie_sourcepackagerelease = MockSourcePackageRelease('main', katie)
409
>>> sync_package_upload = MockPackageUpload(
410
... release_pocket, True, katie_sourcepackagerelease, archive)
411
>>> sync_package_upload.isAutoSyncUpload()
413
>>> translations_upload = MockPackageUploadCustom()
414
>>> translations_upload.packageupload = sync_package_upload
415
>>> translations_upload.publishRosettaTranslations()
414
418
Non-auto-sync uploads by 'katie' still indicate 'katie' as the uploader.
416
>>> non_sync_package_upload = MockPackageUpload(
417
... release_pocket, False, katie_sourcepackagerelease, archive)
418
>>> non_sync_package_upload.isAutoSyncUpload()
420
>>> translations_upload.packageupload = non_sync_package_upload
421
>>> translations_upload.publishRosettaTranslations()
420
>>> non_sync_package_upload = MockPackageUpload(
421
... release_pocket, False, katie_sourcepackagerelease, archive)
422
>>> non_sync_package_upload.isAutoSyncUpload()
424
>>> translations_upload.packageupload = non_sync_package_upload
425
>>> translations_upload.publishRosettaTranslations()
424
428
Uploads by anyone else are treated as if importer is the packager.
426
>>> person_set = getUtility(IPersonSet)
427
>>> carlos = person_set.getByName('carlos')
428
>>> carlos_sourcepackagerelease = MockSourcePackageRelease('main', carlos)
429
>>> carlos_package_upload = MockPackageUpload(
430
... release_pocket, False, carlos_sourcepackagerelease, archive)
431
>>> carlos_package_upload.isAutoSyncUpload()
433
>>> translations_upload.packageupload = carlos_package_upload
434
>>> translations_upload.publishRosettaTranslations()
430
>>> person_set = getUtility(IPersonSet)
431
>>> carlos = person_set.getByName('carlos')
432
>>> carlos_sourcepackagerelease = MockSourcePackageRelease('main', carlos)
433
>>> carlos_package_upload = MockPackageUpload(
434
... release_pocket, False, carlos_sourcepackagerelease, archive)
435
>>> carlos_package_upload.isAutoSyncUpload()
437
>>> translations_upload.packageupload = carlos_package_upload
438
>>> translations_upload.publishRosettaTranslations()
438
442
Translations tarball