launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #01557
[Merge] lp:~gmb/launchpad/fix-bugzilla-sans-alias-bug-660873 into lp:launchpad/devel
Graham Binns has proposed merging lp:~gmb/launchpad/fix-bugzilla-sans-alias-bug-660873 into lp:launchpad/devel.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers): code
Related bugs:
#660873 BugzillaAPI._storeBugs() doesn't handle bugs not having an alias field
https://bugs.launchpad.net/bugs/660873
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.
--
https://code.launchpad.net/~gmb/launchpad/fix-bugzilla-sans-alias-bug-660873/+merge/38533
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~gmb/launchpad/fix-bugzilla-sans-alias-bug-660873 into lp:launchpad/devel.
=== 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 @@
>>> bugzilla._getActualBugId(2)
2
+Sometimes a Bugzilla will return bug data without an alias field.
+_storeBugs() handles that, too.
+
+ >>> from lp.bugs.tests.externalbugtracker import (
+ ... NoAliasTestBugzillaAPIXMLRPCTransport)
+ >>> no_alias_transport = NoAliasTestBugzillaAPIXMLRPCTransport(
+ ... 'http://bugzilla-3.4.example.com/')
+ >>> no_alias_bugzilla = BugzillaAPI(
+ ... 'http://bugzilla-3.4.example.com/',
+ ... xmlrpc_transport=no_alias_transport)
+ >>> no_alias_transport.print_method_calls = True
+ >>> no_alias_bugzilla.initializeRemoteBugDB([1])
+ CALLED Bug.get({'ids': [1], 'permissive': True})
+
+ >>> print len(no_alias_bugzilla._bug_aliases)
+ 0
+
Getting remote statuses
-----------------------
=== 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 @@
# IDs. We use the aliases dict to look up the correct ID for
# a bug. This allows us to reference a bug by either ID or
# alias.
- if remote_bug['alias'] != '':
+ if remote_bug.get('alias', '') != '':
self._bug_aliases[remote_bug['alias']] = remote_bug['id']
@ensure_no_transaction
=== 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 @@
return [{'changes': changes}]
+class NoAliasTestBugzillaAPIXMLRPCTransport(TestBugzillaAPIXMLRPCTransport):
+ """A TestBugzillaAPIXMLRPCTransport that has no bug aliases."""
+
+ bugs = {
+ 1: {'assigned_to': 'test@xxxxxxxxxxxxx',
+ 'component': 'GPPSystems',
+ 'creation_time': datetime(2008, 6, 10, 16, 19, 53),
+ 'id': 1,
+ 'internals': {},
+ 'is_open': True,
+ 'last_change_time': datetime(2008, 6, 10, 16, 19, 53),
+ 'priority': 'P1',
+ 'product': 'Marvin',
+ 'resolution': 'FIXED',
+ 'see_also': [],
+ 'severity': 'normal',
+ 'status': 'RESOLVED',
+ 'summary': "That bloody robot still exists.",
+ },
+ }
+
+
class TestMantis(Mantis):
"""Mantis ExternalSystem for use in tests.