~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/soyuz/scripts/tests/test_copypackage.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-05-24 11:48:32 UTC
  • mfrom: (13045.15.17 copies-use-overrides)
  • Revision ID: launchpad@pqm.canonical.com-20110524114832-oya6nkj2qd820p4w
[r=julian-edwards,
        wgrant][bug=783249] Add support for generic overrides to the package
        copier.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2009-2010 Canonical Ltd.  This software is licensed under the
 
1
# Copyright 2009-2011 Canonical Ltd.  This software is licensed under the
2
2
# GNU Affero General Public License version 3 (see the file LICENSE).
3
3
 
4
4
__metaclass__ = type
1150
1150
            [copy.displayname for copy in copies])
1151
1151
 
1152
1152
    def doCopy(self, source, archive, series, pocket, include_binaries):
1153
 
        return _do_direct_copy(source, archive, series, pocket, True)
 
1153
        return _do_direct_copy(source, archive, series, pocket,
 
1154
            include_binaries)
1154
1155
 
1155
1156
    def testCanCopyArchIndependentBinariesBuiltInAnUnsupportedArch(self):
1156
1157
        # _do_direct_copy() uses the binary candidate build architecture,
1157
 
        # instead of the publish one, in other to check if it's
 
1158
        # instead of the published one, in order to check if it's
1158
1159
        # suitable for the destination. It avoids skipping the single
1159
1160
        # arch-indep publication returned by SPPH.getBuiltBinaries()
1160
1161
        # if it happens to be published in an unsupportted architecture
1244
1245
        # The copy succeeds, and no i386 publication is created.
1245
1246
        self.assertCopied(copies, nobby, ('hppa',))
1246
1247
 
 
1248
    def assertComponentSectionAndPriority(self, component, source,
 
1249
                                          destination):
 
1250
        self.assertEquals(component, destination.component)
 
1251
        self.assertEquals(source.section, destination.section)
 
1252
        self.assertEquals(source.priority, destination.priority)
 
1253
 
 
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
 
1257
        # to the default.
 
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(
 
1265
            pub_source=source)
 
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
 
1270
        # upload.
 
1271
        transaction.commit()
 
1272
 
 
1273
        nobby = self.createNobby(('i386', 'hppa'))
 
1274
        target_archive = self.test_publisher.ubuntutest.main_archive
 
1275
 
 
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)
 
1284
 
 
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
 
1304
 
 
1305
        source = self.test_publisher.getPubSource(
 
1306
            archive=archive, version='1.0-2', architecturehintlist='all')
 
1307
        [bin_i386, bin_hppa] = self.test_publisher.getPubBinaries(
 
1308
            pub_source=source)
 
1309
        # The package copier will want the changes files associated with the
 
1310
        # upload.
 
1311
        transaction.commit()
 
1312
 
 
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)
 
1320
 
 
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()
 
1336
 
 
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)
 
1344
        
 
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(
 
1353
            pub_source=source)
 
1354
        target_archive = self.factory.makeArchive(
 
1355
            distribution=self.test_publisher.ubuntutest, virtualized=True)
 
1356
        nobby = self.createNobby(('i386', 'hppa'))
 
1357
 
 
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)
 
1366
 
1247
1367
 
1248
1368
class TestDoDelayedCopy(TestCaseWithFactory, BaseDoCopyTests):
1249
1369