1244
1245
# The copy succeeds, and no i386 publication is created.
1245
1246
self.assertCopied(copies, nobby, ('hppa',))
1248
def assertComponentSectionAndPriority(self, component, source,
1250
self.assertEquals(component, destination.component)
1251
self.assertEquals(source.section, destination.section)
1252
self.assertEquals(source.priority, destination.priority)
1254
def test_new_publication_overrides(self):
1255
# When we copy publications, if the destination primary archive has
1256
# no prior publications of the source/binaries, we set the component
1258
# This is an oversimplication, in future we will also override
1259
# contrib/non-free to multiverse.
1260
archive = self.factory.makeArchive(
1261
distribution=self.test_publisher.ubuntutest, virtualized=False)
1262
source = self.test_publisher.getPubSource(
1263
archive=archive, architecturehintlist='any')
1264
[bin_i386, bin_hppa] = self.test_publisher.getPubBinaries(
1266
component = self.factory.makeComponent()
1267
for kind in (source, bin_i386, bin_hppa):
1268
kind.component = component
1269
# The package copier will want the changes files associated with the
1271
transaction.commit()
1273
nobby = self.createNobby(('i386', 'hppa'))
1274
target_archive = self.test_publisher.ubuntutest.main_archive
1276
[copied_source, copied_bin_i386, copied_bin_hppa] = self.doCopy(
1277
source, target_archive, nobby, source.pocket, True)
1278
universe = getUtility(IComponentSet)['universe']
1279
self.assertEquals(universe, copied_source.component)
1280
self.assertComponentSectionAndPriority(
1281
universe, bin_i386, copied_bin_i386)
1282
self.assertComponentSectionAndPriority(
1283
universe, bin_hppa, copied_bin_hppa)
1285
def test_existing_publication_overrides(self):
1286
# When source/binaries are copied to a destination primary archive,
1287
# if that archive has existing publications, we respect their
1288
# component and section when copying.
1289
nobby = self.createNobby(('i386', 'hppa'))
1290
archive = self.factory.makeArchive(
1291
distribution=self.test_publisher.ubuntutest, virtualized=False)
1292
target_archive = self.factory.makeArchive(
1293
distribution=self.test_publisher.ubuntutest, virtualized=False,
1294
purpose=ArchivePurpose.PRIMARY)
1295
existing_source = self.test_publisher.getPubSource(
1296
archive=target_archive, version='1.0-1', distroseries=nobby,
1297
architecturehintlist='all')
1298
existing_source.component = self.factory.makeComponent()
1299
[ebin_i386, ebin_hppa] = self.test_publisher.getPubBinaries(
1300
pub_source=existing_source)
1301
section = self.factory.makeSection()
1302
ebin_i386.section = section
1303
ebin_hppa.section = section
1305
source = self.test_publisher.getPubSource(
1306
archive=archive, version='1.0-2', architecturehintlist='all')
1307
[bin_i386, bin_hppa] = self.test_publisher.getPubBinaries(
1309
# The package copier will want the changes files associated with the
1311
transaction.commit()
1313
[copied_source, copied_bin_i386, copied_bin_hppa] = self.doCopy(
1314
source, target_archive, nobby, source.pocket, True)
1315
self.assertEquals(copied_source.component, existing_source.component)
1316
self.assertComponentSectionAndPriority(
1317
ebin_i386.component, ebin_i386, copied_bin_i386)
1318
self.assertComponentSectionAndPriority(
1319
ebin_hppa.component, ebin_hppa, copied_bin_hppa)
1321
def test_existing_publication_overrides_pockets(self):
1322
# When we copy source/binaries from one pocket to another, the
1323
# overrides are unchanged from the source publication overrides.
1324
nobby = self.createNobby(('i386', 'hppa'))
1325
archive = self.test_publisher.ubuntutest.main_archive
1326
source = self.test_publisher.getPubSource(
1327
archive=archive, version='1.0-1', architecturehintlist='any',
1328
distroseries=nobby, pocket=PackagePublishingPocket.PROPOSED)
1329
[bin_i386, bin_hppa] = self.test_publisher.getPubBinaries(
1330
pub_source=source, distroseries=nobby,
1331
pocket=PackagePublishingPocket.PROPOSED)
1332
component = self.factory.makeComponent()
1333
for kind in (source, bin_i386, bin_hppa):
1334
kind.component = component
1335
transaction.commit()
1337
[copied_source, copied_bin_i386, copied_bin_hppa] = self.doCopy(
1338
source, archive, nobby, PackagePublishingPocket.UPDATES, True)
1339
self.assertEquals(copied_source.component, source.component)
1340
self.assertComponentSectionAndPriority(
1341
bin_i386.component, bin_i386, copied_bin_i386)
1342
self.assertComponentSectionAndPriority(
1343
bin_hppa.component, bin_hppa, copied_bin_hppa)
1345
def test_existing_publication_no_overrides(self):
1346
# When we copy source/binaries into a PPA, we don't respect their
1347
# component and section.
1348
archive = self.factory.makeArchive(
1349
distribution=self.test_publisher.ubuntutest, virtualized=False)
1350
source = self.test_publisher.getPubSource(
1351
archive=archive, version='1.0-2', architecturehintlist='all')
1352
[bin_i386, bin_hppa] = self.test_publisher.getPubBinaries(
1354
target_archive = self.factory.makeArchive(
1355
distribution=self.test_publisher.ubuntutest, virtualized=True)
1356
nobby = self.createNobby(('i386', 'hppa'))
1358
[copied_source, copied_bin_i386, copied_bin_hppa] = self.doCopy(
1359
source, target_archive, nobby, source.pocket, True)
1360
main = getUtility(IComponentSet)['main']
1361
self.assertEquals(main, copied_source.component)
1362
self.assertComponentSectionAndPriority(
1363
main, bin_i386, copied_bin_i386)
1364
self.assertComponentSectionAndPriority(
1365
main, bin_hppa, copied_bin_hppa)
1248
1368
class TestDoDelayedCopy(TestCaseWithFactory, BaseDoCopyTests):