Misc: rewrite @more tests to fully check the output.

This uncovered a few bugs; next commits will fix them.
This commit is contained in:
Valentin Lorentz 2020-04-11 16:06:00 +02:00
parent 37a7029618
commit f19079c75e

View File

@ -209,21 +209,30 @@ class MiscTestCase(ChannelPluginTestCase):
nickConfig.setValue(orig) nickConfig.setValue(orig)
def testMore(self): def testMore(self):
self.assertRegexp('echo %s' % ('abc'*400), 'more') self.assertResponse('echo %s' % ('abc '*400),
self.assertRegexp('more', 'more') 'abc '*112 + ' \x02(3 more messages)\x02')
self.assertNotRegexp('more', 'more') self.assertResponse('more',
'abc '*112 + ' \x02(2 more messages)\x0f')
self.assertResponse('more',
'abc '*112 + ' \x02(1 more message)\x0f')
self.assertResponse('more',
' '.join(['abc']*(400-112*3)))
self.assertResponse('more',
"Error: That's all, there is no more.")
def testMoreMores(self):
with conf.supybot.plugins.Misc.mores.context(2): with conf.supybot.plugins.Misc.mores.context(2):
self.assertRegexp('echo %s' % ('abc'*700), 'more') self.assertResponse('echo %s' % ('abc '*400),
'abc '*112 + ' \x02(3 more messages)\x02')
self.assertNotRegexp('more', 'more') self.assertResponse('more',
'abc '*112)
m = self.irc.takeMsg() m = self.irc.takeMsg()
self.assertIsNot(m, None) self.assertIsNot(m, None)
self.assertIn('more', m.args[1]) self.assertEqual(
m.args[1],
self.assertNotRegexp('more', 'more') self.nick + ': ' + 'abc '*112 + ' \x02(1 more message)\x0f')
m = self.irc.takeMsg() self.assertResponse('more',
self.assertIsNot(m, None) "Error: That's all, there is no more.")
self.assertNotIn('more', m.args[1])
def testClearMores(self): def testClearMores(self):
self.assertRegexp('echo %s' % ('abc'*700), 'more') self.assertRegexp('echo %s' % ('abc'*700), 'more')