← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~rvb/launchpad/init-distroseries-publisher-862247 into lp:launchpad

 

Raphaël Victor Badin has proposed merging lp:~rvb/launchpad/init-distroseries-publisher-862247 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #862247 in Launchpad itself: "Initializing a distroseries should not be possible without a publisher config"
  https://bugs.launchpad.net/launchpad/+bug/862247

For more details, see:
https://code.launchpad.net/~rvb/launchpad/init-distroseries-publisher-862247/+merge/77684

This branch adds a check to the initialization code so that an error is raised if one tries to initialize a series without a publisher config is set up.

= Tests =

./bin/test -vvc test_initialize_distroseries test_derive_no_publisher_config

= QA =

Try initializing a series which has no publisher set up (e.g. baltix).  The error should be about the series not having a publisher set up.
-- 
https://code.launchpad.net/~rvb/launchpad/init-distroseries-publisher-862247/+merge/77684
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/launchpad/init-distroseries-publisher-862247 into lp:launchpad.
=== modified file 'database/schema/security.cfg'
--- database/schema/security.cfg	2011-09-25 21:44:40 +0000
+++ database/schema/security.cfg	2011-09-30 10:39:36 +0000
@@ -990,9 +990,10 @@
 public.packageuploadbuild                       = SELECT
 public.packaging                                = SELECT, INSERT
 public.person                                   = SELECT
-public.processor                                = SELECT
 public.pocketchroot                             = SELECT
+public.processor                                = SELECT
 public.processorfamily                          = SELECT
+public.publisherconfig                          = SELECT
 public.section                                  = SELECT
 public.sectionselection                         = SELECT, INSERT
 public.sourcepackageformatselection             = SELECT, INSERT

=== modified file 'lib/lp/soyuz/scripts/initialize_distroseries.py'
--- lib/lp/soyuz/scripts/initialize_distroseries.py	2011-09-12 14:42:36 +0000
+++ lib/lp/soyuz/scripts/initialize_distroseries.py	2011-09-30 10:39:36 +0000
@@ -18,6 +18,7 @@
 from canonical.launchpad.helpers import ensure_unicode
 from canonical.launchpad.interfaces.lpstorm import IMasterStore
 from lp.app.errors import NotFoundError
+from lp.archivepublisher.interfaces.publisherconfig import IPublisherConfigSet
 from lp.buildmaster.enums import BuildStatus
 from lp.registry.interfaces.distroseriesparent import IDistroSeriesParentSet
 from lp.registry.interfaces.pocket import PackagePublishingPocket
@@ -147,6 +148,7 @@
                 ("Series {child.name} has already been initialised"
                  ".").format(
                     child=self.distroseries))
+        self._checkPublisherConfig()
         if (self.distroseries.distribution.has_published_sources and
             self.distroseries.previous_series is None):
             raise InitializationError(
@@ -160,6 +162,19 @@
             self._checkQueue(parent)
         self._checkSeries()
 
+    def _checkPublisherConfig(self):
+        """A series cannot be initialized if it has no publisher config
+        set up.
+        """
+        publisherconfigset = getUtility(IPublisherConfigSet)
+        config = publisherconfigset.getByDistribution(
+            self.distroseries.distribution)
+        if config is None:
+            raise InitializationError(
+                ("Series {child.name} has no publisher config set up"
+                 ".").format(
+                    child=self.distroseries))
+
     def _checkParents(self):
         """If self.first_derivation, the parents list cannot be empty."""
         if self.first_derivation:

=== modified file 'lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py'
--- lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py	2011-09-12 14:42:36 +0000
+++ lib/lp/soyuz/scripts/tests/test_initialize_distroseries.py	2011-09-30 10:39:36 +0000
@@ -17,6 +17,7 @@
 from canonical.config import config
 from canonical.launchpad.interfaces.lpstorm import IStore
 from canonical.testing.layers import LaunchpadZopelessLayer
+from lp.archivepublisher.interfaces.publisherconfig import IPublisherConfigSet
 from lp.buildmaster.enums import BuildStatus
 from lp.registry.interfaces.distroseriesdifference import (
     IDistroSeriesDifferenceSource,
@@ -128,6 +129,10 @@
         if child is None:
             child = self.factory.makeDistroSeries(
                 distribution=distribution, previous_series=previous_series)
+        publisherconfigset = getUtility(IPublisherConfigSet)
+        pub_config = publisherconfigset.getByDistribution(child.distribution)
+        if pub_config is None:
+            self.factory.makePublisherConfig(distribution=child.distribution)
         ids = InitializeDistroSeries(
             child, [parent.id for parent in parents], arches, packagesets,
             rebuild, overlays, overlay_pockets, overlay_components)
@@ -1149,6 +1154,18 @@
              "and a parent was not explicitly specified."),
             ids.check)
 
+    def test_derive_no_publisher_config(self):
+        # Initializing a series without a publisher config
+        # triggers an error.
+        distribution = self.factory.makeDistribution(no_pubconf=True)
+        child = self.factory.makeDistroSeries(
+            distribution=distribution, name='myseries')
+        ids = InitializeDistroSeries(child, [])
+        self.assertRaisesWithContent(
+            InitializationError,
+            "Series myseries has no publisher config set up.",
+            ids.check)
+
     def createDistroSeriesWithPublication(self, distribution=None):
         # Create a distroseries with a publication in the DEBUG archive.
         distroseries = self.factory.makeDistroSeries(