mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-30 06:49:24 +01:00
Fixed tests.
This commit is contained in:
parent
c68a8015a0
commit
87f4d36d6f
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
###
|
###
|
||||||
# Copyright (c) 2002, Jeremiah Fincher
|
# Copyright (c) 2003, Jeremiah Fincher
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
@ -121,6 +121,7 @@ class Scheduler(callbacks.Privmsg):
|
|||||||
try:
|
try:
|
||||||
name = int(name)
|
name = int(name)
|
||||||
irc.error('Names must not be an integer.')
|
irc.error('Names must not be an integer.')
|
||||||
|
return
|
||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
self.events[name] = command
|
self.events[name] = command
|
||||||
|
@ -69,7 +69,6 @@ class Schedule(drivers.IrcDriver):
|
|||||||
def reset(self):
|
def reset(self):
|
||||||
self.events.clear()
|
self.events.clear()
|
||||||
self.schedule[:] = []
|
self.schedule[:] = []
|
||||||
self.counter = 0
|
|
||||||
|
|
||||||
def addEvent(self, f, t, name=None):
|
def addEvent(self, f, t, name=None):
|
||||||
"""Schedules an event f to run at time t.
|
"""Schedules an event f to run at time t.
|
||||||
|
@ -41,11 +41,11 @@ class SchedulerTestCase(ChannelPluginTestCase):
|
|||||||
|
|
||||||
def testAddRemove(self):
|
def testAddRemove(self):
|
||||||
self.assertRegexp('scheduler list', 'no.*commands')
|
self.assertRegexp('scheduler list', 'no.*commands')
|
||||||
m = self.assertNotError('scheduler add [seconds 5s] echo foo bar baz')
|
m = self.assertNotError('scheduler add 5 echo testAddRemove')
|
||||||
self.assertNotRegexp('scheduler list', 'no.*commands')
|
self.assertNotRegexp('scheduler list', 'no.*commands')
|
||||||
self.assertNoResponse(' ', 4)
|
self.assertNoResponse(' ', 3)
|
||||||
self.assertResponse(' ', 'foo bar baz')
|
self.assertResponse(' ', 'testAddRemove')
|
||||||
m = self.assertNotError('scheduler add 5 echo xyzzy')
|
m = self.assertNotError('scheduler add 5 echo testAddRemove2')
|
||||||
# Get id.
|
# Get id.
|
||||||
id = None
|
id = None
|
||||||
for s in m.args[1].split():
|
for s in m.args[1].split():
|
||||||
@ -58,30 +58,25 @@ class SchedulerTestCase(ChannelPluginTestCase):
|
|||||||
self.assertNoResponse(' ', 5)
|
self.assertNoResponse(' ', 5)
|
||||||
|
|
||||||
def testRepeat(self):
|
def testRepeat(self):
|
||||||
self.assertNotError('scheduler repeat repeater 5 echo foo bar baz')
|
self.assertNotError('scheduler repeat repeater 5 echo testRepeat')
|
||||||
self.assertNotError(' ') # First response.
|
self.assertResponse(' ', 'testRepeat')
|
||||||
self.assertResponse('scheduler list', 'repeater: "echo foo bar baz"')
|
self.assertResponse('scheduler list', 'repeater: "echo testRepeat"')
|
||||||
self.assertNoResponse(' ', 4)
|
self.assertNoResponse(' ', 3)
|
||||||
self.assertResponse(' ', 'foo bar baz')
|
self.assertResponse(' ', 'testRepeat')
|
||||||
self.assertResponse('scheduler list', 'repeater: "echo foo bar baz"')
|
|
||||||
self.assertNoResponse(' ', 4)
|
|
||||||
self.assertResponse(' ', 'foo bar baz')
|
|
||||||
self.assertNotError('scheduler remove repeater')
|
self.assertNotError('scheduler remove repeater')
|
||||||
self.assertNotRegexp('scheduler list', 'repeater')
|
self.assertNotRegexp('scheduler list', 'repeater')
|
||||||
self.assertNoResponse(' ', 5)
|
self.assertNoResponse(' ', 5)
|
||||||
|
|
||||||
def testRepeatWorksWithNestedCommands(self):
|
def testRepeatWorksWithNestedCommands(self):
|
||||||
self.assertNotError('scheduler repeat foo 5 "echo foo [echo bar]"')
|
self.assertNotError('scheduler repeat foo 5 "echo foo [echo nested]"')
|
||||||
self.assertNotError(' ') # First response.
|
self.assertResponse(' ', 'foo nested')
|
||||||
self.assertNoResponse(' ', 4)
|
self.assertNoResponse(' ', 3)
|
||||||
self.assertResponse(' ', 'foo bar')
|
self.assertResponse(' ', 'foo nested')
|
||||||
self.assertNoResponse(' ', 4)
|
|
||||||
self.assertResponse(' ', 'foo bar')
|
|
||||||
self.assertNotError('scheduler remove foo')
|
self.assertNotError('scheduler remove foo')
|
||||||
self.assertNoResponse(' ', 5)
|
self.assertNoResponse(' ', 5)
|
||||||
|
|
||||||
def testRepeatDisallowsIntegerNames(self):
|
def testRepeatDisallowsIntegerNames(self):
|
||||||
self.assertError('scheduler repeat 1234 1234 "echo foo bar baz"')
|
self.assertError('scheduler repeat 1234 1234 "echo NoIntegerNames"')
|
||||||
|
|
||||||
|
|
||||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
||||||
|
Loading…
Reference in New Issue
Block a user