launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #24702
[Merge] ~cjwatson/launchpad:remove-distroseries-getPublishedSources into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:remove-distroseries-getPublishedSources into launchpad:master.
Commit message:
Remove DistroSeries.getPublishedSources
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/383707
It has been deprecated since 2011. I removed the small number of remaining uses of it.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:remove-distroseries-getPublishedSources into launchpad:master.
diff --git a/lib/lp/archiveuploader/nascentuploadfile.py b/lib/lp/archiveuploader/nascentuploadfile.py
index 0791141..d69f25d 100644
--- a/lib/lp/archiveuploader/nascentuploadfile.py
+++ b/lib/lp/archiveuploader/nascentuploadfile.py
@@ -63,6 +63,7 @@ from lp.soyuz.enums import (
from lp.soyuz.interfaces.binarypackagebuild import IBinaryPackageBuildSet
from lp.soyuz.interfaces.binarypackagename import IBinaryPackageNameSet
from lp.soyuz.interfaces.component import IComponentSet
+from lp.soyuz.interfaces.publishing import active_publishing_status
from lp.soyuz.interfaces.section import ISectionSet
from lp.soyuz.model.files import SourceFileMixin
@@ -786,9 +787,10 @@ class BaseBinaryUploadFile(PackageUploadFile):
assert self.source_name is not None
assert self.source_version is not None
distroseries = self.policy.distroseries
- spphs = distroseries.getPublishedSources(
- self.source_name, version=self.source_version,
- include_pending=True, archive=self.policy.archive)
+ spphs = self.policy.archive.getPublishedSources(
+ name=self.source_name, version=self.source_version,
+ status=active_publishing_status, distroseries=distroseries,
+ exact_match=True)
# Workaround storm bug in EmptyResultSet.
spphs = list(spphs[:1])
try:
diff --git a/lib/lp/registry/browser/distributionsourcepackage.py b/lib/lp/registry/browser/distributionsourcepackage.py
index 72f2cd3..55fabee 100644
--- a/lib/lp/registry/browser/distributionsourcepackage.py
+++ b/lib/lp/registry/browser/distributionsourcepackage.py
@@ -1,4 +1,4 @@
-# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2020 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
__metaclass__ = type
@@ -357,8 +357,8 @@ class DistributionSourcePackageView(DistributionSourcePackageBaseView,
# three archives.
archive_set = getUtility(IArchiveSet)
publications = archive_set.getPublicationsInArchives(
- self.context.sourcepackagename, top_three_archives,
- self.context.distribution)
+ self.context.sourcepackagename, top_three_archives,
+ distribution=self.context.distribution)
# Collect the publishings for each archive
archive_publishings = {}
@@ -429,8 +429,10 @@ class DistributionSourcePackageView(DistributionSourcePackageBaseView,
:param sourcepackage: ISourcePackage
"""
- publications = sourcepackage.distroseries.getPublishedSources(
- sourcepackage.sourcepackagename)
+ publications = getUtility(IArchiveSet).getPublicationsInArchives(
+ sourcepackage.sourcepackagename,
+ sourcepackage.distribution.all_distro_archives,
+ distroseries=sourcepackage.distroseries)
pocket_dict = {}
for pub in shortlist(publications):
version = pub.source_package_version
diff --git a/lib/lp/registry/doc/distroseries.txt b/lib/lp/registry/doc/distroseries.txt
index c637ab5..f19f972 100644
--- a/lib/lp/registry/doc/distroseries.txt
+++ b/lib/lp/registry/doc/distroseries.txt
@@ -131,41 +131,8 @@ and version values consistently.
Warty (4.10)
-Published sources
------------------
-
-DistroSeries.getPublishedSources:
-
- >>> from lp.registry.model.distroseries import DistroSeries
- >>> from lp.registry.model.sourcepackagename import SourcePackageName
- >>> warty2 = DistroSeries.get(1)
-
-Passing a ISourcePackageName as argument:
-
- >>> prs = warty2.getPublishedSources(
- ... SourcePackageName.byName('mozilla-firefox'))
- >>> print prs.count()
- 1
- >>> print prs[0].sourcepackagerelease.sourcepackagename.name
- mozilla-firefox
-
-Passing a string name:
-
- >>> print warty2.getPublishedSources('mozilla-firefox').count()
- 1
-
-Including pending publication records in the result:
-
- >>> print warty2.getPublishedSources('mozilla-firefox',
- ... include_pending=True).count()
- 2
-
-Not found as empty list:
-
- >>> print warty2.getPublishedSources('nosuchpackage').count()
- 0
-
-See distroseries-publishing-lookups.txt for more information.
+canModifySuite
+--------------
canModifySuite method helps us to decide if an upload is allowed or not,
according to the distroseries status and the upload target pocket.
@@ -336,9 +303,13 @@ again" type set of assertions.
>>> humpy.previous_series = hoary
>>> ids = InitializeDistroSeries(humpy, [hoary.id])
>>> ids.initialize()
- >>> hoary.getPublishedSources('pmount').count()
+ >>> hoary.main_archive.getPublishedSources(
+ ... name='pmount', status=PackagePublishingStatus.PUBLISHED,
+ ... distroseries=hoary, exact_match=True).count()
1
- >>> humpy.getPublishedSources('pmount').count()
+ >>> humpy.main_archive.getPublishedSources(
+ ... name='pmount', status=PackagePublishingStatus.PUBLISHED,
+ ... distroseries=humpy, exact_match=True).count()
1
>>> hoary.main_archive.getAllPublishedBinaries(
... distroarchseries=hoary['i386'], name=u'pmount',
diff --git a/lib/lp/registry/interfaces/distroseries.py b/lib/lp/registry/interfaces/distroseries.py
index 2d84906..42704d0 100644
--- a/lib/lp/registry/interfaces/distroseries.py
+++ b/lib/lp/registry/interfaces/distroseries.py
@@ -1,4 +1,4 @@
-# Copyright 2009-2017 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2020 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Interfaces including and related to IDistroSeries."""
@@ -617,27 +617,6 @@ class IDistroSeriesPublic(
and the value is a `IDistributionSourcePackageRelease`.
"""
- def getPublishedSources(sourcepackage_or_name, pocket=None, version=None,
- include_pending=False, archive=None):
- """Return the SourcePackagePublishingHistory(s)
-
- Deprecated. Use IArchive.getPublishedSources instead.
-
- Given a ISourcePackageName or name.
-
- If pocket is not specified, we look in all pockets.
-
- If version is not specified, return packages with any version.
-
- If 'include_pending' is True, we return also the pending publication
- records, those packages that will get published in the next publisher
- run (it's only useful when we need to know if a given package is
- known during a publisher run, mostly in pre-upload checks)
-
- If 'archive' is not specified consider publication in the
- main_archive, otherwise respect the given value.
- """
-
def getAllPublishedSources():
"""Return all currently published sources for the distroseries.
diff --git a/lib/lp/registry/model/distroseries.py b/lib/lp/registry/model/distroseries.py
index a34eff1..9ae85f4 100644
--- a/lib/lp/registry/model/distroseries.py
+++ b/lib/lp/registry/model/distroseries.py
@@ -35,10 +35,7 @@ from storm.expr import (
SQL,
)
from storm.locals import JSON
-from storm.store import (
- EmptyResultSet,
- Store,
- )
+from storm.store import Store
from zope.component import getUtility
from zope.interface import implementer
@@ -77,14 +74,8 @@ from lp.registry.interfaces.pocket import (
pocketsuffix,
)
from lp.registry.interfaces.series import SeriesStatus
-from lp.registry.interfaces.sourcepackage import (
- ISourcePackage,
- ISourcePackageFactory,
- )
-from lp.registry.interfaces.sourcepackagename import (
- ISourcePackageName,
- ISourcePackageNameSet,
- )
+from lp.registry.interfaces.sourcepackage import ISourcePackageFactory
+from lp.registry.interfaces.sourcepackagename import ISourcePackageName
from lp.registry.model.milestone import (
HasMilestonesMixin,
Milestone,
@@ -1006,55 +997,6 @@ class DistroSeries(SQLBase, BugTargetBase, HasSpecificationsMixin,
return [SourcePackage(sourcepackagename=spn, distroseries=self) for
spn in result]
- def getPublishedSources(self, sourcepackage_or_name, version=None,
- pocket=None, include_pending=False,
- archive=None):
- """See `IDistroSeries`."""
- # Deprecated. Use IArchive.getPublishedSources instead.
-
- # XXX cprov 2006-02-13 bug 31317:
- # We need a standard and easy API, no need
- # to support multiple type arguments, only string name should be
- # the best choice in here, the call site will be clearer.
- if ISourcePackage.providedBy(sourcepackage_or_name):
- spn = sourcepackage_or_name.name
- elif ISourcePackageName.providedBy(sourcepackage_or_name):
- spn = sourcepackage_or_name
- else:
- spns = getUtility(ISourcePackageNameSet)
- spn = spns.queryByName(sourcepackage_or_name)
- if spn is None:
- return EmptyResultSet()
-
- queries = ["""
- sourcepackagerelease=sourcepackagerelease.id AND
- sourcepackagepublishinghistory.sourcepackagename=%s AND
- distroseries=%s
- """ % sqlvalues(spn.id, self.id)]
-
- if pocket is not None:
- queries.append("pocket=%s" % sqlvalues(pocket.value))
-
- if version is not None:
- queries.append("version=%s" % sqlvalues(version))
-
- if include_pending:
- queries.append("status in (%s, %s)" % sqlvalues(
- PackagePublishingStatus.PUBLISHED,
- PackagePublishingStatus.PENDING))
- else:
- queries.append("status=%s" % sqlvalues(
- PackagePublishingStatus.PUBLISHED))
-
- archives = self.distribution.getArchiveIDList(archive)
- queries.append("archive IN %s" % sqlvalues(archives))
-
- published = SourcePackagePublishingHistory.select(
- " AND ".join(queries), clauseTables=['SourcePackageRelease'],
- orderBy=['-id'])
-
- return published
-
def isUnstable(self):
"""See `IDistroSeries`."""
return self.status in ACTIVE_UNRELEASED_STATUSES
diff --git a/lib/lp/registry/model/distroseriesdifference.py b/lib/lp/registry/model/distroseriesdifference.py
index 0672584..e1d96f5 100644
--- a/lib/lp/registry/model/distroseriesdifference.py
+++ b/lib/lp/registry/model/distroseriesdifference.py
@@ -1,4 +1,4 @@
-# Copyright 2010-2016 Canonical Ltd. This software is licensed under the
+# Copyright 2010-2020 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Database classes for a difference between two distribution series."""
@@ -125,9 +125,8 @@ def most_recent_publications(dsds, in_parent, statuses, match_version=False):
DistroSeriesDifference.source_package_name_id,
SourcePackagePublishingHistory,
)
- # DistroSeries.getPublishedSources() matches on MAIN_ARCHIVE_PURPOSES,
- # but we are only ever going to be interested in the distribution's
- # main (PRIMARY) archive.
+ # We are only ever going to be interested in the distribution's main
+ # (PRIMARY) archive.
archive_subselect = Select(
Archive.id, tables=[Archive, DistroSeries],
where=And(
@@ -564,8 +563,10 @@ class DistroSeriesDifference(StormBase):
if for_parent:
distro_series = self.parent_series
- pubs = distro_series.getPublishedSources(
- self.source_package_name, include_pending=True)
+ pubs = distro_series.main_archive.getPublishedSources(
+ name=self.source_package_name.name,
+ status=active_publishing_status, distroseries=distro_series,
+ exact_match=True, order_by_date=True)
# The most recent published source is the first one.
try:
diff --git a/lib/lp/soyuz/doc/distroseries-publishing-lookups.txt b/lib/lp/soyuz/doc/distroseries-publishing-lookups.txt
deleted file mode 100644
index f10ebc1..0000000
--- a/lib/lp/soyuz/doc/distroseries-publishing-lookups.txt
+++ /dev/null
@@ -1,116 +0,0 @@
-DistroSeries source publishing lookups
-======================================
-
-IDistroSeries allows source publishing lookup via the
-getPublishedSources method which returns a shortlist of
-ISourcePackagePublishingHistory ordered by descending ID.
-
-In order to test its behaviour 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
-
-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
-
diff --git a/lib/lp/soyuz/interfaces/archive.py b/lib/lp/soyuz/interfaces/archive.py
index 209d1a0..6347193 100644
--- a/lib/lp/soyuz/interfaces/archive.py
+++ b/lib/lp/soyuz/interfaces/archive.py
@@ -1,4 +1,4 @@
-# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2020 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Archive interfaces."""
@@ -2452,7 +2452,7 @@ class IArchiveSet(Interface):
"""Return a result set containing all private PPAs."""
def getPublicationsInArchives(source_package_name, archive_list,
- distribution):
+ distribution=None, distroseries=None):
"""Return a result set of publishing records for the source package.
:param source_package_name: an `ISourcePackageName` identifying the
@@ -2461,6 +2461,8 @@ class IArchiveSet(Interface):
restrict the search.
:param distribution: the distribution by which the results will
be limited.
+ :param distroseries: the distroseries by which the results will
+ be limited.
:return: a resultset of the `ISourcePackagePublishingHistory` objects
that are currently published in the given archives.
"""
diff --git a/lib/lp/soyuz/model/archive.py b/lib/lp/soyuz/model/archive.py
index 6e430ec..b5a4ce7 100644
--- a/lib/lp/soyuz/model/archive.py
+++ b/lib/lp/soyuz/model/archive.py
@@ -1,4 +1,4 @@
-# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2020 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Database class for table Archive."""
@@ -2939,7 +2939,7 @@ class ArchiveSet:
return query.order_by(Archive.name)
def getPublicationsInArchives(self, source_package_name, archive_list,
- distribution):
+ distribution=None, distroseries=None):
"""See `IArchiveSet`."""
archive_ids = [archive.id for archive in archive_list]
@@ -2949,17 +2949,23 @@ class ArchiveSet:
# given list of archives. Note: importing DistroSeries here to
# avoid circular imports.
from lp.registry.model.distroseries import DistroSeries
- results = store.find(
- SourcePackagePublishingHistory,
+ clauses = [
Archive.id.is_in(archive_ids),
SourcePackagePublishingHistory.archive == Archive.id,
(SourcePackagePublishingHistory.status ==
PackagePublishingStatus.PUBLISHED),
SourcePackagePublishingHistory.sourcepackagename ==
source_package_name,
- SourcePackagePublishingHistory.distroseries == DistroSeries.id,
- DistroSeries.distribution == distribution,
- )
+ ]
+ if distribution is not None:
+ clauses.extend([
+ SourcePackagePublishingHistory.distroseries == DistroSeries.id,
+ DistroSeries.distribution == distribution,
+ ])
+ if distroseries is not None:
+ clauses.append(
+ SourcePackagePublishingHistory.distroseries == distroseries)
+ results = store.find(SourcePackagePublishingHistory, *clauses)
return results.order_by(SourcePackagePublishingHistory.id)
diff --git a/lib/lp/soyuz/model/distroseriesdifferencejob.py b/lib/lp/soyuz/model/distroseriesdifferencejob.py
index 2e6897e..5f86fc2 100644
--- a/lib/lp/soyuz/model/distroseriesdifferencejob.py
+++ b/lib/lp/soyuz/model/distroseriesdifferencejob.py
@@ -1,4 +1,4 @@
-# Copyright 2011-2013 Canonical Ltd. This software is licensed under the
+# Copyright 2011-2020 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Job class to request generation or update of `DistroSeriesDifference`s."""
@@ -147,8 +147,9 @@ def may_require_job(derived_series, sourcepackagename, parent_series):
def has_package(distroseries, sourcepackagename):
"""Does `distroseries` have the given source package?"""
- return not distroseries.getPublishedSources(
- sourcepackagename, include_pending=True).is_empty()
+ return not distroseries.main_archive.getPublishedSources(
+ name=sourcepackagename.name, status=active_publishing_status,
+ distroseries=distroseries, exact_match=True).is_empty()
@implementer(IDistroSeriesDifferenceJob)
diff --git a/lib/lp/soyuz/scripts/tests/test_gina.py b/lib/lp/soyuz/scripts/tests/test_gina.py
index 9574c38..bf5f2b8 100644
--- a/lib/lp/soyuz/scripts/tests/test_gina.py
+++ b/lib/lp/soyuz/scripts/tests/test_gina.py
@@ -613,7 +613,9 @@ class TestRunner(TestCaseWithFactory):
importer_handler)
return [
p.source_package_version
- for p in series.getPublishedSources('archive-copier')]
+ for p in series.main_archive.getPublishedSources(
+ name='archive-copier', distroseries=series,
+ exact_match=True)]
# Our test archive has archive-copier 0.1.5 and 0.3.6 With
# soyuz.gina.skip_source_versions set to
diff --git a/lib/lp/soyuz/tests/test_archive.py b/lib/lp/soyuz/tests/test_archive.py
index 8660e70..0381df4 100644
--- a/lib/lp/soyuz/tests/test_archive.py
+++ b/lib/lp/soyuz/tests/test_archive.py
@@ -1,4 +1,4 @@
-# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
+# Copyright 2009-2020 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Test Archive features."""
@@ -172,15 +172,17 @@ class TestGetPublicationsInArchive(TestCaseWithFactory):
)
return archives, sourcepackagename
- def getPublications(self, sourcepackagename, archives, distribution):
+ def getPublications(self, sourcepackagename, archives, distribution=None,
+ distroseries=None):
return getUtility(IArchiveSet).getPublicationsInArchives(
- sourcepackagename, archives, distribution=distribution)
+ sourcepackagename, archives, distribution=distribution,
+ distroseries=distroseries)
def test_getPublications_returns_all_published_publications(self):
# Returns all currently published publications for archives
archives, sourcepackagename = self.makeArchivesWithPublications()
results = self.getPublications(
- sourcepackagename, archives, archives[0].distribution)
+ sourcepackagename, archives, distribution=archives[0].distribution)
self.assertEqual(3, results.count())
def test_getPublications_empty_list_of_archives(self):
@@ -188,7 +190,7 @@ class TestGetPublicationsInArchive(TestCaseWithFactory):
# resultset.
archives, sourcepackagename = self.makeArchivesWithPublications()
results = self.getPublications(
- sourcepackagename, [], archives[0].distribution)
+ sourcepackagename, [], distribution=archives[0].distribution)
self.assertEqual([], list(results))
def assertPublicationsFromArchives(self, publications, archives):
@@ -200,7 +202,8 @@ class TestGetPublicationsInArchive(TestCaseWithFactory):
# Returns only publications for the specified archives
archives, sourcepackagename = self.makeArchivesWithPublications()
results = self.getPublications(
- sourcepackagename, [archives[0]], archives[0].distribution)
+ sourcepackagename, [archives[0]],
+ distribution=archives[0].distribution)
self.assertPublicationsFromArchives(results, [archives[0]])
def test_getPublications_returns_only_published_publications(self):
@@ -211,7 +214,7 @@ class TestGetPublicationsInArchive(TestCaseWithFactory):
archive=archive, sourcepackagename=sourcepackagename,
status=PackagePublishingStatus.PENDING)
results = self.getPublications(
- sourcepackagename, [archive], archive.distribution)
+ sourcepackagename, [archive], distribution=archive.distribution)
self.assertEqual([], list(results))
def publishSourceInNewArchive(self, sourcepackagename):
@@ -236,6 +239,27 @@ class TestGetPublicationsInArchive(TestCaseWithFactory):
distribution=archive.distribution)
self.assertPublicationsFromArchives(results, [archive])
+ def test_getPublications_for_specific_distroseries(self):
+ # Results can be filtered for specific distroseries.
+ archives = self.makeArchivesForOneDistribution()
+ sourcepackagename = self.factory.makeSourcePackageName()
+ distroseries_list = [
+ self.factory.makeDistroSeries(
+ distribution=archives[0].distribution)
+ for _ in range(3)]
+ for archive in archives:
+ for distroseries in distroseries_list:
+ self.factory.makeSourcePackagePublishingHistory(
+ sourcepackagename=sourcepackagename,
+ distroseries=distroseries, archive=archive,
+ status=PackagePublishingStatus.PUBLISHED)
+ for distroseries in distroseries_list:
+ results = self.getPublications(
+ sourcepackagename, archives, distroseries=distroseries)
+ self.assertPublicationsFromArchives(results, archives)
+ for publication in results:
+ self.assertEqual(distroseries, publication.distroseries)
+
class TestArchiveRepositorySize(TestCaseWithFactory):