DistroSeries source publishing lookups ====================================== IDistroSeries allows source publishing lookup via getReleasedPackages method which returns a shortlist of ISourcePackagePublishingHistory ordered by descending ID. In order to test its behavior we will create a bunch of sample publishing records with different (status, pocket, archive) in ubuntu/breezy-autotest, which is empty: >>> from lp.registry.interfaces.distribution import IDistributionSet >>> from lp.registry.interfaces.person import IPersonSet >>> from lp.registry.interfaces.pocket import PackagePublishingPocket >>> ubuntu = getUtility(IDistributionSet)['ubuntu'] >>> breezy_autotest = ubuntu['breezy-autotest'] >>> cprov_archive = getUtility(IPersonSet).getByName('cprov').archive We will use a 'cnews' sourcepackage because it's not published yet in the distroseries we want to test, this will help to make the tests as clear as possible. >>> hoary = ubuntu['hoary'] >>> cnews_hoary = hoary.getSourcePackage('cnews') >>> sample_spr = cnews_hoary.currentrelease.sourcepackagerelease >>> from lp.soyuz.model.publishing import ( ... SourcePackagePublishingHistory) >>> SourcePackagePublishingHistory.selectBy( ... distroseries=breezy_autotest, ... sourcepackagerelease=sample_spr).count() 0 Create and collect several binary publishing records in a variety of states, pockets and archives: >>> from lp.soyuz.tests.soyuz import SoyuzTestHelper >>> soyuz_helper = SoyuzTestHelper() >>> sample_pub = soyuz_helper.createPublishingForDistroSeries( ... sample_spr, breezy_autotest) >>> [pub_main_release_pending, pub_main_release_published, ... pub_main_updates_pending, pub_main_proposed_published, ... pub_ppa_release_pending, pub_ppa_release_published, ... pub_ppa_updates_pending, pub_ppa_proposed_published] = sample_pub Looking for all PUBLISHED publications in main_archive and all pockets: >>> import operator >>> all_published_main_pubs = [ ... pub_main_proposed_published, ... pub_main_release_published, ... ] >>> all_published_main_pubs = sorted( ... all_published_main_pubs, key=operator.attrgetter('id'), ... reverse=True) >>> result = breezy_autotest.getPublishedSources('cnews') >>> soyuz_helper.checkPubList(all_published_main_pubs, result) True Looking for all PUBLISHED or PENDING publications in main_archive and all pockets. >>> all_main_pubs = [ ... pub_main_proposed_published, ... pub_main_updates_pending, ... pub_main_release_published, ... pub_main_release_pending, ... ] >>> all_main_pubs = sorted( ... all_main_pubs, key=operator.attrgetter('id'), reverse=True) >>> result = breezy_autotest.getPublishedSources( ... 'cnews', include_pending=True) >>> soyuz_helper.checkPubList(all_main_pubs, result) True Using 'pocket' filter: >>> updates_main_pubs = [ ... pub_main_updates_pending, ... ] >>> result = breezy_autotest.getPublishedSources( ... 'cnews', include_pending=True, ... pocket=PackagePublishingPocket.UPDATES) >>> soyuz_helper.checkPubList(updates_main_pubs, result) True Using 'exclude_pocket' filter, to exclude publications to RELEASE pocket: >>> non_release_main_pubs = [ ... pub_main_proposed_published, ... pub_main_updates_pending, ... ] >>> non_release_main_pubs = sorted( ... non_release_main_pubs, key=operator.attrgetter('id'), ... reverse=True) >>> result = breezy_autotest.getPublishedSources( ... 'cnews', include_pending=True, ... exclude_pocket=PackagePublishingPocket.RELEASE) >>> soyuz_helper.checkPubList(non_release_main_pubs, result) True Looking for all PUBLISHED or PENDING publications in cprov PPA and all pockets. >>> all_ppa_pubs = [ ... pub_ppa_proposed_published, ... pub_ppa_updates_pending, ... pub_ppa_release_published, ... pub_ppa_release_pending, ... ] >>> all_ppa_pubs = sorted( ... all_ppa_pubs, key=operator.attrgetter('id'), reverse=True) >>> result = breezy_autotest.getPublishedSources( ... 'cnews', include_pending=True, archive=cprov_archive) >>> soyuz_helper.checkPubList(all_ppa_pubs, result) True