~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/soyuz/tests/test_publishing.py

  • Committer: Stuart Bishop
  • Date: 2011-10-20 06:24:21 UTC
  • mfrom: (9893.10.6 trivial)
  • mto: This revision was merged to the branch mainline in revision 14178.
  • Revision ID: stuart.bishop@canonical.com-20111020062421-8irsskytxf2i0srg
Merged trivial into distinct-db-users.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1471
1471
        self.assertEquals(spph.ancestor.displayname, ancestor.displayname)
1472
1472
 
1473
1473
 
 
1474
class TestGetOtherPublicationsForSameSource(TestNativePublishingBase):
 
1475
    """Test parts of the BinaryPackagePublishingHistory model.
 
1476
 
 
1477
    See also lib/lp/soyuz/doc/publishing.txt
 
1478
    """
 
1479
 
 
1480
    layer = LaunchpadZopelessLayer
 
1481
 
 
1482
    def _makeMixedSingleBuildPackage(self, version="1.0"):
 
1483
        # Set up a source with a build that generated four binaries,
 
1484
        # two of them an arch-all.
 
1485
        foo_src_pub = self.getPubSource(
 
1486
            sourcename="foo", version=version, architecturehintlist="i386",
 
1487
            status=PackagePublishingStatus.PUBLISHED)
 
1488
        [foo_bin_pub] = self.getPubBinaries(
 
1489
            binaryname="foo-bin", status=PackagePublishingStatus.PUBLISHED,
 
1490
            architecturespecific=True, version=version,
 
1491
            pub_source=foo_src_pub)
 
1492
        # Now need to grab the build for the source so we can add
 
1493
        # more binaries to it.
 
1494
        [build] = foo_src_pub.getBuilds()
 
1495
        foo_one_common = self.factory.makeBinaryPackageRelease(
 
1496
            binarypackagename="foo-one-common", version=version, build=build,
 
1497
            architecturespecific=False)
 
1498
        foo_one_common_pubs = self.publishBinaryInArchive(
 
1499
            foo_one_common, self.ubuntutest.main_archive,
 
1500
            pocket=foo_src_pub.pocket,
 
1501
            status=PackagePublishingStatus.PUBLISHED)
 
1502
        foo_two_common = self.factory.makeBinaryPackageRelease(
 
1503
            binarypackagename="foo-two-common", version=version, build=build,
 
1504
            architecturespecific=False)
 
1505
        foo_two_common_pubs = self.publishBinaryInArchive(
 
1506
            foo_two_common, self.ubuntutest.main_archive,
 
1507
            pocket=foo_src_pub.pocket,
 
1508
            status=PackagePublishingStatus.PUBLISHED)
 
1509
        foo_three = self.factory.makeBinaryPackageRelease(
 
1510
            binarypackagename="foo-three", version=version, build=build,
 
1511
            architecturespecific=True)
 
1512
        [foo_three_pub] = self.publishBinaryInArchive(
 
1513
            foo_three, self.ubuntutest.main_archive,
 
1514
            pocket=foo_src_pub.pocket,
 
1515
            status=PackagePublishingStatus.PUBLISHED)
 
1516
        # So now we have source foo, which has arch specific binaries
 
1517
        # foo-bin and foo-three, and arch:all binaries foo-one-common and
 
1518
        # foo-two-common. The latter two will have multiple publications,
 
1519
        # one for each DAS in the series.
 
1520
        return (
 
1521
            foo_src_pub, foo_bin_pub, foo_one_common_pubs,
 
1522
            foo_two_common_pubs, foo_three_pub)
 
1523
 
 
1524
    def test_getOtherPublicationsForSameSource(self):
 
1525
        # By default getOtherPublicationsForSameSource should return all
 
1526
        # of the other binaries built by the same source as the passed
 
1527
        # binary publication, except the arch-indep ones.
 
1528
        (foo_src_pub, foo_bin_pub, foo_one_common_pubs, foo_two_common_pubs,
 
1529
            foo_three_pub) = self._makeMixedSingleBuildPackage()
 
1530
 
 
1531
        foo_one_common_pub = foo_one_common_pubs[0]
 
1532
        others = foo_one_common_pub.getOtherPublicationsForSameSource()
 
1533
        others = list(others)
 
1534
 
 
1535
        self.assertContentEqual([foo_three_pub, foo_bin_pub], others)
 
1536
 
 
1537
    def test_getOtherPublicationsForSameSource_include_archindep(self):
 
1538
        # Check that the arch-indep binaries are returned if requested.
 
1539
        (foo_src_pub, foo_bin_pub, foo_one_common_pubs, foo_two_common_pubs,
 
1540
         foo_three_pub) = self._makeMixedSingleBuildPackage()
 
1541
 
 
1542
        foo_one_common_pub = foo_one_common_pubs[0]
 
1543
        others = foo_one_common_pub.getOtherPublicationsForSameSource(
 
1544
            include_archindep=True)
 
1545
        others = list(others)
 
1546
 
 
1547
        # We expect all publications created above to be returned,
 
1548
        # except the one we use to call the method on.
 
1549
        expected = [foo_three_pub, foo_bin_pub]
 
1550
        expected.extend(foo_one_common_pubs[1:])
 
1551
        expected.extend(foo_two_common_pubs)
 
1552
        self.assertContentEqual(expected, others)
 
1553
 
 
1554
    def test_getOtherPublicationsForSameSource_inactive(self):
 
1555
        # Check that inactive publications are not returned.
 
1556
        (foo_src_pub, foo_bin_pub, foo_one_common_pubs, foo_two_common_pubs,
 
1557
             foo_three_pub) = self._makeMixedSingleBuildPackage()
 
1558
        foo_bin_pub.status = PackagePublishingStatus.SUPERSEDED
 
1559
        foo_three_pub.status = PackagePublishingStatus.SUPERSEDED
 
1560
        foo_one_common_pub = foo_one_common_pubs[0]
 
1561
        others = foo_one_common_pub.getOtherPublicationsForSameSource()
 
1562
        others = list(others)
 
1563
 
 
1564
        self.assertEqual(0, len(others))
 
1565
 
 
1566
    def test_getOtherPublicationsForSameSource_multiple_versions(self):
 
1567
        # Check that publications for only the same version as the
 
1568
        # context binary publication are returned.
 
1569
        (foo_src_pub, foo_bin_pub, foo_one_common_pubs, foo_two_common_pubs,
 
1570
         foo_three_pub) = self._makeMixedSingleBuildPackage(version="1.0")
 
1571
        self._makeMixedSingleBuildPackage(version="1.1")
 
1572
 
 
1573
        foo_one_common_pub = foo_one_common_pubs[0]
 
1574
        others = foo_one_common_pub.getOtherPublicationsForSameSource()
 
1575
        others = list(others)
 
1576
 
 
1577
        self.assertContentEqual([foo_three_pub, foo_bin_pub], others)
 
1578
 
 
1579
 
1474
1580
class TestGetBuiltBinaries(TestNativePublishingBase):
1475
1581
    """Test SourcePackagePublishingHistory.getBuiltBinaries() works."""
1476
1582