Scheduler: Use mocking to make tests faster.

40s -> less than 10s.
Also some timeout tweaks that might fix GH-1385.
This commit is contained in:
Valentin Lorentz 2019-11-11 15:06:06 +01:00
parent 1a69a7b892
commit ad6671966c
2 changed files with 25 additions and 13 deletions

View File

@ -8,7 +8,7 @@ install:
script: script:
- echo $TRAVIS_PYTHON_VERSION - echo $TRAVIS_PYTHON_VERSION
- python setup.py install - python setup.py install
- supybot-test test -v --plugins-dir=./plugins/ --no-network --disable-multiprocessing --exclude=./plugins/Scheduler --exclude=./plugins/Filter - supybot-test test -v --plugins-dir=./plugins/ --no-network --disable-multiprocessing
- if [[ "$TRAVIS_PYTHON_VERSION" =~ ^3\.[4-9] ]] ; then python -m irctest irctest.controllers.limnoria; fi - if [[ "$TRAVIS_PYTHON_VERSION" =~ ^3\.[4-9] ]] ; then python -m irctest irctest.controllers.limnoria; fi
notifications: notifications:
email: false email: false

View File

@ -42,8 +42,10 @@ class SchedulerTestCase(ChannelPluginTestCase):
self.assertRegexp('scheduler list', 'no.*commands') self.assertRegexp('scheduler list', 'no.*commands')
m = self.assertNotError('scheduler add 5 echo testAddRemove') m = self.assertNotError('scheduler add 5 echo testAddRemove')
self.assertNotRegexp('scheduler list', 'no.*commands') self.assertNotRegexp('scheduler list', 'no.*commands')
self.assertNoResponse(' ', 3) timeFastForward(2)
self.assertResponse(' ', 'testAddRemove') self.assertNoResponse(' ', timeout=1)
timeFastForward(2)
self.assertResponse(' ', 'testAddRemove', timeout=1)
m = self.assertNotError('scheduler add 5 echo testAddRemove2') m = self.assertNotError('scheduler add 5 echo testAddRemove2')
# Get id. # Get id.
id = None id = None
@ -54,7 +56,8 @@ class SchedulerTestCase(ChannelPluginTestCase):
break break
self.failUnless(id, 'Couldn\'t find id in reply.') self.failUnless(id, 'Couldn\'t find id in reply.')
self.assertNotError('scheduler remove %s' % id) self.assertNotError('scheduler remove %s' % id)
self.assertNoResponse(' ', 5) timeFastForward(5)
self.assertNoResponse(' ', timeout=1)
# Need this test to run first so it has id 0 for its event # Need this test to run first so it has id 0 for its event
def test00RemoveZero(self): def test00RemoveZero(self):
@ -66,25 +69,34 @@ class SchedulerTestCase(ChannelPluginTestCase):
id = s id = s
break break
self.assertNotError('scheduler remove %s' % id) self.assertNotError('scheduler remove %s' % id)
self.assertNoResponse(' ', 5) timeFastForward(5)
self.assertNoResponse(' ', timeout=1)
def testRepeat(self): def testRepeat(self):
self.assertNotError('scheduler repeat repeater 5 echo testRepeat') self.assertNotError('scheduler repeat repeater 5 echo testRepeat')
self.assertResponse(' ', 'testRepeat') timeFastForward(5)
self.assertResponse(' ', 'testRepeat', timeout=1)
self.assertResponse('scheduler list', 'repeater: "echo testRepeat"') self.assertResponse('scheduler list', 'repeater: "echo testRepeat"')
self.assertNoResponse(' ', 3) timeFastForward(3)
self.assertResponse(' ', 'testRepeat') self.assertNoResponse(' ', timeout=1)
timeFastForward(2)
self.assertResponse(' ', 'testRepeat', timeout=1)
self.assertNotError('scheduler remove repeater') self.assertNotError('scheduler remove repeater')
self.assertNotRegexp('scheduler list', 'repeater') self.assertNotRegexp('scheduler list', 'repeater')
self.assertNoResponse(' ', 5) timeFastForward(5)
self.assertNoResponse(' ', timeout=1)
def testRepeatWorksWithNestedCommands(self): def testRepeatWorksWithNestedCommands(self):
self.assertNotError('scheduler repeat foo 5 "echo foo [echo nested]"') self.assertNotError('scheduler repeat foo 5 "echo foo [echo nested]"')
self.assertResponse(' ', 'foo nested') timeFastForward(5)
self.assertNoResponse(' ', 3) self.assertResponse(' ', 'foo nested', timeout=1)
self.assertResponse(' ', 'foo nested') timeFastForward(3)
self.assertNoResponse(' ', timeout=1)
timeFastForward(2)
self.assertResponse(' ', 'foo nested', timeout=1)
self.assertNotError('scheduler remove foo') self.assertNotError('scheduler remove foo')
self.assertNoResponse(' ', 5) timeFastForward(5)
self.assertNoResponse(' ', timeout=1)
def testRepeatDisallowsIntegerNames(self): def testRepeatDisallowsIntegerNames(self):
self.assertError('scheduler repeat 1234 1234 "echo NoIntegerNames"') self.assertError('scheduler repeat 1234 1234 "echo NoIntegerNames"')