Fixed problem with integer-looking ids in repeat.

This commit is contained in:
Jeremy Fincher 2004-02-13 04:24:44 +00:00
parent af60780619
commit 2d79a470dc
2 changed files with 15 additions and 1 deletions

View File

@ -118,6 +118,11 @@ class Scheduler(callbacks.Privmsg):
except ValueError:
irc.error('Invalid seconds: %r' % seconds)
return
try:
name = int(name)
irc.error('Names must not be an integer.')
except ValueError:
pass
self.events[name] = command
f = self._makeCommandFunction(irc, msg, command)
id = schedule.addPeriodicEvent(f, seconds, name)

View File

@ -31,8 +31,14 @@
from testsupport import *
class MiscTestCase(ChannelPluginTestCase, PluginDocumentation):
import schedule
class SchedulerTestCase(ChannelPluginTestCase):
plugins = ('Scheduler', 'Utilities')
def tearDown(self):
schedule.schedule.reset()
ChannelPluginTestCase.tearDown(self)
def testAddRemove(self):
self.assertRegexp('scheduler list', 'no.*commands')
m = self.assertNotError('scheduler add [seconds 5s] echo foo bar baz')
@ -74,6 +80,9 @@ class MiscTestCase(ChannelPluginTestCase, PluginDocumentation):
self.assertNotError('scheduler remove foo')
self.assertNoResponse(' ', 5)
def testRepeatDisallowsIntegerNames(self):
self.assertError('scheduler repeat 1234 1234 "echo foo bar baz"')
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: