~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/testing/factory.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-07-13 20:55:34 UTC
  • mfrom: (13372.2.14 bug-805634)
  • Revision ID: launchpad@pqm.canonical.com-20110713205534-5bw3ytd7fjr7rj6v
[r=jcsackett][bug=805634] Harmonize copy and regular builds scoring
 rules. Cleaned-up some Soyuz test helpers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2549
2549
        """
2550
2550
        if purpose is None:
2551
2551
            purpose = ArchivePurpose.PPA
 
2552
        elif isinstance(purpose, basestring):
 
2553
            purpose = ArchivePurpose.items[purpose.upper()]
 
2554
 
2552
2555
        if distribution is None:
2553
2556
            # See bug #568769
2554
2557
            if purpose == ArchivePurpose.PPA:
3482
3485
                    distribution=distribution)
3483
3486
 
3484
3487
        if archive is None:
3485
 
            archive = self.makeArchive(
3486
 
                distribution=distroseries.distribution,
3487
 
                purpose=ArchivePurpose.PRIMARY)
 
3488
            archive = distroseries.main_archive
3488
3489
 
3489
3490
        if (sourcepackagename is None or
3490
3491
            isinstance(sourcepackagename, basestring)):
3491
3492
            sourcepackagename = self.getOrMakeSourcePackageName(
3492
3493
                sourcepackagename)
3493
3494
 
3494
 
        if component is None:
3495
 
            component = self.makeComponent()
 
3495
        if (component is None or isinstance(component, basestring)):
 
3496
            component = self.makeComponent(component)
3496
3497
 
3497
3498
        if urgency is None:
3498
3499
            urgency = self.getAnySourcePackageUrgency()
 
3500
        elif isinstance(urgency, basestring):
 
3501
            urgency = SourcePackageUrgency.items[urgency.upper()]
3499
3502
 
3500
3503
        section = self.makeSection(name=section_name)
3501
3504
 
3566
3569
            build uses as its source.
3567
3570
        :param sourcepackagename: when source_package_release is None, the
3568
3571
            sourcepackagename from which the build will come.
3569
 
        :param distroarchseries: The DistroArchSeries to use.
3570
 
        :param archive: The Archive to use.
 
3572
        :param distroarchseries: The DistroArchSeries to use. Defaults to the
 
3573
            one from the source_package_release, or a new one if not provided.
 
3574
        :param archive: The Archive to use. Defaults to the one from the
 
3575
            source_package_release, or the distro arch series main archive
 
3576
            otherwise.
3571
3577
        :param builder: An optional builder to assign.
3572
3578
        :param status: The BuildStatus for the build.
3573
3579
        """
3574
 
        if archive is None:
3575
 
            if source_package_release is None:
3576
 
                archive = self.makeArchive()
3577
 
            else:
3578
 
                archive = source_package_release.upload_archive
3579
3580
        if processor is None:
3580
3581
            processor = self.makeProcessor()
3581
3582
        if distroarchseries is None:
3586
3587
            distroarchseries = self.makeDistroArchSeries(
3587
3588
                distroseries=distroseries,
3588
3589
                processorfamily=processor.family)
 
3590
        if archive is None:
 
3591
            if source_package_release is None:
 
3592
                archive = distroarchseries.main_archive
 
3593
            else:
 
3594
                archive = source_package_release.upload_archive
3589
3595
        if pocket is None:
3590
3596
            pocket = PackagePublishingPocket.RELEASE
 
3597
        elif isinstance(pocket, basestring):
 
3598
            pocket = PackagePublishingPocket.items[pocket.upper()]
 
3599
 
3591
3600
        if source_package_release is None:
3592
3601
            multiverse = self.makeComponent(name='multiverse')
3593
3602
            source_package_release = self.makeSourcePackageRelease(
3615
3624
        IStore(binary_package_build).flush()
3616
3625
        return binary_package_build
3617
3626
 
3618
 
    def makeSourcePackagePublishingHistory(self, sourcepackagename=None,
3619
 
                                           distroseries=None, maintainer=None,
3620
 
                                           creator=None, component=None,
3621
 
                                           section_name=None,
3622
 
                                           urgency=None, version=None,
 
3627
    def makeSourcePackagePublishingHistory(self,
 
3628
                                           distroseries=None,
3623
3629
                                           archive=None,
3624
 
                                           builddepends=None,
3625
 
                                           builddependsindep=None,
3626
 
                                           build_conflicts=None,
3627
 
                                           build_conflicts_indep=None,
3628
 
                                           architecturehintlist='all',
3629
 
                                           dateremoved=None,
3630
 
                                           date_uploaded=UTC_NOW,
 
3630
                                           sourcepackagerelease=None,
3631
3631
                                           pocket=None,
3632
3632
                                           status=None,
 
3633
                                           dateremoved=None,
 
3634
                                           date_uploaded=UTC_NOW,
3633
3635
                                           scheduleddeletiondate=None,
3634
 
                                           dsc_standards_version='3.6.2',
3635
 
                                           dsc_format='1.0',
3636
 
                                           dsc_binaries='foo-bin',
3637
 
                                           sourcepackagerelease=None,
3638
3636
                                           ancestor=None,
 
3637
                                           **kwargs
3639
3638
                                           ):
3640
 
        """Make a `SourcePackagePublishingHistory`."""
 
3639
        """Make a `SourcePackagePublishingHistory`.
 
3640
 
 
3641
        :param sourcepackagerelease: The source package release to publish
 
3642
            If not provided, a new one will be created.
 
3643
        :param distroseries: The distro series in which to publish.
 
3644
            Default to the source package release one, or a new one will
 
3645
            be created when not provided.
 
3646
        :param archive: The archive to publish into. Default to the
 
3647
            initial source package release  upload archive, or to the
 
3648
            distro series main archive.
 
3649
        :param pocket: The pocket to publish into. Can be specified as a
 
3650
            string. Defaults to the RELEASE pocket.
 
3651
        :param status: The publication status. Defaults to PENDING. If
 
3652
            set to PUBLISHED, the publisheddate will be set to now.
 
3653
        :param dateremoved: The removal date.
 
3654
        :param date_uploaded: The upload date. Defaults to now.
 
3655
        :param scheduleddeletiondate: The date where the publication
 
3656
            is scheduled to be removed.
 
3657
        :param ancestor: The publication ancestor parameter.
 
3658
        :param **kwargs: All other parameters are passed through to the
 
3659
            makeSourcePackageRelease call if needed.
 
3660
        """
3641
3661
        if distroseries is None:
3642
 
            if archive is None:
3643
 
                distribution = None
 
3662
            if sourcepackagerelease is not None:
 
3663
                distroseries = sourcepackagerelease.upload_distroseries
3644
3664
            else:
3645
 
                distribution = archive.distribution
3646
 
            distroseries = self.makeDistroRelease(distribution=distribution)
3647
 
 
 
3665
                if archive is None:
 
3666
                    distribution = None
 
3667
                else:
 
3668
                    distribution = archive.distribution
 
3669
                distroseries = self.makeDistroRelease(
 
3670
                    distribution=distribution)
3648
3671
        if archive is None:
3649
 
            archive = self.makeArchive(
3650
 
                distribution=distroseries.distribution,
3651
 
                purpose=ArchivePurpose.PRIMARY)
 
3672
            archive = distroseries.main_archive
3652
3673
 
3653
3674
        if pocket is None:
3654
3675
            pocket = self.getAnyPocket()
 
3676
        elif isinstance(pocket, basestring):
 
3677
            pocket = PackagePublishingPocket.items[pocket.upper()]
3655
3678
 
3656
3679
        if status is None:
3657
3680
            status = PackagePublishingStatus.PENDING
 
3681
        elif isinstance(status, basestring):
 
3682
            status = PackagePublishingStatus.items[status.upper()]
3658
3683
 
3659
3684
        if sourcepackagerelease is None:
3660
3685
            sourcepackagerelease = self.makeSourcePackageRelease(
3661
 
                archive=archive,
3662
 
                sourcepackagename=sourcepackagename,
3663
 
                distroseries=distroseries,
3664
 
                maintainer=maintainer,
3665
 
                creator=creator, component=component,
3666
 
                section_name=section_name,
3667
 
                urgency=urgency,
3668
 
                version=version,
3669
 
                builddepends=builddepends,
3670
 
                builddependsindep=builddependsindep,
3671
 
                build_conflicts=build_conflicts,
3672
 
                build_conflicts_indep=build_conflicts_indep,
3673
 
                architecturehintlist=architecturehintlist,
3674
 
                dsc_standards_version=dsc_standards_version,
3675
 
                dsc_format=dsc_format,
3676
 
                dsc_binaries=dsc_binaries,
3677
 
                date_uploaded=date_uploaded)
 
3686
                archive=archive, distroseries=distroseries,
 
3687
                date_uploaded=date_uploaded, **kwargs)
3678
3688
 
3679
3689
        spph = getUtility(IPublishingSet).newSourcePublication(
3680
3690
            archive, sourcepackagerelease, distroseries,