Merge lp:~gmb/launchpad/fix-bugzilla-sans-alias-bug-660873 into lp:launchpad

Proposed by Graham Binns
Status: Merged
Approved by: Graham Binns
Approved revision: no longer in the source branch.
Merged at revision: 11719
Proposed branch: lp:~gmb/launchpad/fix-bugzilla-sans-alias-bug-660873
Merge into: lp:launchpad
Diff against target: 72 lines (+40/-1)
3 files modified
lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt (+17/-0)
lib/lp/bugs/externalbugtracker/bugzilla.py (+1/-1)
lib/lp/bugs/tests/externalbugtracker.py (+22/-0)
To merge this branch: bzr merge lp:~gmb/launchpad/fix-bugzilla-sans-alias-bug-660873
Reviewer Review Type Date Requested Status
Abel Deuring (community) code Approve
Review via email: mp+38533@code.launchpad.net

Commit message

The BugzillaAPI and LPPlugin ExternalBugTrackers will no longer OOPS when a Bugzilla doesn't return an alias for a bug.

Description of the change

This branch fixes bug 660873.

In order to fix this bug I've:

 - Added a new TestBugzillaAPIXMLRPCTransport that doesn't return bug aliases.
 - Added a test that covers the problem to externalbugtracker-bugzilla-api.txt
 - Fixed the bug by using .get() instead of accessing the key directly.

To post a comment you must log in.
Revision history for this message
Abel Deuring (adeuring) :
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/doc/externalbugtracker-bugzilla-api.txt'
2--- lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt 2010-10-04 19:50:45 +0000
3+++ lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt 2010-10-15 12:38:43 +0000
4@@ -230,6 +230,23 @@
5 >>> bugzilla._getActualBugId(2)
6 2
7
8+Sometimes a Bugzilla will return bug data without an alias field.
9+_storeBugs() handles that, too.
10+
11+ >>> from lp.bugs.tests.externalbugtracker import (
12+ ... NoAliasTestBugzillaAPIXMLRPCTransport)
13+ >>> no_alias_transport = NoAliasTestBugzillaAPIXMLRPCTransport(
14+ ... 'http://bugzilla-3.4.example.com/')
15+ >>> no_alias_bugzilla = BugzillaAPI(
16+ ... 'http://bugzilla-3.4.example.com/',
17+ ... xmlrpc_transport=no_alias_transport)
18+ >>> no_alias_transport.print_method_calls = True
19+ >>> no_alias_bugzilla.initializeRemoteBugDB([1])
20+ CALLED Bug.get({'ids': [1], 'permissive': True})
21+
22+ >>> print len(no_alias_bugzilla._bug_aliases)
23+ 0
24+
25
26 Getting remote statuses
27 -----------------------
28
29=== modified file 'lib/lp/bugs/externalbugtracker/bugzilla.py'
30--- lib/lp/bugs/externalbugtracker/bugzilla.py 2010-09-24 21:06:04 +0000
31+++ lib/lp/bugs/externalbugtracker/bugzilla.py 2010-10-15 12:38:43 +0000
32@@ -575,7 +575,7 @@
33 # IDs. We use the aliases dict to look up the correct ID for
34 # a bug. This allows us to reference a bug by either ID or
35 # alias.
36- if remote_bug['alias'] != '':
37+ if remote_bug.get('alias', '') != '':
38 self._bug_aliases[remote_bug['alias']] = remote_bug['id']
39
40 @ensure_no_transaction
41
42=== modified file 'lib/lp/bugs/tests/externalbugtracker.py'
43--- lib/lp/bugs/tests/externalbugtracker.py 2010-09-28 14:59:25 +0000
44+++ lib/lp/bugs/tests/externalbugtracker.py 2010-10-15 12:38:43 +0000
45@@ -1077,6 +1077,28 @@
46 return [{'changes': changes}]
47
48
49+class NoAliasTestBugzillaAPIXMLRPCTransport(TestBugzillaAPIXMLRPCTransport):
50+ """A TestBugzillaAPIXMLRPCTransport that has no bug aliases."""
51+
52+ bugs = {
53+ 1: {'assigned_to': 'test@canonical.com',
54+ 'component': 'GPPSystems',
55+ 'creation_time': datetime(2008, 6, 10, 16, 19, 53),
56+ 'id': 1,
57+ 'internals': {},
58+ 'is_open': True,
59+ 'last_change_time': datetime(2008, 6, 10, 16, 19, 53),
60+ 'priority': 'P1',
61+ 'product': 'Marvin',
62+ 'resolution': 'FIXED',
63+ 'see_also': [],
64+ 'severity': 'normal',
65+ 'status': 'RESOLVED',
66+ 'summary': "That bloody robot still exists.",
67+ },
68+ }
69+
70+
71 class TestMantis(Mantis):
72 """Mantis ExternalSystem for use in tests.
73