~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

Merge db-devel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
    datetime,
9
9
    timedelta,
10
10
    )
 
11
import doctest
11
12
 
 
13
from testtools.matchers import DocTestMatches
12
14
import transaction
13
15
from zope.component import getUtility
14
16
from zope.security.interfaces import Unauthorized
36
38
from lp.services.job.interfaces.job import JobStatus
37
39
from lp.services.propertycache import clear_property_cache
38
40
from lp.services.worlddata.interfaces.country import ICountrySet
 
41
from lp.soyuz.adapters.archivedependencies import (
 
42
    get_sources_list_for_building,
 
43
    )
39
44
from lp.soyuz.enums import (
40
45
    ArchivePermissionType,
41
46
    ArchivePurpose,
1429
1434
        self.assertDep('i386', 'foo-universe', [universe_bins[0]])
1430
1435
 
1431
1436
 
 
1437
class TestOverlays(TestCaseWithFactory):
 
1438
 
 
1439
    layer = LaunchpadZopelessLayer
 
1440
 
 
1441
    def _createDep(self, derived_series, parent_series,
 
1442
                   parent_distro, component_name=None, pocket=None,
 
1443
                   overlay=True, arch_tag='i386',
 
1444
                   publish_base_url=u'http://archive.launchpad.dev/'):
 
1445
        # Helper to create a parent/child relationshipi.
 
1446
        if type(parent_distro) == str:
 
1447
            depdistro = self.factory.makeDistribution(parent_distro,
 
1448
                publish_base_url=publish_base_url)
 
1449
        else:
 
1450
            depdistro = parent_distro
 
1451
        if type(parent_series) == str:
 
1452
            depseries = self.factory.makeDistroSeries(
 
1453
                name=parent_series, distribution=depdistro)
 
1454
            deparchseries = self.factory.makeDistroArchSeries(
 
1455
                distroseries=depseries, architecturetag=arch_tag)
 
1456
        else:
 
1457
            depseries = parent_series
 
1458
        if component_name is not None:
 
1459
            component = getUtility(IComponentSet)[component_name]
 
1460
        else:
 
1461
            component = None
 
1462
 
 
1463
        self.factory.makeDistroSeriesParent(
 
1464
            derived_series=derived_series, parent_series=depseries,
 
1465
            initialized=True, is_overlay=overlay, pocket=pocket,
 
1466
            component=component)
 
1467
        return depseries, depdistro
 
1468
 
 
1469
    def test_overlay_dependencies(self):
 
1470
        # sources.list is properly generated for a complex overlay structure.
 
1471
        # Pocket dependencies and component dependencies are taken into
 
1472
        # account when generating sources.list.
 
1473
        #
 
1474
        #            breezy               type of relation:
 
1475
        #               |                    |           |
 
1476
        #    -----------------------         |           o
 
1477
        #    |          |          |         |           |
 
1478
        #    o          o          |      no overlay  overlay
 
1479
        #    |          |          |
 
1480
        # series11  series21   series31
 
1481
        #    |
 
1482
        #    o
 
1483
        #    |
 
1484
        # series12
 
1485
        #
 
1486
        test_publisher = SoyuzTestPublisher()
 
1487
        test_publisher.prepareBreezyAutotest()
 
1488
        breezy = test_publisher.breezy_autotest
 
1489
        pub_source = test_publisher.getPubSource(
 
1490
            version='1.1', archive=breezy.main_archive)
 
1491
        [build] = pub_source.createMissingBuilds()
 
1492
        series11, depdistro = self._createDep(
 
1493
            breezy, 'series11', 'depdistro', 'universe',
 
1494
            PackagePublishingPocket.SECURITY)
 
1495
        self._createDep(
 
1496
            breezy, 'series21', 'depdistro2', 'multiverse',
 
1497
            PackagePublishingPocket.UPDATES)
 
1498
        self._createDep(breezy, 'series31', 'depdistro3', overlay=False)
 
1499
        self._createDep(
 
1500
            series11, 'series12', 'depdistro4', 'multiverse',
 
1501
            PackagePublishingPocket.UPDATES)
 
1502
        sources_list = get_sources_list_for_building(build,
 
1503
            build.distro_arch_series, build.source_package_release.name)
 
1504
 
 
1505
        self.assertThat(
 
1506
            "\n".join(sources_list),
 
1507
            DocTestMatches(
 
1508
                ".../ubuntutest breezy-autotest main\n"
 
1509
                ".../depdistro series11 main universe\n"
 
1510
                ".../depdistro series11-security main universe\n"
 
1511
                ".../depdistro2 series21 "
 
1512
                    "main restricted universe multiverse\n"
 
1513
                ".../depdistro2 series21-security "
 
1514
                    "main restricted universe multiverse\n"
 
1515
                ".../depdistro2 series21-updates "
 
1516
                   "main restricted universe multiverse\n"
 
1517
                ".../depdistro4 series12 main restricted "
 
1518
                    "universe multiverse\n"
 
1519
                ".../depdistro4 series12-security main "
 
1520
                    "restricted universe multiverse\n"
 
1521
                ".../depdistro4 series12-updates "
 
1522
                    "main restricted universe multiverse\n"
 
1523
                , doctest.ELLIPSIS))
 
1524
 
 
1525
 
1432
1526
class TestComponents(TestCaseWithFactory):
1433
1527
 
1434
1528
    layer = DatabaseFunctionalLayer