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
=== modified file 'lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt'
--- lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt 2010-10-04 19:50:45 +0000
+++ lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt 2010-10-15 12:38:43 +0000
@@ -230,6 +230,23 @@
230 >>> bugzilla._getActualBugId(2)230 >>> bugzilla._getActualBugId(2)
231 2231 2
232232
233Sometimes a Bugzilla will return bug data without an alias field.
234_storeBugs() handles that, too.
235
236 >>> from lp.bugs.tests.externalbugtracker import (
237 ... NoAliasTestBugzillaAPIXMLRPCTransport)
238 >>> no_alias_transport = NoAliasTestBugzillaAPIXMLRPCTransport(
239 ... 'http://bugzilla-3.4.example.com/')
240 >>> no_alias_bugzilla = BugzillaAPI(
241 ... 'http://bugzilla-3.4.example.com/',
242 ... xmlrpc_transport=no_alias_transport)
243 >>> no_alias_transport.print_method_calls = True
244 >>> no_alias_bugzilla.initializeRemoteBugDB([1])
245 CALLED Bug.get({'ids': [1], 'permissive': True})
246
247 >>> print len(no_alias_bugzilla._bug_aliases)
248 0
249
233250
234Getting remote statuses251Getting remote statuses
235-----------------------252-----------------------
236253
=== modified file 'lib/lp/bugs/externalbugtracker/bugzilla.py'
--- lib/lp/bugs/externalbugtracker/bugzilla.py 2010-09-24 21:06:04 +0000
+++ lib/lp/bugs/externalbugtracker/bugzilla.py 2010-10-15 12:38:43 +0000
@@ -575,7 +575,7 @@
575 # IDs. We use the aliases dict to look up the correct ID for575 # IDs. We use the aliases dict to look up the correct ID for
576 # a bug. This allows us to reference a bug by either ID or576 # a bug. This allows us to reference a bug by either ID or
577 # alias.577 # alias.
578 if remote_bug['alias'] != '':578 if remote_bug.get('alias', '') != '':
579 self._bug_aliases[remote_bug['alias']] = remote_bug['id']579 self._bug_aliases[remote_bug['alias']] = remote_bug['id']
580580
581 @ensure_no_transaction581 @ensure_no_transaction
582582
=== modified file 'lib/lp/bugs/tests/externalbugtracker.py'
--- lib/lp/bugs/tests/externalbugtracker.py 2010-09-28 14:59:25 +0000
+++ lib/lp/bugs/tests/externalbugtracker.py 2010-10-15 12:38:43 +0000
@@ -1077,6 +1077,28 @@
1077 return [{'changes': changes}]1077 return [{'changes': changes}]
10781078
10791079
1080class NoAliasTestBugzillaAPIXMLRPCTransport(TestBugzillaAPIXMLRPCTransport):
1081 """A TestBugzillaAPIXMLRPCTransport that has no bug aliases."""
1082
1083 bugs = {
1084 1: {'assigned_to': 'test@canonical.com',
1085 'component': 'GPPSystems',
1086 'creation_time': datetime(2008, 6, 10, 16, 19, 53),
1087 'id': 1,
1088 'internals': {},
1089 'is_open': True,
1090 'last_change_time': datetime(2008, 6, 10, 16, 19, 53),
1091 'priority': 'P1',
1092 'product': 'Marvin',
1093 'resolution': 'FIXED',
1094 'see_also': [],
1095 'severity': 'normal',
1096 'status': 'RESOLVED',
1097 'summary': "That bloody robot still exists.",
1098 },
1099 }
1100
1101
1080class TestMantis(Mantis):1102class TestMantis(Mantis):
1081 """Mantis ExternalSystem for use in tests.1103 """Mantis ExternalSystem for use in tests.
10821104