~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/archivepublisher/tests/test_publisher.py

[r=rvb][bug=905281] Skip publishing OBSOLETE and FUTURE series in
        PRIMARY and PARTNER archives.

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
from lp.soyuz.interfaces.archive import IArchiveSet
57
57
from lp.soyuz.tests.test_publishing import TestNativePublishingBase
58
58
from lp.testing import TestCaseWithFactory
 
59
from lp.testing.fakemethod import FakeMethod
59
60
from lp.testing.gpgkeys import gpgkeysdir
60
61
from lp.testing.keyserver import KeyServerTac
61
62
from lp.testing.layers import ZopelessDatabaseLayer
431
432
        # remove locally created dir
432
433
        shutil.rmtree(test_pool_dir)
433
434
 
 
435
    def testPublishingSkipsObsoleteFuturePrimarySeries(self):
 
436
        """Publisher skips OBSOLETE/FUTURE series in PRIMARY archives."""
 
437
        publisher = Publisher(
 
438
            self.logger, self.config, self.disk_pool,
 
439
            self.ubuntutest.main_archive)
 
440
        # Remove security proxy so that the publisher can call our fake
 
441
        # method.
 
442
        publisher.distro = removeSecurityProxy(publisher.distro)
 
443
 
 
444
        for status in (SeriesStatus.OBSOLETE, SeriesStatus.FUTURE):
 
445
            naked_breezy_autotest = publisher.distro['breezy-autotest']
 
446
            naked_breezy_autotest.status = status
 
447
            naked_breezy_autotest.publish = FakeMethod(result=set())
 
448
 
 
449
            publisher.A_publish(False)
 
450
 
 
451
            self.assertEqual(0, naked_breezy_autotest.publish.call_count)
 
452
 
 
453
    def testPublishingConsidersObsoleteFuturePPASeries(self):
 
454
        """Publisher does not skip OBSOLETE/FUTURE series in PPA archives."""
 
455
        ubuntu_team = getUtility(IPersonSet).getByName('ubuntu-team')
 
456
        test_archive = getUtility(IArchiveSet).new(
 
457
            distribution=self.ubuntutest, owner=ubuntu_team,
 
458
            purpose=ArchivePurpose.PPA)
 
459
        publisher = Publisher(
 
460
            self.logger, self.config, self.disk_pool, test_archive)
 
461
        # Remove security proxy so that the publisher can call our fake
 
462
        # method.
 
463
        publisher.distro = removeSecurityProxy(publisher.distro)
 
464
 
 
465
        for status in (SeriesStatus.OBSOLETE, SeriesStatus.FUTURE):
 
466
            naked_breezy_autotest = publisher.distro['breezy-autotest']
 
467
            naked_breezy_autotest.status = status
 
468
            naked_breezy_autotest.publish = FakeMethod(result=set())
 
469
 
 
470
            publisher.A_publish(False)
 
471
 
 
472
            self.assertEqual(1, naked_breezy_autotest.publish.call_count)
 
473
 
434
474
    def testPublisherBuilderFunctions(self):
435
475
        """Publisher can be initialized via provided helper function.
436
476