Merge lp:~gmb/launchpad/fix-update-bug-watch into lp:launchpad

Proposed by Graham Binns
Status: Merged
Approved by: Gavin Panella
Approved revision: no longer in the source branch.
Merged at revision: 12069
Proposed branch: lp:~gmb/launchpad/fix-update-bug-watch
Merge into: lp:launchpad
Diff against target: 132 lines (+25/-22)
2 files modified
lib/lp/bugs/scripts/checkwatches/bugwatchupdater.py (+4/-9)
lib/lp/bugs/scripts/checkwatches/tests/test_bugwatchupdater.py (+21/-13)
To merge this branch: bzr merge lp:~gmb/launchpad/fix-update-bug-watch
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+43643@code.launchpad.net

Commit message

[r=allenap][ui=none][bug=568505,578714] Extraneous parameters have been removed from BugWatchUpdater.updateBugWatch().

Description of the change

This branch fixes the linked bugs by removing the extraneous parameters
from BugWatchUpdater.updateBugWatch(). I've also altered the tests for
that method.

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) wrote :

Nice!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/scripts/checkwatches/bugwatchupdater.py'
2--- lib/lp/bugs/scripts/checkwatches/bugwatchupdater.py 2010-10-26 15:47:24 +0000
3+++ lib/lp/bugs/scripts/checkwatches/bugwatchupdater.py 2010-12-14 13:56:16 +0000
4@@ -53,14 +53,9 @@
5 self.can_push_comments = parent.can_push_comments
6 self.can_back_link = parent.can_back_link
7
8- # XXX 2010-05-11 gmb bug=578714:
9- # The last three parameters on this method aren't needed and
10- # should be removed.
11 @commit_before
12 def updateBugWatch(self, new_remote_status, new_malone_status,
13- new_remote_importance, new_malone_importance,
14- can_import_comments=None, can_push_comments=None,
15- can_back_link=None):
16+ new_remote_importance, new_malone_importance):
17 """Update the BugWatch."""
18 with self.transaction:
19 if new_malone_status is not None:
20@@ -88,14 +83,14 @@
21 oops_id = None
22 if do_sync:
23 try:
24- if can_import_comments or self.can_import_comments:
25+ if self.can_import_comments:
26 error_status = (
27 BugWatchActivityStatus.COMMENT_IMPORT_FAILED)
28 self.importBugComments()
29- if can_push_comments or self.can_push_comments:
30+ if self.can_push_comments:
31 error_status = BugWatchActivityStatus.COMMENT_PUSH_FAILED
32 self.pushBugComments()
33- if can_back_link or self.can_back_link:
34+ if self.can_back_link:
35 error_status = BugWatchActivityStatus.BACKLINK_FAILED
36 self.linkLaunchpadBug()
37 except Exception, ex:
38
39=== modified file 'lib/lp/bugs/scripts/checkwatches/tests/test_bugwatchupdater.py'
40--- lib/lp/bugs/scripts/checkwatches/tests/test_bugwatchupdater.py 2010-10-04 19:50:45 +0000
41+++ lib/lp/bugs/scripts/checkwatches/tests/test_bugwatchupdater.py 2010-12-14 13:56:16 +0000
42@@ -25,7 +25,9 @@
43
44
45 def make_bug_watch_updater(checkwatches_master, bug_watch,
46- external_bugtracker, server_time=None):
47+ external_bugtracker, server_time=None,
48+ can_import_comments=False,
49+ can_push_comments=False, can_back_link=False):
50 """Helper function to create a BugWatchUpdater instance."""
51 if server_time is None:
52 server_time = datetime.now()
53@@ -33,10 +35,17 @@
54 remote_bug_updater = checkwatches_master.remote_bug_updater_factory(
55 checkwatches_master, external_bugtracker, bug_watch.remotebug,
56 [bug_watch.id], [], server_time)
57- return BugWatchUpdater(
58+
59+ bug_watch_updater = BugWatchUpdater(
60 remote_bug_updater, bug_watch,
61 remote_bug_updater.external_bugtracker)
62
63+ bug_watch_updater.can_import_comments = can_import_comments
64+ bug_watch_updater.can_push_comments = can_push_comments
65+ bug_watch_updater.can_back_link = can_back_link
66+
67+ return bug_watch_updater
68+
69
70 class BrokenCommentSyncingExternalBugTracker(TestExternalBugTracker):
71 """An ExternalBugTracker that can't sync comments."""
72@@ -100,8 +109,7 @@
73
74 bug_watch_updater.updateBugWatch(
75 'FIXED', BugTaskStatus.FIXRELEASED, 'LOW',
76- BugTaskImportance.LOW, can_import_comments=False,
77- can_push_comments=False, can_back_link=False)
78+ BugTaskImportance.LOW)
79
80 self.assertEqual('FIXED', self.bug_watch.remotestatus)
81 self.assertEqual(BugTaskStatus.FIXRELEASED, self.bug_task.status)
82@@ -119,12 +127,12 @@
83 external_bugtracker = BrokenCommentSyncingExternalBugTracker(
84 'http://example.com')
85 bug_watch_updater = make_bug_watch_updater(
86- self.checkwatches_master, self.bug_watch, external_bugtracker)
87+ self.checkwatches_master, self.bug_watch, external_bugtracker,
88+ can_import_comments=True)
89
90 bug_watch_updater.updateBugWatch(
91 'FIXED', BugTaskStatus.FIXRELEASED, 'LOW',
92- BugTaskImportance.LOW, can_import_comments=True,
93- can_push_comments=False, can_back_link=False)
94+ BugTaskImportance.LOW)
95
96 self._checkLastErrorAndMessage(
97 BugWatchActivityStatus.COMMENT_IMPORT_FAILED,
98@@ -136,15 +144,15 @@
99 external_bugtracker = BrokenCommentSyncingExternalBugTracker(
100 'http://example.com')
101 bug_watch_updater = make_bug_watch_updater(
102- self.checkwatches_master, self.bug_watch, external_bugtracker)
103+ self.checkwatches_master, self.bug_watch, external_bugtracker,
104+ can_push_comments=True)
105
106 self.factory.makeBugComment(
107 bug=self.bug_task.bug, bug_watch=self.bug_watch)
108
109 bug_watch_updater.updateBugWatch(
110 'FIXED', BugTaskStatus.FIXRELEASED, 'LOW',
111- BugTaskImportance.LOW, can_import_comments=False,
112- can_push_comments=True, can_back_link=False)
113+ BugTaskImportance.LOW)
114
115 self._checkLastErrorAndMessage(
116 BugWatchActivityStatus.COMMENT_PUSH_FAILED,
117@@ -156,12 +164,12 @@
118 external_bugtracker = BrokenCommentSyncingExternalBugTracker(
119 'http://example.com')
120 bug_watch_updater = make_bug_watch_updater(
121- self.checkwatches_master, self.bug_watch, external_bugtracker)
122+ self.checkwatches_master, self.bug_watch, external_bugtracker,
123+ can_back_link=True)
124
125 bug_watch_updater.updateBugWatch(
126 'FIXED', BugTaskStatus.FIXRELEASED, 'LOW',
127- BugTaskImportance.LOW, can_import_comments=False,
128- can_push_comments=False, can_back_link=True)
129+ BugTaskImportance.LOW)
130
131 self._checkLastErrorAndMessage(
132 BugWatchActivityStatus.BACKLINK_FAILED,