mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-23 10:34:19 +01:00
Added more tests.
This commit is contained in:
parent
bef6533ed4
commit
3f764eab0f
@ -32,8 +32,10 @@
|
|||||||
from test import *
|
from test import *
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
import pickle
|
||||||
|
|
||||||
import conf
|
import conf
|
||||||
|
import debug
|
||||||
import irclib
|
import irclib
|
||||||
import ircmsgs
|
import ircmsgs
|
||||||
|
|
||||||
@ -97,6 +99,40 @@ class IrcMsgQueueTestCase(unittest.TestCase):
|
|||||||
self.failIf(q)
|
self.failIf(q)
|
||||||
|
|
||||||
|
|
||||||
|
class ChannelTestCase(unittest.TestCase):
|
||||||
|
def testPickleCopy(self):
|
||||||
|
c = irclib.Channel()
|
||||||
|
for name in c.__slots__:
|
||||||
|
debug.printf(getattr(c, name))
|
||||||
|
c1 = pickle.loads(pickle.dumps(c))
|
||||||
|
for name in c1.__slots__:
|
||||||
|
debug.printf(getattr(c1, name))
|
||||||
|
self.assertEqual(pickle.loads(pickle.dumps(c)), c)
|
||||||
|
|
||||||
|
def testAddUser(self):
|
||||||
|
c = irclib.Channel()
|
||||||
|
c.addUser('foo')
|
||||||
|
self.failUnless('foo' in c.users)
|
||||||
|
self.failIf('foo' in c.ops)
|
||||||
|
self.failIf('foo' in c.voices)
|
||||||
|
self.failIf('foo' in c.halfops)
|
||||||
|
c.addUser('+bar')
|
||||||
|
self.failUnless('bar' in c.users)
|
||||||
|
self.failUnless('bar' in c.voices)
|
||||||
|
self.failIf('bar' in c.ops)
|
||||||
|
self.failIf('bar' in c.halfops)
|
||||||
|
c.addUser('%baz')
|
||||||
|
self.failUnless('baz' in c.users)
|
||||||
|
self.failUnless('baz' in c.halfops)
|
||||||
|
self.failIf('baz' in c.voices)
|
||||||
|
self.failIf('baz' in c.ops)
|
||||||
|
c.addUser('@quuz')
|
||||||
|
self.failUnless('quuz' in c.users)
|
||||||
|
self.failUnless('quuz' in c.ops)
|
||||||
|
self.failIf('quuz' in c.halfops)
|
||||||
|
self.failIf('quuz' in c.voices)
|
||||||
|
|
||||||
|
|
||||||
class IrcStateTestCase(unittest.TestCase):
|
class IrcStateTestCase(unittest.TestCase):
|
||||||
class FakeIrc:
|
class FakeIrc:
|
||||||
nick = 'nick'
|
nick = 'nick'
|
||||||
@ -115,6 +151,29 @@ class IrcStateTestCase(unittest.TestCase):
|
|||||||
self.assertEqual(list(state.history), msgs[len(msgs)-conf.maxHistory:])
|
self.assertEqual(list(state.history), msgs[len(msgs)-conf.maxHistory:])
|
||||||
conf.maxHistory = oldconfmaxhistory
|
conf.maxHistory = oldconfmaxhistory
|
||||||
|
|
||||||
|
def testPickleCopy(self):
|
||||||
|
state = irclib.IrcState()
|
||||||
|
self.assertEqual(state, pickle.loads(pickle.dumps(state)))
|
||||||
|
for msg in msgs:
|
||||||
|
try:
|
||||||
|
state.addMsg(self.irc, msg)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
self.assertEqual(state, pickle.loads(pickle.dumps(state)))
|
||||||
|
|
||||||
|
def testEq(self):
|
||||||
|
state1 = irclib.IrcState()
|
||||||
|
state2 = irclib.IrcState()
|
||||||
|
self.assertEqual(state1, state2)
|
||||||
|
for msg in msgs:
|
||||||
|
try:
|
||||||
|
state1.addMsg(self.irc, msg)
|
||||||
|
state2.addMsg(self.irc, msg)
|
||||||
|
self.assertEqual(state1, state2)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
def testChannels(self):
|
def testChannels(self):
|
||||||
channel =
|
channel =
|
||||||
|
Loading…
Reference in New Issue
Block a user