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

Proposed by Colin Watson
Status: Merged
Merged at revision: 18204
Proposed branch: lp:~cjwatson/launchpad/fix-bugalsoaffects-dsp-picker
Merge into: lp:launchpad
Diff against target: 65 lines (+19/-6)
2 files modified
lib/lp/bugs/browser/bugalsoaffects.py (+5/-1)
lib/lp/bugs/browser/tests/test_bugalsoaffects.py (+14/-5)
To merge this branch: bzr merge lp:~cjwatson/launchpad/fix-bugalsoaffects-dsp-picker
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+306295@code.launchpad.net

Commit message

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

Description of the change

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.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/browser/bugalsoaffects.py'
2--- lib/lp/bugs/browser/bugalsoaffects.py 2016-06-10 22:06:13 +0000
3+++ lib/lp/bugs/browser/bugalsoaffects.py 2016-09-20 23:15:54 +0000
4@@ -469,8 +469,12 @@
5 for bugtask in IBug(self.context).bugtasks:
6 if (IDistributionSourcePackage.providedBy(bugtask.target) and
7 (not self.widgets['sourcepackagename'].hasInput())):
8+ # Set the rendered value to the raw name string rather than
9+ # the SPN object. The widget won't have its distribution
10+ # set up in order to be able to look up the SPN, and even if
11+ # it did it might not correspond to a valid DSP.
12 self.widgets['sourcepackagename'].setRenderedValue(
13- bugtask.sourcepackagename)
14+ bugtask.sourcepackagename.name)
15 break
16 return super(DistroBugTaskCreationStep, self).render()
17
18
19=== modified file 'lib/lp/bugs/browser/tests/test_bugalsoaffects.py'
20--- lib/lp/bugs/browser/tests/test_bugalsoaffects.py 2016-07-27 17:19:20 +0000
21+++ lib/lp/bugs/browser/tests/test_bugalsoaffects.py 2016-09-20 23:15:54 +0000
22@@ -8,7 +8,10 @@
23 from lp.services.features.testing import FeatureFixture
24 from lp.services.webapp import canonical_url
25 from lp.soyuz.enums import PackagePublishingStatus
26-from lp.testing import TestCaseWithFactory
27+from lp.testing import (
28+ person_logged_in,
29+ TestCaseWithFactory,
30+ )
31 from lp.testing.layers import DatabaseFunctionalLayer
32 from lp.testing.pages import get_feedback_messages
33
34@@ -33,8 +36,11 @@
35 bug = self.factory.makeBug()
36 distroseries = self.factory.makeDistroSeries(
37 distribution=self.distribution)
38- dsp = self.factory.makeDSPCache(distroseries=distroseries)
39- spn = dsp.sourcepackagename
40+ dsp1 = self.factory.makeDSPCache(distroseries=distroseries)
41+ with person_logged_in(bug.owner):
42+ bug.addTask(bug.owner, dsp1)
43+ dsp2 = self.factory.makeDSPCache(distroseries=distroseries)
44+ spn = dsp2.sourcepackagename
45 browser = self.openBugPage(bug)
46 browser.getLink(url='+distrotask').click()
47 browser.getControl('Distribution').value = [self.distribution.name]
48@@ -48,13 +54,16 @@
49 bug = self.factory.makeBug()
50 distroseries = self.factory.makeDistroSeries(
51 distribution=self.distribution)
52- dsp = self.factory.makeDSPCache(
53+ dsp1 = self.factory.makeDSPCache(distroseries=distroseries)
54+ with person_logged_in(bug.owner):
55+ bug.addTask(bug.owner, dsp1)
56+ dsp2 = self.factory.makeDSPCache(
57 distroseries=distroseries, sourcepackagename='snarf')
58 with FeatureFixture({u"disclosure.dsp_picker.enabled": u"on"}):
59 browser = self.openBugPage(bug)
60 browser.getLink(url='+distrotask').click()
61 browser.getControl('Distribution').value = [self.distribution.name]
62- browser.getControl('Source Package Name').value = dsp.name
63+ browser.getControl('Source Package Name').value = dsp2.name
64 browser.getControl('Continue').click()
65 self.assertEqual([], get_feedback_messages(browser.contents))
66