← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~wgrant/launchpad/bugzilla-alias-list into lp:launchpad

 

William Grant has proposed merging lp:~wgrant/launchpad/bugzilla-alias-list into lp:launchpad.

Commit message:
Fix Bugzilla bug watches to support new versions that permit multiple aliases.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/bugzilla-alias-list/+merge/314265

Fix Bugzilla bug watches to support new versions that permit multiple aliases.

eg. OOPS-ff5db6643741d0fe0357f384beb3bef0
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/bugzilla-alias-list into lp:launchpad.
=== modified file 'lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt'
--- lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt	2016-09-21 02:49:42 +0000
+++ lib/lp/bugs/doc/externalbugtracker-bugzilla-api.txt	2017-01-06 23:03:09 +0000
@@ -191,8 +191,8 @@
 
     >>> bugzilla._bugs = {}
     >>> bugzilla._bug_aliases = {}
-    >>> bugzilla.initializeRemoteBugDB([2, 'bug-two'])
-    CALLED Bug.get({'ids': [2, 'bug-two'], 'permissive': True})
+    >>> bugzilla.initializeRemoteBugDB([2, 'bug-two', 3])
+    CALLED Bug.get({'ids': [2, 'bug-two', 3], 'permissive': True})
 
     >>> print_bugs(bugzilla._bugs)
     Bug 2:
@@ -211,14 +211,32 @@
         severity: high
         status: NEW
         summary: Collect unknown persons in docking bay 2.
+    Bug 3:
+        alias: ['bug-three', 'bad-diodes']
+        assigned_to: marvin@xxxxxxxxxxxxxxxx
+        component: Crew
+        creation_time: 2008-06-10 09:23:12
+        id: 3
+        internals:...
+        is_open: True
+        last_change_time: 2008-06-10 09:24:29
+        priority: P1
+        product: Marvin
+        resolution:
+        see_also: []
+        severity: high
+        status: NEW
+        summary: Pain in all the diodes down my left hand side.
     <BLANKLINE>
     <BLANKLINE>
 
 Aliases are stored in a separate dict, which contains a mapping between
 the alias and the bug's actual ID.
 
-    >>> for alias, bug_id in bugzilla._bug_aliases.items():
+    >>> for alias, bug_id in sorted(bugzilla._bug_aliases.items()):
     ...     print "%s: %s" % (alias, bug_id)
+    bad-diodes: 3
+    bug-three: 3
     bug-two: 2
 
 The method _getActualBugId() returns the correct bug ID for a passed bug
@@ -230,6 +248,10 @@
     >>> bugzilla._getActualBugId(2)
     2
 
+    >>> bugzilla._getActualBugId('bad-diodes')
+    3
+
+
 Sometimes a Bugzilla will return bug data without an alias field.
 _storeBugs() handles that, too.
 

=== modified file 'lib/lp/bugs/externalbugtracker/bugzilla.py'
--- lib/lp/bugs/externalbugtracker/bugzilla.py	2015-07-08 16:05:11 +0000
+++ lib/lp/bugs/externalbugtracker/bugzilla.py	2017-01-06 23:03:09 +0000
@@ -620,8 +620,13 @@
             # 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.get('alias', '') != '':
-                self._bug_aliases[remote_bug['alias']] = remote_bug['id']
+            # Some versions of Bugzilla return a single alias string,
+            # others return a (possibly empty) list.
+            aliases = remote_bug.get('alias', '')
+            if isinstance(aliases, basestring):
+                aliases = [] if not aliases else [aliases]
+            for alias in aliases:
+                self._bug_aliases[alias] = remote_bug['id']
 
     @ensure_no_transaction
     def getCurrentDBTime(self):

=== modified file 'lib/lp/bugs/tests/bugzilla-api-xmlrpc-transport.txt'
--- lib/lp/bugs/tests/bugzilla-api-xmlrpc-transport.txt	2016-09-21 02:49:42 +0000
+++ lib/lp/bugs/tests/bugzilla-api-xmlrpc-transport.txt	2017-01-06 23:03:09 +0000
@@ -269,6 +269,21 @@
     severity: high
     status: NEW
     summary: Collect unknown persons in docking bay 2.
+    alias: ['bug-three', 'bad-diodes']
+    assigned_to: marvin@xxxxxxxxxxxxxxxx
+    component: Crew
+    creation_time: 2008-06-10 09:23:12
+    id: 3
+    internals:...
+    is_open: True
+    last_change_time: 2008-06-10 09:24:29
+    priority: P1
+    product: Marvin
+    resolution:
+    see_also: []
+    severity: high
+    status: NEW
+    summary: Pain in all the diodes down my left hand side.
 
 
 Getting the comments for a bug

=== modified file 'lib/lp/bugs/tests/externalbugtracker.py'
--- lib/lp/bugs/tests/externalbugtracker.py	2013-05-09 08:53:01 +0000
+++ lib/lp/bugs/tests/externalbugtracker.py	2017-01-06 23:03:09 +0000
@@ -424,11 +424,29 @@
             'status': 'NEW',
             'summary': 'Collect unknown persons in docking bay 2.',
             },
+        3: {'alias': ['bug-three', 'bad-diodes'],
+            'assigned_to': 'marvin@xxxxxxxxxxxxxxxx',
+            'component': 'Crew',
+            'creation_time': datetime(2008, 6, 10, 9, 23, 12),
+            'id': 3,
+            'internals': {},
+            'is_open': True,
+            'last_change_time': datetime(2008, 6, 10, 9, 24, 29),
+            'priority': 'P1',
+            'product': 'Marvin',
+            'resolution': '',
+            'see_also': [],
+            'severity': 'high',
+            'status': 'NEW',
+            'summary': "Pain in all the diodes down my left hand side.",
+            },
         }
 
     # Map aliases onto bugs.
     _bug_aliases = {
         'bug-two': 2,
+        'bug-three': 3,
+        'bad-diodes': 3,
         }
 
     # Comments are mapped to bug IDs.


Follow ups