Change project registry value to defaultProject.

This commit is contained in:
James Vega 2004-02-09 04:02:21 +00:00
parent abd4eeddf0
commit 2a586bdb78
2 changed files with 76 additions and 79 deletions

View File

@ -72,7 +72,7 @@ def configure(advanced):
if yn('Do you want to specify a default project?'): if yn('Do you want to specify a default project?'):
project = anything('Project name:') project = anything('Project name:')
if project: if project:
conf.supybot.plugins.Sourceforge.project.set(project) conf.supybot.plugins.Sourceforge.defaultProject.set(project)
output("""Sourceforge is quite the word to type, and it may get annoying output("""Sourceforge is quite the word to type, and it may get annoying
typing it all the time because Supybot makes you use the plugin typing it all the time because Supybot makes you use the plugin
@ -101,7 +101,7 @@ conf.registerPlugin('Sourceforge')
conf.registerChannelValue(conf.supybot.plugins.Sourceforge, 'trackerSnarfer', conf.registerChannelValue(conf.supybot.plugins.Sourceforge, 'trackerSnarfer',
registry.Boolean(False, """Determines whether the bot will reply to SF.net registry.Boolean(False, """Determines whether the bot will reply to SF.net
Tracker URLs in the channel with a nice summary of the tracker item.""")) Tracker URLs in the channel with a nice summary of the tracker item."""))
conf.registerChannelValue(conf.supybot.plugins.Sourceforge, 'project', conf.registerChannelValue(conf.supybot.plugins.Sourceforge, 'defaultProject',
registry.String('', """Sets the default project to use in the case that no registry.String('', """Sets the default project to use in the case that no
explicit project is given.""")) explicit project is given."""))
@ -204,7 +204,7 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp):
except ValueError: except ValueError:
pass pass
if not project: if not project:
project = self.registryValue('project', msg.args[0]) project = self.registryValue('defaultProject', msg.args[0])
if not project: if not project:
raise callbacks.ArgumentError raise callbacks.ArgumentError
try: try:
@ -224,7 +224,7 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp):
default project is set. default project is set.
""" """
project = privmsgs.getArgs(args, required=0, optional=1) project = privmsgs.getArgs(args, required=0, optional=1)
project = project or self.registryValue('project', msg.args[0]) project = project or self.registryValue('defaultProject', msg.args[0])
if not project: if not project:
raise callbacks.ArgumentError raise callbacks.ArgumentError
text = webutils.getUrl(''.join([self._projectURL, project])) text = webutils.getUrl(''.join([self._projectURL, project]))
@ -255,7 +255,7 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp):
irc.error('"%s" is not a proper bugnumber.' % project) irc.error('"%s" is not a proper bugnumber.' % project)
return return
bugnum = project bugnum = project
project = self.registryValue('project', msg.args[0]) project = self.registryValue('defaultProject', msg.args[0])
if not project: if not project:
raise callbacks.ArgumentError raise callbacks.ArgumentError
try: try:
@ -290,7 +290,7 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp):
except ValueError: except ValueError:
pass pass
if not project: if not project:
project = self.registryValue('project', msg.args[0]) project = self.registryValue('defaultProject', msg.args[0])
if not project: if not project:
raise callbacks.ArgumentError raise callbacks.ArgumentError
try: try:
@ -309,7 +309,7 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp):
default project is set. default project is set.
""" """
project = privmsgs.getArgs(args, required=0, optional=1) project = privmsgs.getArgs(args, required=0, optional=1)
project = project or self.registryValue('project', msg.args[0]) project = project or self.registryValue('defaultProject', msg.args[0])
if not project: if not project:
raise callbacks.ArgumentError raise callbacks.ArgumentError
text = webutils.getUrl(''.join([self._projectURL, project])) text = webutils.getUrl(''.join([self._projectURL, project]))
@ -340,7 +340,7 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp):
irc.error('"%s" is not a proper rfenumber.' % project) irc.error('"%s" is not a proper rfenumber.' % project)
return return
rfenum = project rfenum = project
project = self.registryValue('project', msg.args[0]) project = self.registryValue('defaultProject', msg.args[0])
if not project: if not project:
raise callbacks.ArgumentError raise callbacks.ArgumentError
try: try:

View File

@ -85,28 +85,17 @@ if network:
n = re.search('#(\d+)', m.args[1]).group(1) n = re.search('#(\d+)', m.args[1]).group(1)
self.assertNotError('rfe --open gaim %s' % n) self.assertNotError('rfe --open gaim %s' % n)
"""
Just assume pending works since we're not 99% guaranteed to have a
project that has pending bugs/rfes like we do with the others.
def testPending(self):
m = self.getMsg('bugs --pending gaim')
self.failUnless(m, 'No response from Sourceforge.')
n = re.search('#(\d+)', m.args[1]).group(1)
self.assertNotError('bug --pending gaim %s' % n)
m = self.getMsg('rfes --pending gaim')
self.failUnless(m, 'No response from Sourceforge.')
n = re.search('#(\d+)', m.args[1]).group(1)
self.assertNotError('rfe --pending gaim %s' % n)
"""
def testBugs(self): def testBugs(self):
self.assertHelp('bugs') self.assertHelp('bugs')
conf.supybot.plugins.Sourceforge.project.set('supybot')
self.assertNotError('bugs')
self.assertRegexp('bugs alkjfi83fa8', 'find the Bugs')
self.assertNotError('bugs gaim')
conf.supybot.plugins.Sourceforge.project.set('')
self.assertRegexp('bugs 83423', 'Use the bug command') self.assertRegexp('bugs 83423', 'Use the bug command')
try:
original = conf.supybot.plugins.Sourceforge.defaultProject()
conf.supybot.plugins.Sourceforge.defaultProject.set('supybot')
self.assertRegexp('bugs alkjfi83fa8', 'find the Bugs')
self.assertNotError('bugs gaim')
self.assertNotError('bugs')
finally:
conf.supybot.plugins.Sourceforge.defaultProject.set(original)
def testRfe(self): def testRfe(self):
m = self.getMsg('rfes gaim') m = self.getMsg('rfes gaim')
@ -118,18 +107,21 @@ if network:
def testRfes(self): def testRfes(self):
self.assertHelp('rfes') self.assertHelp('rfes')
conf.supybot.plugins.Sourceforge.project.set('gaim')
self.assertNotError('rfes')
self.assertRegexp('rfes alkjfi83hfa8', 'find the RFEs')
self.assertNotError('rfes gaim')
conf.supybot.plugins.Sourceforge.project.set('')
self.assertRegexp('rfes 83423', 'Use the rfe command') self.assertRegexp('rfes 83423', 'Use the rfe command')
try:
original = conf.supybot.plugins.Sourceforge.defaultProject()
conf.supybot.plugins.Sourceforge.defaultProject.set('gaim')
self.assertNotError('rfes')
self.assertRegexp('rfes alkjfi83hfa8', 'find the RFEs')
self.assertNotError('rfes gaim')
finally:
conf.supybot.plugins.Sourceforge.defaultProject.set(original)
def testDefaultproject(self): def testDefaultproject(self):
self.assertHelp('bugs') self.assertHelp('bugs')
try: try:
original = conf.supybot.plugins.Sourceforge.project() original = conf.supybot.plugins.Sourceforge.defaultProject()
conf.supybot.plugins.Sourceforge.project.set('supybot') conf.supybot.plugins.Sourceforge.defaultProject.set('supybot')
self.assertNotError('bugs') self.assertNotError('bugs')
m = self.getMsg('bugs') m = self.getMsg('bugs')
n = re.search('#(\d+)', m.args[1]).group(1) n = re.search('#(\d+)', m.args[1]).group(1)
@ -137,54 +129,59 @@ if network:
# This should have the same effect as calling 'bug supybot %s' # This should have the same effect as calling 'bug supybot %s'
self.assertNotError('bug %s' % n) self.assertNotError('bug %s' % n)
finally: finally:
conf.supybot.plugins.Sourceforge.project.set(original) conf.supybot.plugins.Sourceforge.defaultProject.set(original)
def testSnarfer(self): def testSnarfer(self):
s = r'.*Status.*: \w+' s = r'.*Status.*: \w+'
conf.supybot.plugins.Sourceforge.trackerSnarfer.setValue(True) try:
self.assertRegexp('http://sourceforge.net/tracker/index.php?' original = conf.supybot.plugins.Sourceforge.trackerSnarfer()
'func=detail&aid=589953&group_id=58965&' conf.supybot.plugins.Sourceforge.trackerSnarfer.setValue(True)
'atid=489447', self.assertRegexp('http://sourceforge.net/tracker/index.php?'
s) 'func=detail&aid=589953&group_id=58965&'
self.assertRegexp('http://sourceforge.net/tracker/index.php?' 'atid=489447',
'func=detail&aid=712761&group_id=58965&' s)
'atid=489450', self.assertRegexp('http://sourceforge.net/tracker/index.php?'
s) 'func=detail&aid=712761&group_id=58965&'
self.assertRegexp('http://sourceforge.net/tracker/index.php?' 'atid=489450',
'func=detail&aid=540223&group_id=235&' s)
'atid=300235', self.assertRegexp('http://sourceforge.net/tracker/index.php?'
s) 'func=detail&aid=540223&group_id=235&'
self.assertRegexp('http://sourceforge.net/tracker/index.php?' 'atid=300235',
'func=detail&aid=561547&group_id=235&' s)
'atid=200235', self.assertRegexp('http://sourceforge.net/tracker/index.php?'
s) 'func=detail&aid=561547&group_id=235&'
self.assertRegexp('http://sourceforge.net/tracker/index.php?' 'atid=200235',
'func=detail&aid=400942&group_id=235&' s)
'atid=390395', self.assertRegexp('http://sourceforge.net/tracker/index.php?'
s) 'func=detail&aid=400942&group_id=235&'
'atid=390395',
# test that it works without index.php s)
self.assertNotError('http://sourceforge.net/tracker/?'
'func=detail&aid=540223&group_id=235&' # test that it works without index.php
'atid=300235') self.assertNotError('http://sourceforge.net/tracker/?'
# test that it works with www 'func=detail&aid=540223&group_id=235&'
self.assertNotError('http://www.sourceforge.net/tracker/index.php?' 'atid=300235')
'func=detail&aid=540223&group_id=235&' # test that it works with www
'atid=300235') self.assertNotError('http://www.sourceforge.net/tracker/index.php?'
# test that it works with www and without index.php 'func=detail&aid=540223&group_id=235&'
self.assertNotError('http://www.sourceforge.net/tracker/?' 'atid=300235')
'func=detail&aid=540223&group_id=235&' # test that it works with www and without index.php
'atid=300235') self.assertNotError('http://www.sourceforge.net/tracker/?'
# test that it works with sf.net 'func=detail&aid=540223&group_id=235&'
self.assertNotError('http://sf.net/tracker/?' 'atid=300235')
'func=detail&aid=540223&group_id=235&' # test that it works with sf.net
'atid=300235') self.assertNotError('http://sf.net/tracker/?'
# test that it works 'func=detail&aid=540223&group_id=235&'
self.assertNotError('https://sourceforge.net/tracker/?' 'atid=300235')
'func=detail&atid=105470&aid=827260&' # test that it works
'group_id=5470') self.assertNotError('https://sourceforge.net/tracker/?'
self.assertNoResponse('https://sourceforge.net/tracker/?' 'func=detail&atid=105470&aid=827260&'
'group_id=58965&atid=489447') 'group_id=5470')
self.assertNoResponse('https://sourceforge.net/tracker/?'
'group_id=58965&atid=489447')
finally:
conf.supybot.plugins.Sourceforge.trackerSnarfer.setValue(
original)
def testTotal(self): def testTotal(self):
self.assertRegexp('totalbugs gaim', r'\d+ open / \d+ total') self.assertRegexp('totalbugs gaim', r'\d+ open / \d+ total')