From f57f57c5be50fc9cf2860b79310a22f4f1d7811e Mon Sep 17 00:00:00 2001 From: James Vega Date: Mon, 17 Nov 2003 19:57:07 +0000 Subject: [PATCH] Fixed some bugs in Bugzilla and added some tests to try and catch more problems in the future. --- plugins/Bugzilla.py | 11 ++++++++--- test/test_Bugzilla.py | 3 +++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/plugins/Bugzilla.py b/plugins/Bugzilla.py index 6a14852aa..20a65f5ea 100644 --- a/plugins/Bugzilla.py +++ b/plugins/Bugzilla.py @@ -43,6 +43,7 @@ from itertools import imap, ifilter from htmlentitydefs import entitydefs as entities import conf +import debug import utils import plugins import ircutils @@ -114,7 +115,8 @@ class Bugzilla(callbacks.PrivmsgCommandAndRegexp, plugins.Configurable): be listed with the bugzilla query. """ (name, url, description) = privmsgs.getArgs(args, required=3) - cursor = self.db.cursor() + if url[-1] == '/': + url = url[:-1] self.db[name] = [url, description] self.shorthand = utils.abbrev(self.db.keys()) irc.reply(msg, conf.replySuccess) @@ -191,10 +193,13 @@ class Bugzilla(callbacks.PrivmsgCommandAndRegexp, plugins.Configurable): try: name = self.shorthand[name] (url, description) = self.db[name] + #debug.printf(url) + #debug.printf(description) except KeyError: irc.error(msg, replyNoBugzilla % name) return queryurl = '%s/xml.cgi?id=%s' % (url, number) + #debug.printf(queryurl) try: summary = self._get_short_bug_summary(queryurl,description,number) except BugzillaError, e: @@ -229,8 +234,8 @@ class Bugzilla(callbacks.PrivmsgCommandAndRegexp, plugins.Configurable): return ', '.join(imap(str, L)) def _get_short_bug_summary(self, url, desc, number): - bugxml = self._getbugxml(url, desc) try: + bugxml = self._getbugxml(url, desc) zilladom = minidom.parseString(bugxml) except Exception, e: s = 'Could not parse XML returned by %s bugzilla: %s' % (desc, e) @@ -267,7 +272,7 @@ class Bugzilla(callbacks.PrivmsgCommandAndRegexp, plugins.Configurable): def _getbugxml(self, url, desc): try: fh = urllib2.urlopen(url) - except urllib2.UrlError, e: + except urllib2.HTTPError, e: raise IOError, 'Connection to %s bugzilla failed' % desc bugxml = fh.read() fh.close() diff --git a/test/test_Bugzilla.py b/test/test_Bugzilla.py index 12ffe32bb..9189e04c8 100644 --- a/test/test_Bugzilla.py +++ b/test/test_Bugzilla.py @@ -36,6 +36,9 @@ class BugzillaTest(PluginTestCase, PluginDocumentation): def testBugzilla(self): self.assertNotError('bug gcc 5') self.assertNotError('http://gcc.gnu.org/bugzilla/show_bug.cgi?id=5') + self.assertNotError('add xiph http://bugs.xiph.org/ Xiph') + self.assertNotError('bug xiph 413') + self.assertNotError('remove xiph') def testConfigBugzillaSnarfer(self): self.assertNotError('bugzilla config bug-snarfer off')