def test_copy_archive_without_leak(self):
     # If source publications are copied to a .COPY archive, they don't
     # "leak" into SourcePackage.getBuildRecords().
     admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
     # Set up a distroseries and related bits, so we can create builds.
     source_name = self.factory.getUniqueString()
     spn = self.factory.makeSourcePackageName(name=source_name)
     processor = self.factory.makeProcessor()
     distroseries = self.factory.makeDistroSeries()
     das = self.factory.makeDistroArchSeries(distroseries=distroseries,
                                             processor=processor,
                                             supports_virtualized=True)
     with person_logged_in(admin):
         publisher = SoyuzTestPublisher()
         publisher.prepareBreezyAutotest()
         publisher.addFakeChroots(distroseries=distroseries)
         distroseries.nominatedarchindep = das
         self.factory.makeBuilder(processor=processor)
     spph = self.factory.makeSourcePackagePublishingHistory(
         sourcepackagename=spn, distroseries=distroseries)
     spph.createMissingBuilds()
     # Create a copy archive.
     copy = self.factory.makeArchive(purpose=ArchivePurpose.COPY,
                                     distribution=distroseries.distribution)
     # And copy the publication into it.
     copy_spph = spph.copyTo(distroseries, PackagePublishingPocket.RELEASE,
                             copy)
     [copy_build] = copy_spph.createMissingBuilds()
     builds = copy.getBuildRecords()
     self.assertEquals([copy_build], list(builds))
     source = SourcePackage(spn, spph.distroseries)
     # SourcePackage.getBuildRecords() doesn't have two build records.
     builds = source.getBuildRecords().count()
     self.assertEquals(1, builds)
 def test_copy_archive_without_leak(self):
     # If source publications are copied to a .COPY archive, they don't
     # "leak" into SourcePackage.getBuildRecords().
     admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
     # Set up a distroseries and related bits, so we can create builds.
     source_name = self.factory.getUniqueString()
     spn = self.factory.makeSourcePackageName(name=source_name)
     processor = self.factory.makeProcessor()
     distroseries = self.factory.makeDistroSeries()
     das = self.factory.makeDistroArchSeries(
         distroseries=distroseries, processor=processor,
         supports_virtualized=True)
     with person_logged_in(admin):
         publisher = SoyuzTestPublisher()
         publisher.prepareBreezyAutotest()
         publisher.addFakeChroots(distroseries=distroseries)
         distroseries.nominatedarchindep = das
         self.factory.makeBuilder(processor=processor)
     spph = self.factory.makeSourcePackagePublishingHistory(
         sourcepackagename=spn, distroseries=distroseries)
     spph.createMissingBuilds()
     # Create a copy archive.
     copy = self.factory.makeArchive(
         purpose=ArchivePurpose.COPY,
         distribution=distroseries.distribution)
     # And copy the publication into it.
     copy_spph = spph.copyTo(
         distroseries, PackagePublishingPocket.RELEASE, copy)
     [copy_build] = copy_spph.createMissingBuilds()
     builds = copy.getBuildRecords()
     self.assertEquals([copy_build], list(builds))
     source = SourcePackage(spn, spph.distroseries)
     # SourcePackage.getBuildRecords() doesn't have two build records.
     builds = source.getBuildRecords().count()
     self.assertEquals(1, builds)
 def sourcepackages(self):
     """See IProductSeries"""
     from lp.registry.model.sourcepackage import SourcePackage
     ret = self.packagings
     ret = [SourcePackage(sourcepackagename=r.sourcepackagename,
                          distroseries=r.distroseries)
                 for r in ret]
     ret.sort(key=lambda a: a.distribution.name + a.distroseries.version
              + a.sourcepackagename.name)
     return ret
示例#4
0
 def setUp(self):
     super(TestReuploadPackageTranslations, self).setUp()
     sourcepackagename = self.factory.makeSourcePackageName()
     distroseries = self.factory.makeDistroSeries()
     self.sourcepackage = SourcePackage(sourcepackagename, distroseries)
     self.script = ReuploadPackageTranslations(
         'reupload',
         test_args=[
             '-d', distroseries.distribution.name, '-s', distroseries.name,
             '-p', sourcepackagename.name, '-qqq'
         ])
    def setUp(self):
        super(TestSourcePackageHasBuildRecords, self).setUp()
        gedit_name = self.builds[0].source_package_release.sourcepackagename
        self.context = SourcePackage(
            gedit_name, self.builds[0].distro_arch_series.distroseries)

        # Convert the other two builds to be builds of
        # gedit as well so that the one source package (gedit) will have
        # three builds.
        for build in self.builds[1:3]:
            spr = build.source_package_release
            removeSecurityProxy(spr).sourcepackagename = gedit_name
            IStore(SourcePackagePublishingHistory).find(
                SourcePackagePublishingHistory, sourcepackagerelease=spr).set(
                    sourcepackagenameID=gedit_name.id)

        # Set them as sucessfully built
        for build in self.builds:
            build.updateStatus(BuildStatus.BUILDING)
            build.updateStatus(BuildStatus.FULLYBUILT)
 def get_distroseries_packages(self, active_only=True):
     """See `IDistributionSourcePackage`."""
     result = []
     for series in self.distribution.series:
         if active_only:
             if not series.active:
                 continue
         candidate = SourcePackage(self.sourcepackagename, series)
         if candidate.currentrelease is not None:
             result.append(candidate)
     return result
 def test_ordering_lastscore(self):
     # PENDING build records returned are ordered by score.
     spph = self.factory.makeSourcePackagePublishingHistory()
     spr = spph.sourcepackagerelease
     source_package = SourcePackage.new(
         spph.sourcepackagerelease.sourcepackagename, spph.distroseries)
     build1 = self.factory.makeBinaryPackageBuild(
         source_package_release=spr)
     build2 = self.factory.makeBinaryPackageBuild(
         source_package_release=spr)
     build1.queueBuild()
     build2.queueBuild()
     build1.buildqueue_record.lastscore = 10
     build2.buildqueue_record.lastscore = 1000
     builds = list(source_package.getBuildRecords())
     self.assertEquals([build2, build1], builds)
 def test_ordering_lastscore(self):
     # PENDING build records returned are ordered by score.
     spph = self.factory.makeSourcePackagePublishingHistory()
     spr = spph.sourcepackagerelease
     source_package = SourcePackage.new(
         spph.sourcepackagerelease.sourcepackagename, spph.distroseries)
     build1 = self.factory.makeBinaryPackageBuild(
         source_package_release=spr)
     build2 = self.factory.makeBinaryPackageBuild(
         source_package_release=spr)
     build1.queueBuild()
     build2.queueBuild()
     build1.buildqueue_record.lastscore = 10
     build2.buildqueue_record.lastscore = 1000
     builds = list(source_package.getBuildRecords())
     self.assertEquals([build2, build1], builds)
示例#9
0
 def get(self,
         person,
         product=None,
         distroseries=None,
         sourcepackagename=None):
     """See `IBranchNamespaceSet`."""
     if product is not None:
         assert (distroseries is None and sourcepackagename is None), (
             "product implies no distroseries or sourcepackagename. "
             "Got %r, %r, %r." % (product, distroseries, sourcepackagename))
         return ProductNamespace(person, product)
     elif distroseries is not None:
         assert sourcepackagename is not None, (
             "distroseries implies sourcepackagename. Got %r, %r" %
             (distroseries, sourcepackagename))
         return PackageNamespace(
             person, SourcePackage(sourcepackagename, distroseries))
     else:
         return PersonalNamespace(person)
    def setUp(self):
        super(TestSourcePackageHasBuildRecords, self).setUp()
        gedit_name = self.builds[0].source_package_release.sourcepackagename
        self.context = SourcePackage(
            gedit_name, self.builds[0].distro_arch_series.distroseries)

        # Convert the other two builds to be builds of
        # gedit as well so that the one source package (gedit) will have
        # three builds.
        for build in self.builds[1:3]:
            spr = build.source_package_release
            removeSecurityProxy(spr).sourcepackagename = gedit_name
            IStore(SourcePackagePublishingHistory).find(
                SourcePackagePublishingHistory, sourcepackagerelease=spr
                ).set(sourcepackagenameID=gedit_name.id)

        # Set them as sucessfully built
        for build in self.builds:
            build.updateStatus(BuildStatus.BUILDING)
            build.updateStatus(BuildStatus.FULLYBUILT)
class TestSourcePackageHasBuildRecords(TestHasBuildRecordsInterface):
    """Test the SourcePackage implementation of IHasBuildRecords."""
    def setUp(self):
        super(TestSourcePackageHasBuildRecords, self).setUp()
        gedit_name = self.builds[0].source_package_release.sourcepackagename
        self.context = SourcePackage(
            gedit_name, self.builds[0].distro_arch_series.distroseries)

        # Convert the other two builds to be builds of
        # gedit as well so that the one source package (gedit) will have
        # three builds.
        for build in self.builds[1:3]:
            spr = build.source_package_release
            removeSecurityProxy(spr).sourcepackagename = gedit_name
            IStore(SourcePackagePublishingHistory).find(
                SourcePackagePublishingHistory, sourcepackagerelease=spr).set(
                    sourcepackagenameID=gedit_name.id)

        # Set them as sucessfully built
        for build in self.builds:
            build.updateStatus(BuildStatus.BUILDING)
            build.updateStatus(BuildStatus.FULLYBUILT)

    def test_get_build_records(self):
        # We can fetch builds records from a SourcePackage.
        builds = self.context.getBuildRecords(
            build_state=BuildStatus.FULLYBUILT).count()
        self.assertEquals(3, builds)
        builds = self.context.getBuildRecords(
            pocket=PackagePublishingPocket.RELEASE).count()
        self.assertEquals(3, builds)
        builds = self.context.getBuildRecords(
            pocket=PackagePublishingPocket.UPDATES).count()
        self.assertEquals(0, builds)

    def test_ordering_date(self):
        # Build records returned are ordered by creation date.
        builds = self.context.getBuildRecords(
            build_state=BuildStatus.FULLYBUILT)
        date_created = [build.date_created for build in builds]
        self.assertTrue(date_created[0] > date_created[1] > date_created[2])

    def test_ordering_lastscore(self):
        # PENDING build records returned are ordered by score.
        spph = self.factory.makeSourcePackagePublishingHistory()
        spr = spph.sourcepackagerelease
        source_package = SourcePackage.new(
            spph.sourcepackagerelease.sourcepackagename, spph.distroseries)
        build1 = self.factory.makeBinaryPackageBuild(
            source_package_release=spr)
        build2 = self.factory.makeBinaryPackageBuild(
            source_package_release=spr)
        build1.queueBuild()
        build2.queueBuild()
        build1.buildqueue_record.lastscore = 10
        build2.buildqueue_record.lastscore = 1000
        builds = list(source_package.getBuildRecords())
        self.assertEquals([build2, build1], builds)

    def test_copy_archive_without_leak(self):
        # If source publications are copied to a .COPY archive, they don't
        # "leak" into SourcePackage.getBuildRecords().
        admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
        # Set up a distroseries and related bits, so we can create builds.
        source_name = self.factory.getUniqueString()
        spn = self.factory.makeSourcePackageName(name=source_name)
        processor = self.factory.makeProcessor()
        distroseries = self.factory.makeDistroSeries()
        das = self.factory.makeDistroArchSeries(distroseries=distroseries,
                                                processor=processor,
                                                supports_virtualized=True)
        with person_logged_in(admin):
            publisher = SoyuzTestPublisher()
            publisher.prepareBreezyAutotest()
            publisher.addFakeChroots(distroseries=distroseries)
            distroseries.nominatedarchindep = das
            self.factory.makeBuilder(processor=processor)
        spph = self.factory.makeSourcePackagePublishingHistory(
            sourcepackagename=spn, distroseries=distroseries)
        spph.createMissingBuilds()
        # Create a copy archive.
        copy = self.factory.makeArchive(purpose=ArchivePurpose.COPY,
                                        distribution=distroseries.distribution)
        # And copy the publication into it.
        copy_spph = spph.copyTo(distroseries, PackagePublishingPocket.RELEASE,
                                copy)
        [copy_build] = copy_spph.createMissingBuilds()
        builds = copy.getBuildRecords()
        self.assertEquals([copy_build], list(builds))
        source = SourcePackage(spn, spph.distroseries)
        # SourcePackage.getBuildRecords() doesn't have two build records.
        builds = source.getBuildRecords().count()
        self.assertEquals(1, builds)
示例#12
0
 def sourcepackage(self):
     from lp.registry.model.sourcepackage import SourcePackage
     return SourcePackage(distroseries=self.distroseries,
                          sourcepackagename=self.sourcepackagename)
class TestSourcePackageHasBuildRecords(TestHasBuildRecordsInterface):
    """Test the SourcePackage implementation of IHasBuildRecords."""

    def setUp(self):
        super(TestSourcePackageHasBuildRecords, self).setUp()
        gedit_name = self.builds[0].source_package_release.sourcepackagename
        self.context = SourcePackage(
            gedit_name, self.builds[0].distro_arch_series.distroseries)

        # Convert the other two builds to be builds of
        # gedit as well so that the one source package (gedit) will have
        # three builds.
        for build in self.builds[1:3]:
            spr = build.source_package_release
            removeSecurityProxy(spr).sourcepackagename = gedit_name
            IStore(SourcePackagePublishingHistory).find(
                SourcePackagePublishingHistory, sourcepackagerelease=spr
                ).set(sourcepackagenameID=gedit_name.id)

        # Set them as sucessfully built
        for build in self.builds:
            build.updateStatus(BuildStatus.BUILDING)
            build.updateStatus(BuildStatus.FULLYBUILT)

    def test_get_build_records(self):
        # We can fetch builds records from a SourcePackage.
        builds = self.context.getBuildRecords(
            build_state=BuildStatus.FULLYBUILT).count()
        self.assertEquals(3, builds)
        builds = self.context.getBuildRecords(
            pocket=PackagePublishingPocket.RELEASE).count()
        self.assertEquals(3, builds)
        builds = self.context.getBuildRecords(
            pocket=PackagePublishingPocket.UPDATES).count()
        self.assertEquals(0, builds)

    def test_ordering_date(self):
        # Build records returned are ordered by creation date.
        builds = self.context.getBuildRecords(
            build_state=BuildStatus.FULLYBUILT)
        date_created = [build.date_created for build in builds]
        self.assertTrue(date_created[0] > date_created[1] > date_created[2])

    def test_ordering_lastscore(self):
        # PENDING build records returned are ordered by score.
        spph = self.factory.makeSourcePackagePublishingHistory()
        spr = spph.sourcepackagerelease
        source_package = SourcePackage.new(
            spph.sourcepackagerelease.sourcepackagename, spph.distroseries)
        build1 = self.factory.makeBinaryPackageBuild(
            source_package_release=spr)
        build2 = self.factory.makeBinaryPackageBuild(
            source_package_release=spr)
        build1.queueBuild()
        build2.queueBuild()
        build1.buildqueue_record.lastscore = 10
        build2.buildqueue_record.lastscore = 1000
        builds = list(source_package.getBuildRecords())
        self.assertEquals([build2, build1], builds)

    def test_copy_archive_without_leak(self):
        # If source publications are copied to a .COPY archive, they don't
        # "leak" into SourcePackage.getBuildRecords().
        admin = getUtility(IPersonSet).getByEmail(ADMIN_EMAIL)
        # Set up a distroseries and related bits, so we can create builds.
        source_name = self.factory.getUniqueString()
        spn = self.factory.makeSourcePackageName(name=source_name)
        processor = self.factory.makeProcessor()
        distroseries = self.factory.makeDistroSeries()
        das = self.factory.makeDistroArchSeries(
            distroseries=distroseries, processor=processor,
            supports_virtualized=True)
        with person_logged_in(admin):
            publisher = SoyuzTestPublisher()
            publisher.prepareBreezyAutotest()
            publisher.addFakeChroots(distroseries=distroseries)
            distroseries.nominatedarchindep = das
            self.factory.makeBuilder(processor=processor)
        spph = self.factory.makeSourcePackagePublishingHistory(
            sourcepackagename=spn, distroseries=distroseries)
        spph.createMissingBuilds()
        # Create a copy archive.
        copy = self.factory.makeArchive(
            purpose=ArchivePurpose.COPY,
            distribution=distroseries.distribution)
        # And copy the publication into it.
        copy_spph = spph.copyTo(
            distroseries, PackagePublishingPocket.RELEASE, copy)
        [copy_build] = copy_spph.createMissingBuilds()
        builds = copy.getBuildRecords()
        self.assertEquals([copy_build], list(builds))
        source = SourcePackage(spn, spph.distroseries)
        # SourcePackage.getBuildRecords() doesn't have two build records.
        builds = source.getBuildRecords().count()
        self.assertEquals(1, builds)