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

Proposed by Colin Watson
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 Approve
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.
Revision history for this message
William Grant (wgrant) :
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.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 @@
188 ... not isinstance(bugzilla_to_use, BugzillaLPPlugin))188 ... not isinstance(bugzilla_to_use, BugzillaLPPlugin))
189 True189 True
190190
191A version older than 3.4 is not accepted.
192
193 >>> test_transport = APIXMLRPCTransport()
194 >>> test_transport.version = '3.3'
195
196 >>> bugzilla._test_xmlrpc_proxy = xmlrpclib.ServerProxy(
197 ... 'http://example.com/xmlrpc.cgi',
198 ... transport=test_transport)
199
200 >>> bugzilla_to_use = bugzilla.getExternalBugTrackerToUse()
201 >>> isinstance(bugzilla_to_use, BugzillaAPI)
202 False
203
204bugzilla.mozilla.org uses a date-based version scheme. This is accepted.
205
206 >>> test_transport = APIXMLRPCTransport()
207 >>> test_transport.version = '20181108.1'
208
209 >>> bugzilla._test_xmlrpc_proxy = xmlrpclib.ServerProxy(
210 ... 'http://example.com/xmlrpc.cgi',
211 ... transport=test_transport)
212
213 >>> bugzilla_to_use = bugzilla.getExternalBugTrackerToUse()
214 >>> (isinstance(bugzilla_to_use, BugzillaAPI) and
215 ... not isinstance(bugzilla_to_use, BugzillaLPPlugin))
216 True
217
191If the remote system has the Launchpad plugin installed, an218If the remote system has the Launchpad plugin installed, an
192getExternalBugTrackerToUse() will return a BugzillaLPPlugin instance.219getExternalBugTrackerToUse() will return a BugzillaLPPlugin instance.
193220
194221
=== 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 @@
80 """Return True if the remote host offers the Bugzilla API.80 """Return True if the remote host offers the Bugzilla API.
8181
82 :return: True if the remote host offers an XML-RPC API and its82 :return: True if the remote host offers an XML-RPC API and its
83 version is > 3.4. Return False otherwise.83 version is >= 3.4. Return False otherwise.
84 """84 """
85 api = BugzillaAPI(self.baseurl)85 api = BugzillaAPI(self.baseurl)
86 if self._test_xmlrpc_proxy is not None:86 if self._test_xmlrpc_proxy is not None:
@@ -116,7 +116,7 @@
116 # Older versions of the Bugzilla API return tuples. We116 # Older versions of the Bugzilla API return tuples. We
117 # consider anything other than a mapping to be unsupported.117 # consider anything other than a mapping to be unsupported.
118 if isinstance(remote_version, dict):118 if isinstance(remote_version, dict):
119 if remote_version['version'] >= '3.4':119 if self._parseVersion(remote_version['version']) >= (3, 4):
120 return True120 return True
121 return False121 return False
122122