← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/fix-bmo-version-parsing into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/fix-bmo-version-parsing into lp:launchpad.

Commit message:
Compare Bugzilla versions properly when checking whether they support the Bugzilla API.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1802798 in Launchpad itself: "Launchpad couldn't connect to Mozilla Bugzilla"
  https://bugs.launchpad.net/launchpad/+bug/1802798

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/fix-bmo-version-parsing/+merge/358630
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/fix-bmo-version-parsing into lp:launchpad.
=== modified file 'lib/lp/bugs/doc/externalbugtracker-bugzilla.txt'
--- lib/lp/bugs/doc/externalbugtracker-bugzilla.txt	2018-06-29 23:10:57 +0000
+++ lib/lp/bugs/doc/externalbugtracker-bugzilla.txt	2018-11-12 11:10:53 +0000
@@ -188,6 +188,33 @@
     ...  not isinstance(bugzilla_to_use, BugzillaLPPlugin))
     True
 
+A version older than 3.4 is not accepted.
+
+    >>> test_transport = APIXMLRPCTransport()
+    >>> test_transport.version = '3.3'
+
+    >>> bugzilla._test_xmlrpc_proxy = xmlrpclib.ServerProxy(
+    ...     'http://example.com/xmlrpc.cgi',
+    ...     transport=test_transport)
+
+    >>> bugzilla_to_use = bugzilla.getExternalBugTrackerToUse()
+    >>> isinstance(bugzilla_to_use, BugzillaAPI)
+    False
+
+bugzilla.mozilla.org uses a date-based version scheme.  This is accepted.
+
+    >>> test_transport = APIXMLRPCTransport()
+    >>> test_transport.version = '20181108.1'
+
+    >>> bugzilla._test_xmlrpc_proxy = xmlrpclib.ServerProxy(
+    ...     'http://example.com/xmlrpc.cgi',
+    ...     transport=test_transport)
+
+    >>> bugzilla_to_use = bugzilla.getExternalBugTrackerToUse()
+    >>> (isinstance(bugzilla_to_use, BugzillaAPI) and
+    ...  not isinstance(bugzilla_to_use, BugzillaLPPlugin))
+    True
+
 If the remote system has the Launchpad plugin installed, an
 getExternalBugTrackerToUse() will return a BugzillaLPPlugin instance.
 

=== modified file 'lib/lp/bugs/externalbugtracker/bugzilla.py'
--- lib/lp/bugs/externalbugtracker/bugzilla.py	2018-06-23 09:46:28 +0000
+++ lib/lp/bugs/externalbugtracker/bugzilla.py	2018-11-12 11:10:53 +0000
@@ -80,7 +80,7 @@
         """Return True if the remote host offers the Bugzilla API.
 
         :return: True if the remote host offers an XML-RPC API and its
-            version is > 3.4. Return False otherwise.
+            version is >= 3.4. Return False otherwise.
         """
         api = BugzillaAPI(self.baseurl)
         if self._test_xmlrpc_proxy is not None:
@@ -116,7 +116,7 @@
             # Older versions of the Bugzilla API return tuples. We
             # consider anything other than a mapping to be unsupported.
             if isinstance(remote_version, dict):
-                if remote_version['version'] >= '3.4':
+                if self._parseVersion(remote_version['version']) >= (3, 4):
                     return True
             return False
 


Follow ups