~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

Merge db-devel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
258
258
    default_name_by_purpose,
259
259
    IArchiveSet,
260
260
    )
 
261
from lp.soyuz.interfaces.archivepermission import IArchivePermissionSet
261
262
from lp.soyuz.interfaces.binarypackagebuild import IBinaryPackageBuildSet
262
263
from lp.soyuz.interfaces.binarypackagename import IBinaryPackageNameSet
263
264
from lp.soyuz.interfaces.component import (
2386
2387
        versions=None,
2387
2388
        difference_type=DistroSeriesDifferenceType.DIFFERENT_VERSIONS,
2388
2389
        status=DistroSeriesDifferenceStatus.NEEDS_ATTENTION,
2389
 
        changelogs=None, set_base_version=False):
 
2390
        changelogs=None, set_base_version=False, parent_series=None):
2390
2391
        """Create a new distro series source package difference."""
2391
2392
        if derived_series is None:
2392
 
            parent_series = self.makeDistroSeries()
2393
 
            derived_series = self.makeDistroSeries(
2394
 
                previous_series=parent_series)
 
2393
            dsp = self.makeDistroSeriesParent(
 
2394
                parent_series=parent_series)
 
2395
            derived_series = dsp.derived_series
 
2396
            parent_series = dsp.parent_series
 
2397
        else:
 
2398
            if parent_series is None:
 
2399
                dsp = getUtility(IDistroSeriesParentSet).getByDerivedSeries(
 
2400
                    derived_series)
 
2401
                if dsp.count() == 0:
 
2402
                    new_dsp = self.makeDistroSeriesParent(
 
2403
                        derived_series=derived_series,
 
2404
                        parent_series=parent_series)
 
2405
                    parent_series = new_dsp.parent_series
 
2406
                else:
 
2407
                    parent_series = dsp[0].parent_series
2395
2408
 
2396
2409
        if source_package_name_str is None:
2397
2410
            source_package_name_str = self.getUniqueString('src-name')
2406
2419
 
2407
2420
        base_version = versions.get('base')
2408
2421
        if base_version is not None:
2409
 
            for series in [derived_series, derived_series.previous_series]:
 
2422
            for series in [derived_series, parent_series]:
2410
2423
                spr = self.makeSourcePackageRelease(
2411
2424
                    sourcepackagename=source_package_name,
2412
2425
                    version=base_version)
2431
2444
                version=versions.get('parent'),
2432
2445
                changelog=changelogs.get('parent'))
2433
2446
            self.makeSourcePackagePublishingHistory(
2434
 
                distroseries=derived_series.previous_series,
 
2447
                distroseries=parent_series,
2435
2448
                sourcepackagerelease=spr,
2436
2449
                status=PackagePublishingStatus.PUBLISHED)
2437
2450
 
2438
2451
        diff = getUtility(IDistroSeriesDifferenceSource).new(
2439
 
            derived_series, source_package_name)
 
2452
            derived_series, source_package_name, parent_series)
2440
2453
 
2441
2454
        removeSecurityProxy(diff).status = status
2442
2455
 
2463
2476
            distro_series_difference, owner, comment)
2464
2477
 
2465
2478
    def makeDistroSeriesParent(self, derived_series=None, parent_series=None,
2466
 
                               initialized=False):
 
2479
                               initialized=False, is_overlay=False,
 
2480
                               pocket=None, component=None):
2467
2481
        if parent_series is None:
2468
2482
            parent_series = self.makeDistroSeries()
2469
2483
        if derived_series is None:
2470
2484
            derived_series = self.makeDistroSeries()
2471
2485
        return getUtility(IDistroSeriesParentSet).new(
2472
 
            derived_series, parent_series, initialized)
 
2486
            derived_series, parent_series, initialized, is_overlay, pocket,
 
2487
            component)
2473
2488
 
2474
2489
    def makeDistroArchSeries(self, distroseries=None,
2475
2490
                             architecturetag=None, processorfamily=None,
2565
2580
 
2566
2581
        return archive
2567
2582
 
 
2583
    def makeArchiveAdmin(self, archive=None):
 
2584
        """Make an Archive Admin.
 
2585
 
 
2586
        :param archive: The `IArchive`, will be auto-created if None.
 
2587
 
 
2588
        Make and return an `IPerson` who has an `ArchivePermission` to admin
 
2589
        the distroseries queue.
 
2590
        """
 
2591
        if archive is None:
 
2592
            archive = self.makeArchive()
 
2593
 
 
2594
        person = self.makePerson()
 
2595
        permission_set = getUtility(IArchivePermissionSet)
 
2596
        permission_set.newQueueAdmin(archive, person, 'main')
 
2597
        return person
 
2598
 
2568
2599
    def makeBuilder(self, processor=None, url=None, name=None, title=None,
2569
2600
                    description=None, owner=None, active=True,
2570
2601
                    virtualized=True, vm_host=None, manual=False):