From 2d79a470dc381dc7ebde9a039fdce6ee0624295c Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Fri, 13 Feb 2004 04:24:44 +0000 Subject: [PATCH] Fixed problem with integer-looking ids in repeat. --- plugins/Scheduler.py | 5 +++++ test/test_Scheduler.py | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/plugins/Scheduler.py b/plugins/Scheduler.py index 1d310e228..8b0ecbcbc 100644 --- a/plugins/Scheduler.py +++ b/plugins/Scheduler.py @@ -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) diff --git a/test/test_Scheduler.py b/test/test_Scheduler.py index 2d0b50b91..708e87fcf 100644 --- a/test/test_Scheduler.py +++ b/test/test_Scheduler.py @@ -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: