Merge lp:~stevenk/launchpad/no-makebugtask-private into lp:launchpad

Proposed by Steve Kowalik on 2012-05-31
Status: Merged
Approved by: William Grant on 2012-05-31
Approved revision: no longer in the source branch.
Merged at revision: 15341
Proposed branch: lp:~stevenk/launchpad/no-makebugtask-private
Merge into: lp:launchpad
Diff against target: 100 lines (+8/-33)
2 files modified
lib/lp/soyuz/scripts/tests/test_queue.py (+7/-4)
lib/lp/testing/factory.py (+1/-29)
To merge this branch: bzr merge lp:~stevenk/launchpad/no-makebugtask-private
Reviewer Review Type Date Requested Status
William Grant code 2012-05-31 Approve on 2012-05-31
Review via email: mp+108096@code.launchpad.net

Commit Message

Rip out factory.makeBugTask(private=True)

Description of the Change

While working on the previous factory work with makeBranch(private=True), I noticed this pearl -- makeBugTask(private=True) which behaves *totally* different. There is only one callsite, so it can just create a USERDATA bug with the right task and the special code can die.

To post a comment you must log in.
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/soyuz/scripts/tests/test_queue.py'
2--- lib/lp/soyuz/scripts/tests/test_queue.py 2012-02-10 10:50:03 +0000
3+++ lib/lp/soyuz/scripts/tests/test_queue.py 2012-05-31 05:56:19 +0000
4@@ -28,6 +28,7 @@
5 BugTaskStatus,
6 IBugTaskSet,
7 )
8+from lp.registry.enums import InformationType
9 from lp.registry.interfaces.distribution import IDistributionSet
10 from lp.registry.interfaces.person import IPersonSet
11 from lp.registry.interfaces.pocket import PackagePublishingPocket
12@@ -1084,9 +1085,10 @@
13 # we're testing.
14 spr = self.factory.makeSourcePackageRelease(changelog_entry="blah")
15 archive_admin = self.factory.makePerson()
16- bug_task = self.factory.makeBugTask(
17- target=spr.sourcepackage, private=True)
18- bug = bug_task.bug
19+ bug = self.factory.makeBug(
20+ sourcepackagename=spr.sourcepackagename,
21+ distribution=spr.upload_distroseries.distribution,
22+ information_type=InformationType.USERDATA)
23 changes = StringIO(changes_file_template % bug.id)
24
25 with person_logged_in(archive_admin):
26@@ -1097,7 +1099,8 @@
27
28 # Verify it was closed.
29 with celebrity_logged_in("admin"):
30- self.assertEqual(bug_task.status, BugTaskStatus.FIXRELEASED)
31+ self.assertEqual(
32+ bug.default_bugtask.status, BugTaskStatus.FIXRELEASED)
33
34
35 class TestQueueToolInJail(TestQueueBase, TestCase):
36
37=== modified file 'lib/lp/testing/factory.py'
38--- lib/lp/testing/factory.py 2012-05-30 14:17:37 +0000
39+++ lib/lp/testing/factory.py 2012-05-31 05:56:19 +0000
40@@ -80,7 +80,6 @@
41 CreateBugParams,
42 IBugSet,
43 )
44-from lp.bugs.interfaces.bugtarget import ISeriesBugTarget
45 from lp.bugs.interfaces.bugtask import BugTaskStatus
46 from lp.bugs.interfaces.bugtracker import (
47 BugTrackerType,
48@@ -1725,8 +1724,7 @@
49
50 return bug
51
52- def makeBugTask(self, bug=None, target=None, owner=None, publish=True,
53- private=False):
54+ def makeBugTask(self, bug=None, target=None, owner=None, publish=True):
55 """Create and return a bug task.
56
57 If the bug is already targeted to the given target, the existing
58@@ -1740,8 +1738,6 @@
59 one will be created.
60 :param target: The `IBugTarget`, to which the bug will be
61 targeted to.
62- :param private: If a bug is not specified, the privacy state to use
63- when creating the bug for the bug task..
64 """
65
66 # Find and return the existing target if one exists.
67@@ -1792,33 +1788,9 @@
68 bug, prerequisite_target, publish=publish)
69 bug = prerequisite.bug
70
71- # Private (and soon all) bugs cannot affect multiple projects
72- # so we ensure that if a bug has not been specified and one is
73- # created, it is for the same pillar as that of the specified target.
74- result_bug_task = None
75- if bug is None and private:
76- product = distribution = sourcepackagename = None
77- pillar = target.pillar
78- if IProduct.providedBy(pillar):
79- product = pillar
80- elif IDistribution.providedBy(pillar):
81- distribution = pillar
82- if (IDistributionSourcePackage.providedBy(target)
83- or ISourcePackage.providedBy(target)):
84- sourcepackagename = target.sourcepackagename
85- bug = self.makeBug(
86- private=private, product=product, distribution=distribution,
87- sourcepackagename=sourcepackagename)
88- if not ISeriesBugTarget.providedBy(target):
89- result_bug_task = bug.default_bugtask
90- # We keep the existing behaviour for public bugs because
91- # test_bugtask_search breaks spectacularly otherwise. Almost all other
92- # tests pass.
93 if bug is None:
94 bug = self.makeBug()
95
96- if result_bug_task is not None:
97- return result_bug_task
98 if owner is None:
99 owner = self.makePerson()
100 return removeSecurityProxy(bug).addTask(owner, target)