mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-17 07:02:58 +01:00
Added more tests
This commit is contained in:
parent
a46ce6b109
commit
1855bafe45
@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
from test import *
|
from test import *
|
||||||
|
|
||||||
|
import ircmsgs
|
||||||
import ircutils
|
import ircutils
|
||||||
|
|
||||||
class FunctionsTestCase(unittest.TestCase):
|
class FunctionsTestCase(unittest.TestCase):
|
||||||
@ -81,3 +82,30 @@ class FunctionsTestCase(unittest.TestCase):
|
|||||||
self.failUnless(ircutils.hostmaskPatternEqual(\
|
self.failUnless(ircutils.hostmaskPatternEqual(\
|
||||||
ircutils.banmask(self.hostmask), self.hostmask))
|
ircutils.banmask(self.hostmask), self.hostmask))
|
||||||
|
|
||||||
|
def testSeparateModes(self):
|
||||||
|
self.assertEqual(ircutils.separateModes(['+ooo', 'x', 'y', 'z']),
|
||||||
|
[('+o', 'x'), ('+o', 'y'), ('+o', 'z')])
|
||||||
|
self.assertEqual(ircutils.separateModes(['+o-o', 'x', 'y']),
|
||||||
|
[('+o', 'x'), ('-o', 'y')])
|
||||||
|
self.assertEqual(ircutils.separateModes(['+s-o', 'x']),
|
||||||
|
[('+s', None), ('-o', 'x')])
|
||||||
|
self.assertEqual(ircutils.separateModes(['+sntl', '100']),
|
||||||
|
[('+s', None),('+n', None),('+t', None),('+l', '100')])
|
||||||
|
|
||||||
|
def testToLower(self):
|
||||||
|
self.assertEqual('jemfinch', ircutils.toLower('jemfinch'))
|
||||||
|
self.assertEqual('{}|^', ircutils.toLower('[]\\~'))
|
||||||
|
|
||||||
|
def testNick(self):
|
||||||
|
nicks = ['jemfinch', 'jemfinch\\[]~']
|
||||||
|
for nick in nicks:
|
||||||
|
self.assertEqual(str(ircutils.nick(nick)), str(nick))
|
||||||
|
self.assertEqual(ircutils.nick(nick), nick)
|
||||||
|
self.assertEqual(ircutils.nick(nick), ircutils.toLower(nick))
|
||||||
|
|
||||||
|
def testReplyTo(self):
|
||||||
|
prefix = 'foo!bar@baz'
|
||||||
|
channel = ircmsgs.privmsg('#foo', 'bar baz', prefix=prefix)
|
||||||
|
private = ircmsgs.privmsg('jemfinch', 'bar baz', prefix=prefix)
|
||||||
|
self.assertEqual(ircutils.replyTo(channel), channel.args[0])
|
||||||
|
self.assertEqual(ircutils.replyTo(private), private.nick)
|
||||||
|
@ -37,6 +37,17 @@ import utils
|
|||||||
class UtilsTest(unittest.TestCase):
|
class UtilsTest(unittest.TestCase):
|
||||||
def testTimeElapsed(self):
|
def testTimeElapsed(self):
|
||||||
self.assertRaises(ValueError, utils.timeElapsed, 0, 0, seconds=False)
|
self.assertRaises(ValueError, utils.timeElapsed, 0, 0, seconds=False)
|
||||||
|
then = 0
|
||||||
|
now = 0
|
||||||
|
for now, expected in [(0, '0 seconds'),
|
||||||
|
(1, '1 second'),
|
||||||
|
(60, '1 minute and 0 seconds'),
|
||||||
|
(61, '1 minute and 1 second'),
|
||||||
|
(62, '1 minute and 2 seconds'),
|
||||||
|
(122, '2 minutes and 2 seconds'),
|
||||||
|
(3722, '1 hour, 2 minutes and 2 seconds'),
|
||||||
|
(7322, '2 hours, 2 minutes and 2 seconds')]:
|
||||||
|
self.assertEqual(utils.timeElapsed(now, then), expected)
|
||||||
|
|
||||||
def testEachSubstring(self):
|
def testEachSubstring(self):
|
||||||
s = 'foobar'
|
s = 'foobar'
|
||||||
|
Loading…
Reference in New Issue
Block a user