launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #00058
[Merge] lp:~jelmer/launchpad/bug113563 into lp:launchpad/devel
You have been requested to review the proposed merge of lp:~jelmer/launchpad/bug113563 into lp:launchpad/devel.
This fixes an old tech-debt bug (bug 113563) about having a IDistribution.getSeriesByStatus() method.
--
https://code.launchpad.net/~jelmer/launchpad/bug113563/+merge/23232
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jelmer/launchpad/bug113563 into lp:launchpad/devel.
=== modified file 'lib/lp/registry/interfaces/distribution.py'
--- lib/lp/registry/interfaces/distribution.py 2010-04-09 00:21:24 +0000
+++ lib/lp/registry/interfaces/distribution.py 2010-04-13 14:33:50 +0000
@@ -371,6 +371,13 @@
"""Return a (distroseries,pocket) tuple which is the given textual
distroseriesname in this distribution."""
+ def getSeriesByStatus(status):
+ """Query context distribution for distroseries with a given status.
+
+ :param status: Series status to look for
+ :return: list of `IDistroSeries`
+ """
+
def getSourcePackageCaches(archive=None):
"""The set of all source package info caches for this distribution.
=== modified file 'lib/lp/registry/model/distribution.py'
--- lib/lp/registry/model/distribution.py 2010-04-13 13:38:41 +0000
+++ lib/lp/registry/model/distribution.py 2010-04-13 14:33:50 +0000
@@ -766,6 +766,10 @@
raise NotFoundError(distroseries_name)
+ def getSeriesByStatus(self, status):
+ """See `IDistribution`."""
+ return self.getSeries().find(status=status)
+
def getFileByName(self, filename, archive=None, source=True, binary=True):
"""See `IDistribution`."""
assert (source or binary), "searching in an explicitly empty " \
=== modified file 'lib/lp/registry/tests/test_distribution.py'
--- lib/lp/registry/tests/test_distribution.py 2009-12-13 11:55:40 +0000
+++ lib/lp/registry/tests/test_distribution.py 2010-04-13 14:33:50 +0000
@@ -14,6 +14,7 @@
from lp.soyuz.interfaces.distributionsourcepackagerelease import (
IDistributionSourcePackageRelease)
from lp.registry.interfaces.series import SeriesStatus
+from lp.testing import TestCaseWithFactory
class TestDistributionCurrentSourceReleases(
@@ -74,6 +75,22 @@
self.assertTrue(series is distribution._cached_series)
+class SeriesByStatusTests(TestCaseWithFactory):
+ """Test IDistribution.getSeriesByStatus().
+ """
+
+ def test_get_none(self):
+ distro = self.factory.makeDistribution()
+ self.assertEquals([], distro.getSeriesByStatus(SeriesStatus.FROZEN))
+
+ def test_get_current(self):
+ distro = self.factory.makeDistribution()
+ series = self.factory.makeDistroSeries(distribution=distro,
+ status=SeriesStatus.CURRENT)
+ self.assertEquals([series],
+ distro.getSeriesByStatus(SeriesStatus.CURRENT))
+
+
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestDistributionCurrentSourceReleases))
=== modified file 'lib/lp/soyuz/scripts/ftpmaster.py'
--- lib/lp/soyuz/scripts/ftpmaster.py 2010-02-15 12:59:55 +0000
+++ lib/lp/soyuz/scripts/ftpmaster.py 2010-04-13 14:33:50 +0000
@@ -1036,23 +1036,6 @@
raise LaunchpadScriptFailure(
"Action does not accept defined suite.")
- # XXX cprov 2007-04-20 bug=113563.: Should be implemented in
- # IDistribution.
- def getSeriesByStatus(self, status):
- """Query context distribution for a distroseries in a given status.
-
- I may raise LaunchpadScriptError if no suitable distroseries in a
- given status was found.
- """
- # XXX sabdfl 2007-05-27: Isn't this a bit risky, if there are
- # multiple series with the desired status?
- for series in self.location.distribution.series:
- if series.status == status:
- return series
- raise NotFoundError(
- "Could not find a %s distroseries in %s"
- % (status.name, self.location.distribution.name))
-
@property
def current(self):
"""Return the name of the CURRENT distroseries.
@@ -1063,12 +1046,12 @@
command-line or if not CURRENT distroseries was found.
"""
self.checkNoSuiteDefined()
- try:
- series = self.getSeriesByStatus(SeriesStatus.CURRENT)
- except NotFoundError, err:
- raise LaunchpadScriptFailure(err)
+ series = self.location.distribution.getSeriesByStatus(
+ SeriesStatus.CURRENT)
+ if not series:
+ raise LaunchpadScriptFailure("No CURRENT series.")
- return series.name
+ return series[0].name
@property
def development(self):
@@ -1090,17 +1073,14 @@
wanted_status = (SeriesStatus.DEVELOPMENT,
SeriesStatus.FROZEN)
for status in wanted_status:
- try:
- series = self.getSeriesByStatus(status)
- except NotFoundError:
- pass
-
- if series is None:
+ series = self.location.distribution.getSeriesByStatus(status)
+ if series.count() > 0:
+ break
+ else:
raise LaunchpadScriptFailure(
'There is no DEVELOPMENT distroseries for %s' %
self.location.distribution.name)
-
- return series.name
+ return series[0].name
@property
def supported(self):