← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~stevenk/launchpad/bugalsoaffects-packaging-no-series into lp:launchpad

 

Steve Kowalik has proposed merging lp:~stevenk/launchpad/bugalsoaffects-packaging-no-series into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #810727 in Launchpad itself: "None isn't acceptable as a value for Packaging.distroseries"
  https://bugs.launchpad.net/launchpad/+bug/810727

For more details, see:
https://code.launchpad.net/~stevenk/launchpad/bugalsoaffects-packaging-no-series/+merge/87309

Do not create packaging links in BugAlsoAffectsView if the distribution we get from the DSP task on the bugtask has no currentseries.
-- 
https://code.launchpad.net/~stevenk/launchpad/bugalsoaffects-packaging-no-series/+merge/87309
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/bugalsoaffects-packaging-no-series into lp:launchpad.
=== modified file 'lib/lp/bugs/browser/bugalsoaffects.py'
--- lib/lp/bugs/browser/bugalsoaffects.py	2012-01-01 02:58:52 +0000
+++ lib/lp/bugs/browser/bugalsoaffects.py	2012-01-03 00:32:24 +0000
@@ -663,12 +663,13 @@
         if data.get('add_packaging', False):
             # Create a packaging link so that Launchpad will suggest the
             # upstream project to the user.
-            packaging_util = getUtility(IPackagingUtil)
-            packaging_util.createPackaging(
-                productseries=data['product'].development_focus,
-                sourcepackagename=self.context.target.sourcepackagename,
-                distroseries=self.context.target.distribution.currentseries,
-                packaging=PackagingType.PRIME, owner=self.user)
+            series = self.context.target.distribution.currentseries
+            if series:
+                getUtility(IPackagingUtil).createPackaging(
+                    productseries=data['product'].development_focus,
+                    sourcepackagename=self.context.target.sourcepackagename,
+                    distroseries=series, packaging=PackagingType.PRIME,
+                    owner=self.user)
         return super(ProductBugTaskCreationStep, self).main_action(data)
 
     @property

=== modified file 'lib/lp/bugs/browser/tests/test_bugtask_adding.py'
--- lib/lp/bugs/browser/tests/test_bugtask_adding.py	2012-01-01 02:58:52 +0000
+++ lib/lp/bugs/browser/tests/test_bugtask_adding.py	2012-01-03 00:32:24 +0000
@@ -31,7 +31,7 @@
         self.sourcepackage = self.factory.makeSourcePackage(
             sourcepackagename=self.sourcepackagename,
             distroseries=self.ubuntu_series)
-        self.distrosourcepackage = self.factory.makeDistributionSourcePackage(
+        self.dsp = self.factory.makeDistributionSourcePackage(
             sourcepackagename=self.sourcepackagename, distribution=ubuntu)
         self.factory.makeSourcePackagePublishingHistory(
             sourcepackagename=self.sourcepackagename,
@@ -41,7 +41,7 @@
         self.user = self.factory.makePerson()
         login_person(self.user)
         self.bug_task = self.factory.makeBugTask(
-            target=self.distrosourcepackage, owner=self.user)
+            target=self.dsp, owner=self.user)
         self.bug = self.bug_task.bug
 
     def test_choose_product_when_packaging_does_not_exist(self):
@@ -160,3 +160,22 @@
             self.sourcepackagename, self.ubuntu_series,
             product.development_focus)
         self.assertTrue(has_packaging)
+
+    def test_register_project_create_upstream_bugtask_no_series(self):
+        # Adding a task that affects a product where the distribution has
+        # no series does not error.
+        dsp = self.factory.makeDistributionSourcePackage(
+            sourcepackagename=self.sourcepackagename)
+        self.bug_task = self.factory.makeBugTask(
+            target=dsp, owner=self.user)
+        form = {
+            'field.bug_url': 'http://bugs.foo.org/bugs/show_bug.cgi?id=8',
+            'field.name': 'fruit',
+            'field.displayname': 'Fruit',
+            'field.summary': 'The Fruit summary',
+            'field.add_packaging': 'on',
+            'field.actions.continue': 'Continue',
+            }
+        view = create_initialized_view(
+            self.bug_task, '+affects-new-product', form=form)
+        self.assertEqual([], view.errors)