Merge lp:~gmb/launchpad/bugzilla3.4-see-also-bug-419134 into lp:launchpad
- bugzilla3.4-see-also-bug-419134
- Merge into devel
Proposed by
Graham Binns
Status: | Merged |
---|---|
Approved by: | Graham Binns |
Approved revision: | not available |
Merged at revision: | not available |
Proposed branch: | lp:~gmb/launchpad/bugzilla3.4-see-also-bug-419134 |
Merge into: | lp:launchpad |
Diff against target: |
431 lines (+217/-1) 6 files modified
lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt (+32/-0) lib/lp/bugs/doc/externalbugtracker-bugzilla-lp-plugin.txt (+3/-0) lib/lp/bugs/externalbugtracker/bugzilla.py (+34/-1) lib/lp/bugs/tests/bugzilla-api-xmlrpc-transport.txt (+72/-0) lib/lp/bugs/tests/bugzilla-xmlrpc-transport.txt (+6/-0) lib/lp/bugs/tests/externalbugtracker.py (+70/-0) |
To merge this branch: | bzr merge lp:~gmb/launchpad/bugzilla3.4-see-also-bug-419134 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Guilherme Salgado (community) | rc | Abstain | |
Abel Deuring (community) | code | Approve | |
Review via email: mp+15404@code.launchpad.net |
Commit message
Launchpad can now update the see_also link for bugs on Bugzilla 3.4 bug trackers.
Description of the change
To post a comment you must log in.
Revision history for this message
Graham Binns (gmb) wrote : | # |
Revision history for this message
Abel Deuring (adeuring) wrote : | # |
Looks good. Please add an "XXX" to the doc string of getLaunchpadBug
review:
Approve
(code)
Revision history for this message
Guilherme Salgado (salgado) wrote : | # |
Not yet ready for RC as can't be easily QAed on staging.
review:
Abstain
(rc)
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt' | |||
2 | --- lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt 2009-08-28 12:54:58 +0000 | |||
3 | +++ lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt 2009-12-13 01:14:17 +0000 | |||
4 | @@ -145,6 +145,7 @@ | |||
5 | 145 | priority: P1 | 145 | priority: P1 |
6 | 146 | product: Marvin | 146 | product: Marvin |
7 | 147 | resolution: FIXED | 147 | resolution: FIXED |
8 | 148 | see_also: [] | ||
9 | 148 | severity: normal | 149 | severity: normal |
10 | 149 | status: RESOLVED | 150 | status: RESOLVED |
11 | 150 | summary: That bloody robot still exists. | 151 | summary: That bloody robot still exists. |
12 | @@ -161,6 +162,7 @@ | |||
13 | 161 | priority: P1 | 162 | priority: P1 |
14 | 162 | product: HeartOfGold | 163 | product: HeartOfGold |
15 | 163 | resolution: | 164 | resolution: |
16 | 165 | see_also: [] | ||
17 | 164 | severity: high | 166 | severity: high |
18 | 165 | status: NEW | 167 | status: NEW |
19 | 166 | summary: Collect unknown persons in docking bay 2. | 168 | summary: Collect unknown persons in docking bay 2. |
20 | @@ -198,6 +200,7 @@ | |||
21 | 198 | priority: P1 | 200 | priority: P1 |
22 | 199 | product: HeartOfGold | 201 | product: HeartOfGold |
23 | 200 | resolution: | 202 | resolution: |
24 | 203 | see_also: [] | ||
25 | 201 | severity: high | 204 | severity: high |
26 | 202 | status: NEW | 205 | status: NEW |
27 | 203 | summary: Collect unknown persons in docking bay 2. | 206 | summary: Collect unknown persons in docking bay 2. |
28 | @@ -560,3 +563,32 @@ | |||
29 | 560 | This is a new remote comment. | 563 | This is a new remote comment. |
30 | 561 | <BLANKLINE> | 564 | <BLANKLINE> |
31 | 562 | 565 | ||
32 | 566 | |||
33 | 567 | Linking a Launchpad bug to a remote bug | ||
34 | 568 | --------------------------------------- | ||
35 | 569 | |||
36 | 570 | BugzillaAPI implements the ISupportsBackLinking interface, which means | ||
37 | 571 | that it can be used to tell the remote bug tracker that a given remote | ||
38 | 572 | bug is linked to a Launchpad bug. | ||
39 | 573 | |||
40 | 574 | >>> from canonical.launchpad.interfaces import ISupportsBackLinking | ||
41 | 575 | >>> verifyObject(ISupportsBackLinking, bugzilla) | ||
42 | 576 | True | ||
43 | 577 | |||
44 | 578 | BugzillaAPI.setLaunchpadBugId() can be used to set the Launchpad bug ID | ||
45 | 579 | for a given bug. | ||
46 | 580 | |||
47 | 581 | setLaunchpadBugId() requires the user to be logged in. | ||
48 | 582 | |||
49 | 583 | >>> bugzilla.xmlrpc_transport.expireCookie( | ||
50 | 584 | ... bugzilla.xmlrpc_transport.auth_cookie) | ||
51 | 585 | |||
52 | 586 | >>> bugzilla.xmlrpc_transport.print_method_calls = True | ||
53 | 587 | >>> bugzilla.setLaunchpadBugId(bug_watch.remotebug, bug_watch.bug.id) | ||
54 | 588 | CALLED Bug.update_see_also({'add': | ||
55 | 589 | ['http://bugs.launchpad.dev/bugs...'], 'ids': [1]}) | ||
56 | 590 | |||
57 | 591 | BugzillaAPI.getLaunchpadBugId() will currently always return None due to | ||
58 | 592 | bug 490267. | ||
59 | 593 | |||
60 | 594 | >>> bugzilla.getLaunchpadBugId(bug_watch.remotebug) | ||
61 | 563 | 595 | ||
62 | === modified file 'lib/lp/bugs/doc/externalbugtracker-bugzilla-lp-plugin.txt' | |||
63 | --- lib/lp/bugs/doc/externalbugtracker-bugzilla-lp-plugin.txt 2009-08-26 00:17:29 +0000 | |||
64 | +++ lib/lp/bugs/doc/externalbugtracker-bugzilla-lp-plugin.txt 2009-12-13 01:14:17 +0000 | |||
65 | @@ -210,6 +210,7 @@ | |||
66 | 210 | priority: P1 | 210 | priority: P1 |
67 | 211 | product: Marvin | 211 | product: Marvin |
68 | 212 | resolution: FIXED | 212 | resolution: FIXED |
69 | 213 | see_also:... | ||
70 | 213 | severity: normal | 214 | severity: normal |
71 | 214 | status: RESOLVED | 215 | status: RESOLVED |
72 | 215 | summary: That bloody robot still exists. | 216 | summary: That bloody robot still exists. |
73 | @@ -226,6 +227,7 @@ | |||
74 | 226 | priority: P1 | 227 | priority: P1 |
75 | 227 | product: HeartOfGold | 228 | product: HeartOfGold |
76 | 228 | resolution: | 229 | resolution: |
77 | 230 | see_also:... | ||
78 | 229 | severity: high | 231 | severity: high |
79 | 230 | status: NEW | 232 | status: NEW |
80 | 231 | summary: Collect unknown persons in docking bay 2. | 233 | summary: Collect unknown persons in docking bay 2. |
81 | @@ -555,6 +557,7 @@ | |||
82 | 555 | priority: P1 | 557 | priority: P1 |
83 | 556 | product: HeartOfGold | 558 | product: HeartOfGold |
84 | 557 | resolution: | 559 | resolution: |
85 | 560 | see_also: [] | ||
86 | 558 | severity: high | 561 | severity: high |
87 | 559 | status: NEW | 562 | status: NEW |
88 | 560 | summary: Collect unknown persons in docking bay 2. | 563 | summary: Collect unknown persons in docking bay 2. |
89 | 561 | 564 | ||
90 | === modified file 'lib/lp/bugs/externalbugtracker/bugzilla.py' | |||
91 | --- lib/lp/bugs/externalbugtracker/bugzilla.py 2009-09-23 12:24:10 +0000 | |||
92 | +++ lib/lp/bugs/externalbugtracker/bugzilla.py 2009-12-13 01:14:17 +0000 | |||
93 | @@ -27,6 +27,7 @@ | |||
94 | 27 | from canonical.config import config | 27 | from canonical.config import config |
95 | 28 | from canonical.launchpad.interfaces.message import IMessageSet | 28 | from canonical.launchpad.interfaces.message import IMessageSet |
96 | 29 | from canonical.launchpad.webapp.url import urlappend, urlparse | 29 | from canonical.launchpad.webapp.url import urlappend, urlparse |
97 | 30 | from canonical.launchpad.webapp.publisher import canonical_url | ||
98 | 30 | 31 | ||
99 | 31 | from lp.bugs.externalbugtracker.base import ( | 32 | from lp.bugs.externalbugtracker.base import ( |
100 | 32 | BugNotFound, BugTrackerAuthenticationError, BugTrackerConnectError, | 33 | BugNotFound, BugTrackerAuthenticationError, BugTrackerConnectError, |
101 | @@ -35,6 +36,7 @@ | |||
102 | 35 | UnparseableBugTrackerVersion) | 36 | UnparseableBugTrackerVersion) |
103 | 36 | from lp.bugs.externalbugtracker.xmlrpc import ( | 37 | from lp.bugs.externalbugtracker.xmlrpc import ( |
104 | 37 | UrlLib2Transport) | 38 | UrlLib2Transport) |
105 | 39 | from lp.bugs.interfaces.bug import IBugSet | ||
106 | 38 | from lp.bugs.interfaces.bugtask import BugTaskImportance, BugTaskStatus | 40 | from lp.bugs.interfaces.bugtask import BugTaskImportance, BugTaskStatus |
107 | 39 | from lp.bugs.interfaces.externalbugtracker import UNKNOWN_REMOTE_IMPORTANCE | 41 | from lp.bugs.interfaces.externalbugtracker import UNKNOWN_REMOTE_IMPORTANCE |
108 | 40 | from lp.bugs.interfaces.externalbugtracker import ( | 42 | from lp.bugs.interfaces.externalbugtracker import ( |
109 | @@ -425,7 +427,8 @@ | |||
110 | 425 | class BugzillaAPI(Bugzilla): | 427 | class BugzillaAPI(Bugzilla): |
111 | 426 | """An `ExternalBugTracker` to handle Bugzillas that offer an API.""" | 428 | """An `ExternalBugTracker` to handle Bugzillas that offer an API.""" |
112 | 427 | 429 | ||
114 | 428 | implements(ISupportsCommentImport, ISupportsCommentPushing) | 430 | implements( |
115 | 431 | ISupportsBackLinking, ISupportsCommentImport, ISupportsCommentPushing) | ||
116 | 429 | 432 | ||
117 | 430 | def __init__(self, baseurl, xmlrpc_transport=None, | 433 | def __init__(self, baseurl, xmlrpc_transport=None, |
118 | 431 | internal_xmlrpc_transport=None): | 434 | internal_xmlrpc_transport=None): |
119 | @@ -756,6 +759,36 @@ | |||
120 | 756 | # BugWatchUpdater will expect (see bug 248938). | 759 | # BugWatchUpdater will expect (see bug 248938). |
121 | 757 | return str(return_dict['id']) | 760 | return str(return_dict['id']) |
122 | 758 | 761 | ||
123 | 762 | def getLaunchpadBugId(self, remote_bug): | ||
124 | 763 | """Return the Launchpad bug ID for the remote bug. | ||
125 | 764 | |||
126 | 765 | See `ISupportsBackLinking`. | ||
127 | 766 | """ | ||
128 | 767 | # XXX gmb 2009-11-30 bug=490267 | ||
129 | 768 | # In fact, this method always returns None due to bug | ||
130 | 769 | # 490267. Once the bug is fixed in Bugzilla we should update | ||
131 | 770 | # this method. | ||
132 | 771 | return None | ||
133 | 772 | |||
134 | 773 | @needs_authentication | ||
135 | 774 | def setLaunchpadBugId(self, remote_bug, launchpad_bug_id): | ||
136 | 775 | """Set the Launchpad bug for a given remote bug. | ||
137 | 776 | |||
138 | 777 | See `ISupportsBackLinking`. | ||
139 | 778 | """ | ||
140 | 779 | actual_bug_id = self._getActualBugId(remote_bug) | ||
141 | 780 | |||
142 | 781 | # Grab the bug from the database and get its canonical URL. | ||
143 | 782 | launchpad_bug = getUtility(IBugSet).get(launchpad_bug_id) | ||
144 | 783 | launchpad_bug_url = canonical_url(launchpad_bug) | ||
145 | 784 | |||
146 | 785 | request_params = { | ||
147 | 786 | 'ids': [actual_bug_id], | ||
148 | 787 | 'add': [launchpad_bug_url], | ||
149 | 788 | } | ||
150 | 789 | |||
151 | 790 | self.xmlrpc_proxy.Bug.update_see_also(request_params) | ||
152 | 791 | |||
153 | 759 | 792 | ||
154 | 760 | class BugzillaLPPlugin(BugzillaAPI): | 793 | class BugzillaLPPlugin(BugzillaAPI): |
155 | 761 | """An `ExternalBugTracker` to handle Bugzillas using the LP Plugin.""" | 794 | """An `ExternalBugTracker` to handle Bugzillas using the LP Plugin.""" |
156 | 762 | 795 | ||
157 | === modified file 'lib/lp/bugs/tests/bugzilla-api-xmlrpc-transport.txt' | |||
158 | --- lib/lp/bugs/tests/bugzilla-api-xmlrpc-transport.txt 2009-09-02 09:18:14 +0000 | |||
159 | +++ lib/lp/bugs/tests/bugzilla-api-xmlrpc-transport.txt 2009-12-13 01:14:17 +0000 | |||
160 | @@ -113,6 +113,7 @@ | |||
161 | 113 | priority: P1 | 113 | priority: P1 |
162 | 114 | product: Marvin | 114 | product: Marvin |
163 | 115 | resolution: FIXED | 115 | resolution: FIXED |
164 | 116 | see_also: [] | ||
165 | 116 | severity: normal | 117 | severity: normal |
166 | 117 | status: RESOLVED | 118 | status: RESOLVED |
167 | 118 | summary: That bloody robot still exists. | 119 | summary: That bloody robot still exists. |
168 | @@ -165,6 +166,7 @@ | |||
169 | 165 | priority: P1 | 166 | priority: P1 |
170 | 166 | product: HeartOfGold | 167 | product: HeartOfGold |
171 | 167 | resolution: | 168 | resolution: |
172 | 169 | see_also: [] | ||
173 | 168 | severity: high | 170 | severity: high |
174 | 169 | status: NEW | 171 | status: NEW |
175 | 170 | summary: Collect unknown persons in docking bay 2. | 172 | summary: Collect unknown persons in docking bay 2. |
176 | @@ -194,6 +196,7 @@ | |||
177 | 194 | priority: P1 | 196 | priority: P1 |
178 | 195 | product: Marvin | 197 | product: Marvin |
179 | 196 | resolution: FIXED | 198 | resolution: FIXED |
180 | 199 | see_also: [] | ||
181 | 197 | severity: normal | 200 | severity: normal |
182 | 198 | status: RESOLVED | 201 | status: RESOLVED |
183 | 199 | summary: That bloody robot still exists. | 202 | summary: That bloody robot still exists. |
184 | @@ -237,6 +240,7 @@ | |||
185 | 237 | priority: P1 | 240 | priority: P1 |
186 | 238 | product: HeartOfGold | 241 | product: HeartOfGold |
187 | 239 | resolution: | 242 | resolution: |
188 | 243 | see_also: [] | ||
189 | 240 | severity: high | 244 | severity: high |
190 | 241 | status: NEW | 245 | status: NEW |
191 | 242 | summary: Collect unknown persons in docking bay 2. | 246 | summary: Collect unknown persons in docking bay 2. |
192 | @@ -261,6 +265,7 @@ | |||
193 | 261 | priority: P1 | 265 | priority: P1 |
194 | 262 | product: Marvin | 266 | product: Marvin |
195 | 263 | resolution: FIXED | 267 | resolution: FIXED |
196 | 268 | see_also: [] | ||
197 | 264 | severity: normal | 269 | severity: normal |
198 | 265 | status: RESOLVED | 270 | status: RESOLVED |
199 | 266 | summary: That bloody robot still exists. | 271 | summary: That bloody robot still exists. |
200 | @@ -275,6 +280,7 @@ | |||
201 | 275 | priority: P1 | 280 | priority: P1 |
202 | 276 | product: HeartOfGold | 281 | product: HeartOfGold |
203 | 277 | resolution: | 282 | resolution: |
204 | 283 | see_also: [] | ||
205 | 278 | severity: high | 284 | severity: high |
206 | 279 | status: NEW | 285 | status: NEW |
207 | 280 | summary: Collect unknown persons in docking bay 2. | 286 | summary: Collect unknown persons in docking bay 2. |
208 | @@ -469,3 +475,69 @@ | |||
209 | 469 | Fault: <Fault 101: 'Bug #42 does not exist.'> | 475 | Fault: <Fault 101: 'Bug #42 does not exist.'> |
210 | 470 | 476 | ||
211 | 471 | 477 | ||
212 | 478 | Updating the "See also" links on a bug | ||
213 | 479 | -------------------------------------- | ||
214 | 480 | |||
215 | 481 | It's possible to alter the list of bugs linked to a bug in a Bugzilla | ||
216 | 482 | instance by calling the Bug.update_see_also() method. | ||
217 | 483 | |||
218 | 484 | URLs can be added to the list of "See also" links by passing them in the | ||
219 | 485 | `add` parameter. | ||
220 | 486 | |||
221 | 487 | >>> server.Bug.update_see_also({ | ||
222 | 488 | ... 'ids': [1], 'add': ['https://launchpad.net/bugs/15']}) | ||
223 | 489 | {'changes': {1: {'see_also': | ||
224 | 490 | {'added': ['https://launchpad.net/bugs/15']}}}} | ||
225 | 491 | |||
226 | 492 | The URL will now have been added to the bug's see_also list. | ||
227 | 493 | |||
228 | 494 | >>> return_value = server.Bug.get( | ||
229 | 495 | ... {'ids': [1], 'permissive': True}) | ||
230 | 496 | >>> bug_dict = return_value['bugs'][0] | ||
231 | 497 | >>> for key in sorted(bug_dict): | ||
232 | 498 | ... print "%s: %s" % (key, bug_dict.get(key)) | ||
233 | 499 | alias: | ||
234 | 500 | assigned_to: test@canonical.com | ||
235 | 501 | component: GPPSystems | ||
236 | 502 | creation_time: 20080610T16:19:53 | ||
237 | 503 | id: 1 | ||
238 | 504 | internals:... | ||
239 | 505 | is_open: True | ||
240 | 506 | last_change_time: 20080610T16:19:53 | ||
241 | 507 | priority: P1 | ||
242 | 508 | product: Marvin | ||
243 | 509 | resolution: FIXED | ||
244 | 510 | see_also: ['https://launchpad.net/bugs/15'] | ||
245 | 511 | severity: normal | ||
246 | 512 | status: RESOLVED | ||
247 | 513 | summary: That bloody robot still exists. | ||
248 | 514 | |||
249 | 515 | Any attempt to add the same URL again will simply be ignored. | ||
250 | 516 | |||
251 | 517 | >>> server.Bug.update_see_also({ | ||
252 | 518 | ... 'ids': [1], 'add': ['https://launchpad.net/bugs/15']}) | ||
253 | 519 | {'changes': {}} | ||
254 | 520 | |||
255 | 521 | Trying to add a non Bugzilla or Launchpad URL will raise a Fault. | ||
256 | 522 | |||
257 | 523 | >>> server.Bug.update_see_also({ | ||
258 | 524 | ... 'ids': [1], 'add': ['http://example.com/fail']}); | ||
259 | 525 | Traceback (most recent call last): | ||
260 | 526 | ... | ||
261 | 527 | Fault: <Fault 112: 'Bug URL http://example.com/fail is invalid.'> | ||
262 | 528 | |||
263 | 529 | It's also possible to remove items from a bug's see_also list. | ||
264 | 530 | |||
265 | 531 | >>> server.Bug.update_see_also({ | ||
266 | 532 | ... 'ids': [1], 'remove': ['https://launchpad.net/bugs/15']}) | ||
267 | 533 | {'changes': {1: {'see_also': | ||
268 | 534 | {'removed': ['https://launchpad.net/bugs/15']}}}} | ||
269 | 535 | |||
270 | 536 | If a URL is passed in both the `add` and `remove` argument, it will be | ||
271 | 537 | added (i.e. `add` overrides `remove`). | ||
272 | 538 | |||
273 | 539 | >>> server.Bug.update_see_also({ | ||
274 | 540 | ... 'ids': [1], 'add': ['https://launchpad.net/bugs/14'], | ||
275 | 541 | ... 'remove': ['https://launchpad.dev/bugs/14']}) | ||
276 | 542 | {'changes': {1: {'see_also': | ||
277 | 543 | {'added': ['https://launchpad.net/bugs/14']}}}} | ||
278 | 472 | 544 | ||
279 | === modified file 'lib/lp/bugs/tests/bugzilla-xmlrpc-transport.txt' | |||
280 | --- lib/lp/bugs/tests/bugzilla-xmlrpc-transport.txt 2009-08-21 13:13:56 +0000 | |||
281 | +++ lib/lp/bugs/tests/bugzilla-xmlrpc-transport.txt 2009-12-13 01:14:17 +0000 | |||
282 | @@ -152,6 +152,7 @@ | |||
283 | 152 | priority: P1 | 152 | priority: P1 |
284 | 153 | product: Marvin | 153 | product: Marvin |
285 | 154 | resolution: FIXED | 154 | resolution: FIXED |
286 | 155 | see_also: [] | ||
287 | 155 | severity: normal | 156 | severity: normal |
288 | 156 | status: RESOLVED | 157 | status: RESOLVED |
289 | 157 | summary: That bloody robot still exists. | 158 | summary: That bloody robot still exists. |
290 | @@ -177,6 +178,7 @@ | |||
291 | 177 | priority: P1 | 178 | priority: P1 |
292 | 178 | product: Marvin | 179 | product: Marvin |
293 | 179 | resolution: FIXED | 180 | resolution: FIXED |
294 | 181 | see_also: [] | ||
295 | 180 | severity: normal | 182 | severity: normal |
296 | 181 | status: RESOLVED | 183 | status: RESOLVED |
297 | 182 | summary: That bloody robot still exists. | 184 | summary: That bloody robot still exists. |
298 | @@ -192,6 +194,7 @@ | |||
299 | 192 | priority: P1 | 194 | priority: P1 |
300 | 193 | product: HeartOfGold | 195 | product: HeartOfGold |
301 | 194 | resolution: | 196 | resolution: |
302 | 197 | see_also: [] | ||
303 | 195 | severity: high | 198 | severity: high |
304 | 196 | status: NEW | 199 | status: NEW |
305 | 197 | summary: Collect unknown persons in docking bay 2. | 200 | summary: Collect unknown persons in docking bay 2. |
306 | @@ -214,6 +217,7 @@ | |||
307 | 214 | priority: P1 | 217 | priority: P1 |
308 | 215 | product: HeartOfGold | 218 | product: HeartOfGold |
309 | 216 | resolution: | 219 | resolution: |
310 | 220 | see_also: [] | ||
311 | 217 | severity: high | 221 | severity: high |
312 | 218 | status: NEW | 222 | status: NEW |
313 | 219 | summary: Collect unknown persons in docking bay 2. | 223 | summary: Collect unknown persons in docking bay 2. |
314 | @@ -258,6 +262,7 @@ | |||
315 | 258 | priority: P1 | 262 | priority: P1 |
316 | 259 | product: HeartOfGold | 263 | product: HeartOfGold |
317 | 260 | resolution: | 264 | resolution: |
318 | 265 | see_also: [] | ||
319 | 261 | severity: high | 266 | severity: high |
320 | 262 | status: NEW | 267 | status: NEW |
321 | 263 | summary: Collect unknown persons in docking bay 2. | 268 | summary: Collect unknown persons in docking bay 2. |
322 | @@ -307,6 +312,7 @@ | |||
323 | 307 | priority: P1 | 312 | priority: P1 |
324 | 308 | product: HeartOfGold | 313 | product: HeartOfGold |
325 | 309 | resolution: | 314 | resolution: |
326 | 315 | see_also: [] | ||
327 | 310 | severity: high | 316 | severity: high |
328 | 311 | status: NEW | 317 | status: NEW |
329 | 312 | summary: Collect unknown persons in docking bay 2. | 318 | summary: Collect unknown persons in docking bay 2. |
330 | 313 | 319 | ||
331 | === modified file 'lib/lp/bugs/tests/externalbugtracker.py' | |||
332 | --- lib/lp/bugs/tests/externalbugtracker.py 2009-09-02 08:32:27 +0000 | |||
333 | +++ lib/lp/bugs/tests/externalbugtracker.py 2009-12-13 01:14:17 +0000 | |||
334 | @@ -379,6 +379,7 @@ | |||
335 | 379 | 'priority': 'P1', | 379 | 'priority': 'P1', |
336 | 380 | 'product': 'Marvin', | 380 | 'product': 'Marvin', |
337 | 381 | 'resolution': 'FIXED', | 381 | 'resolution': 'FIXED', |
338 | 382 | 'see_also': [], | ||
339 | 382 | 'severity': 'normal', | 383 | 'severity': 'normal', |
340 | 383 | 'status': 'RESOLVED', | 384 | 'status': 'RESOLVED', |
341 | 384 | 'summary': "That bloody robot still exists.", | 385 | 'summary': "That bloody robot still exists.", |
342 | @@ -394,6 +395,7 @@ | |||
343 | 394 | 'priority': 'P1', | 395 | 'priority': 'P1', |
344 | 395 | 'product': 'HeartOfGold', | 396 | 'product': 'HeartOfGold', |
345 | 396 | 'resolution': '', | 397 | 'resolution': '', |
346 | 398 | 'see_also': [], | ||
347 | 397 | 'severity': 'high', | 399 | 'severity': 'high', |
348 | 398 | 'status': 'NEW', | 400 | 'status': 'NEW', |
349 | 399 | 'summary': 'Collect unknown persons in docking bay 2.', | 401 | 'summary': 'Collect unknown persons in docking bay 2.', |
350 | @@ -773,6 +775,7 @@ | |||
351 | 773 | 'comments', | 775 | 'comments', |
352 | 774 | 'get', | 776 | 'get', |
353 | 775 | 'search', | 777 | 'search', |
354 | 778 | 'update_see_also', | ||
355 | 776 | ], | 779 | ], |
356 | 777 | 'Bugzilla': [ | 780 | 'Bugzilla': [ |
357 | 778 | 'time', | 781 | 'time', |
358 | @@ -992,6 +995,73 @@ | |||
359 | 992 | # cause it to explode. | 995 | # cause it to explode. |
360 | 993 | return [{'id': comment_id}] | 996 | return [{'id': comment_id}] |
361 | 994 | 997 | ||
362 | 998 | def update_see_also(self, arguments): | ||
363 | 999 | """Update the see_also references for a bug.""" | ||
364 | 1000 | assert 'ids' in arguments, ( | ||
365 | 1001 | "You must specify a set of IDs with which to work.") | ||
366 | 1002 | assert ('add' in arguments or 'remove' in arguments), ( | ||
367 | 1003 | "You must specify a list of links to add or remove.") | ||
368 | 1004 | |||
369 | 1005 | changes = {} | ||
370 | 1006 | |||
371 | 1007 | for bug_id in arguments['ids']: | ||
372 | 1008 | bug_id = int(bug_id) | ||
373 | 1009 | |||
374 | 1010 | # If the bug ID doesn't exist, raise a Fault. | ||
375 | 1011 | if bug_id not in self.bugs: | ||
376 | 1012 | raise xmlrpclib.Fault(101, "Bug #%s does not exist." % bug_id) | ||
377 | 1013 | |||
378 | 1014 | see_also_list = self.bugs[bug_id].get('see_also', []) | ||
379 | 1015 | |||
380 | 1016 | # Remove any items first. That way, if they're also in the | ||
381 | 1017 | # 'add' section they'll get re-added. | ||
382 | 1018 | for url in arguments.get('remove', []): | ||
383 | 1019 | if url not in see_also_list: | ||
384 | 1020 | continue | ||
385 | 1021 | |||
386 | 1022 | if changes.get(bug_id) is None: | ||
387 | 1023 | changes[bug_id] = {} | ||
388 | 1024 | |||
389 | 1025 | if changes[bug_id].get('see_also') is None: | ||
390 | 1026 | changes[bug_id]['see_also'] = {} | ||
391 | 1027 | |||
392 | 1028 | if changes[bug_id]['see_also'].get('removed') is None: | ||
393 | 1029 | changes[bug_id]['see_also']['removed'] = [] | ||
394 | 1030 | |||
395 | 1031 | see_also_list.remove(url) | ||
396 | 1032 | changes[bug_id]['see_also']['removed'].append(url) | ||
397 | 1033 | |||
398 | 1034 | # Add any items to the list. | ||
399 | 1035 | for url in arguments.get('add', []): | ||
400 | 1036 | if url in see_also_list: | ||
401 | 1037 | # Ignore existing urls. | ||
402 | 1038 | continue | ||
403 | 1039 | |||
404 | 1040 | if ('launchpad' not in url and | ||
405 | 1041 | 'show_bug.cgi' not in url): | ||
406 | 1042 | raise xmlrpclib.Fault( | ||
407 | 1043 | 112, "Bug URL %s is invalid." % url) | ||
408 | 1044 | |||
409 | 1045 | if changes.get(bug_id) is None: | ||
410 | 1046 | changes[bug_id] = {} | ||
411 | 1047 | |||
412 | 1048 | if changes[bug_id].get('see_also') is None: | ||
413 | 1049 | changes[bug_id]['see_also'] = {} | ||
414 | 1050 | |||
415 | 1051 | if changes[bug_id]['see_also'].get('added') is None: | ||
416 | 1052 | changes[bug_id]['see_also']['added'] = [] | ||
417 | 1053 | |||
418 | 1054 | see_also_list.append(url) | ||
419 | 1055 | changes[bug_id]['see_also']['added'].append(url) | ||
420 | 1056 | |||
421 | 1057 | # Replace the bug's existing see_also list. | ||
422 | 1058 | self.bugs[bug_id]['see_also'] = see_also_list | ||
423 | 1059 | |||
424 | 1060 | # We have to return a list here because xmlrpclib will try to | ||
425 | 1061 | # expand sequences of length 1. Trying to do that on a dict will | ||
426 | 1062 | # cause it to explode. | ||
427 | 1063 | return [{'changes': changes}] | ||
428 | 1064 | |||
429 | 995 | 1065 | ||
430 | 996 | class TestMantis(Mantis): | 1066 | class TestMantis(Mantis): |
431 | 997 | """Mantis ExternalSystem for use in tests. | 1067 | """Mantis ExternalSystem for use in tests. |
This branch fixes bug 419134 by making the BugzillaAPI ExternalBugTracker implement the ISupportsBackLi nking interface.
I've added a test implementation of the Bugzilla API's Bug.update_ see_also( ) method, which I've then used in the tests of BugzillaAPI. setLaunchpadBug Id().
This branch is an rc candidate.
= Launchpad lint =
Note: I suspect that the lint notices about email.Utils are because lint runs using the system Python (2.6) rather than bin/py.
Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.
Linting changed files: bugs/doc/ externalbugtrac ker-bugzilla- api.txt bugs/externalbu gtracker/ bugzilla. py bugs/tests/ bugzilla- api-xmlrpc- transport. txt bugs/tests/ externalbugtrac ker.py
lib/lp/
lib/lp/
lib/lp/
lib/lp/
== Pylint notices ==
lib/lp/ bugs/externalbu gtracker/ bugzilla. py
20: [F0401] Unable to import 'email.Utils' (No module named Utils)
lib/lp/ bugs/tests/ externalbugtrac ker.py TestHandler. default_ open.<lambda> ] Lambda may not be necessary TestHandler. default_ open.<lambda> ] Lambda may not be necessary
1642: [W0108, Urlib2Transport
1656: [W0108, Urlib2Transport