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

Proposed by Colin Watson on 2018-11-12
Status: Merged
Merged at revision: 18836
Proposed branch: lp:~cjwatson/launchpad/fix-bmo-version-parsing
Merge into: lp:launchpad
Diff against target: 58 lines (+29/-2)
2 files modified
lib/lp/bugs/doc/externalbugtracker-bugzilla.txt (+27/-0)
lib/lp/bugs/externalbugtracker/bugzilla.py (+2/-2)
To merge this branch: bzr merge lp:~cjwatson/launchpad/fix-bmo-version-parsing
Reviewer Review Type Date Requested Status
William Grant code 2018-11-12 Approve on 2018-12-05
Review via email: mp+358630@code.launchpad.net

Commit message

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

To post a comment you must log in.
William Grant (wgrant) :
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.txt'
2--- lib/lp/bugs/doc/externalbugtracker-bugzilla.txt 2018-06-29 23:10:57 +0000
3+++ lib/lp/bugs/doc/externalbugtracker-bugzilla.txt 2018-11-12 11:10:53 +0000
4@@ -188,6 +188,33 @@
5 ... not isinstance(bugzilla_to_use, BugzillaLPPlugin))
6 True
7
8+A version older than 3.4 is not accepted.
9+
10+ >>> test_transport = APIXMLRPCTransport()
11+ >>> test_transport.version = '3.3'
12+
13+ >>> bugzilla._test_xmlrpc_proxy = xmlrpclib.ServerProxy(
14+ ... 'http://example.com/xmlrpc.cgi',
15+ ... transport=test_transport)
16+
17+ >>> bugzilla_to_use = bugzilla.getExternalBugTrackerToUse()
18+ >>> isinstance(bugzilla_to_use, BugzillaAPI)
19+ False
20+
21+bugzilla.mozilla.org uses a date-based version scheme. This is accepted.
22+
23+ >>> test_transport = APIXMLRPCTransport()
24+ >>> test_transport.version = '20181108.1'
25+
26+ >>> bugzilla._test_xmlrpc_proxy = xmlrpclib.ServerProxy(
27+ ... 'http://example.com/xmlrpc.cgi',
28+ ... transport=test_transport)
29+
30+ >>> bugzilla_to_use = bugzilla.getExternalBugTrackerToUse()
31+ >>> (isinstance(bugzilla_to_use, BugzillaAPI) and
32+ ... not isinstance(bugzilla_to_use, BugzillaLPPlugin))
33+ True
34+
35 If the remote system has the Launchpad plugin installed, an
36 getExternalBugTrackerToUse() will return a BugzillaLPPlugin instance.
37
38
39=== modified file 'lib/lp/bugs/externalbugtracker/bugzilla.py'
40--- lib/lp/bugs/externalbugtracker/bugzilla.py 2018-06-23 09:46:28 +0000
41+++ lib/lp/bugs/externalbugtracker/bugzilla.py 2018-11-12 11:10:53 +0000
42@@ -80,7 +80,7 @@
43 """Return True if the remote host offers the Bugzilla API.
44
45 :return: True if the remote host offers an XML-RPC API and its
46- version is > 3.4. Return False otherwise.
47+ version is >= 3.4. Return False otherwise.
48 """
49 api = BugzillaAPI(self.baseurl)
50 if self._test_xmlrpc_proxy is not None:
51@@ -116,7 +116,7 @@
52 # Older versions of the Bugzilla API return tuples. We
53 # consider anything other than a mapping to be unsupported.
54 if isinstance(remote_version, dict):
55- if remote_version['version'] >= '3.4':
56+ if self._parseVersion(remote_version['version']) >= (3, 4):
57 return True
58 return False
59