← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/fix-bugalsoaffects-dsp-picker into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/fix-bugalsoaffects-dsp-picker into lp:launchpad.

Commit message:
Fix OOPS on BugTask:+distrotask when using the new package picker and the bug already has a DSP task.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1625771 in Launchpad itself: "OOPS when trying to pick a distrotask"
  https://bugs.launchpad.net/launchpad/+bug/1625771

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/fix-bugalsoaffects-dsp-picker/+merge/306295

Fix OOPS on BugTask:+distrotask when using the new package picker and the bug already has a DSP task.

Such a weird page.  This hits it over the head somewhat and avoids the problem, since we know exactly what we want to end up as the initial value of this field.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/fix-bugalsoaffects-dsp-picker into lp:launchpad.
=== modified file 'lib/lp/bugs/browser/bugalsoaffects.py'
--- lib/lp/bugs/browser/bugalsoaffects.py	2016-06-10 22:06:13 +0000
+++ lib/lp/bugs/browser/bugalsoaffects.py	2016-09-20 23:15:54 +0000
@@ -469,8 +469,12 @@
         for bugtask in IBug(self.context).bugtasks:
             if (IDistributionSourcePackage.providedBy(bugtask.target) and
                 (not self.widgets['sourcepackagename'].hasInput())):
+                # Set the rendered value to the raw name string rather than
+                # the SPN object.  The widget won't have its distribution
+                # set up in order to be able to look up the SPN, and even if
+                # it did it might not correspond to a valid DSP.
                 self.widgets['sourcepackagename'].setRenderedValue(
-                    bugtask.sourcepackagename)
+                    bugtask.sourcepackagename.name)
                 break
         return super(DistroBugTaskCreationStep, self).render()
 

=== modified file 'lib/lp/bugs/browser/tests/test_bugalsoaffects.py'
--- lib/lp/bugs/browser/tests/test_bugalsoaffects.py	2016-07-27 17:19:20 +0000
+++ lib/lp/bugs/browser/tests/test_bugalsoaffects.py	2016-09-20 23:15:54 +0000
@@ -8,7 +8,10 @@
 from lp.services.features.testing import FeatureFixture
 from lp.services.webapp import canonical_url
 from lp.soyuz.enums import PackagePublishingStatus
-from lp.testing import TestCaseWithFactory
+from lp.testing import (
+    person_logged_in,
+    TestCaseWithFactory,
+    )
 from lp.testing.layers import DatabaseFunctionalLayer
 from lp.testing.pages import get_feedback_messages
 
@@ -33,8 +36,11 @@
         bug = self.factory.makeBug()
         distroseries = self.factory.makeDistroSeries(
             distribution=self.distribution)
-        dsp = self.factory.makeDSPCache(distroseries=distroseries)
-        spn = dsp.sourcepackagename
+        dsp1 = self.factory.makeDSPCache(distroseries=distroseries)
+        with person_logged_in(bug.owner):
+            bug.addTask(bug.owner, dsp1)
+        dsp2 = self.factory.makeDSPCache(distroseries=distroseries)
+        spn = dsp2.sourcepackagename
         browser = self.openBugPage(bug)
         browser.getLink(url='+distrotask').click()
         browser.getControl('Distribution').value = [self.distribution.name]
@@ -48,13 +54,16 @@
         bug = self.factory.makeBug()
         distroseries = self.factory.makeDistroSeries(
             distribution=self.distribution)
-        dsp = self.factory.makeDSPCache(
+        dsp1 = self.factory.makeDSPCache(distroseries=distroseries)
+        with person_logged_in(bug.owner):
+            bug.addTask(bug.owner, dsp1)
+        dsp2 = self.factory.makeDSPCache(
             distroseries=distroseries, sourcepackagename='snarf')
         with FeatureFixture({u"disclosure.dsp_picker.enabled": u"on"}):
             browser = self.openBugPage(bug)
             browser.getLink(url='+distrotask').click()
             browser.getControl('Distribution').value = [self.distribution.name]
-            browser.getControl('Source Package Name').value = dsp.name
+            browser.getControl('Source Package Name').value = dsp2.name
             browser.getControl('Continue').click()
         self.assertEqual([], get_feedback_messages(browser.contents))
 


Follow ups