Added some more better handling for channel modes.

This commit is contained in:
Jeremy Fincher 2004-02-16 03:44:11 +00:00
parent 67ab9f8ae1
commit bfd5066ec9
2 changed files with 11 additions and 15 deletions

View File

@ -38,7 +38,7 @@ import conf
import irclib import irclib
import ircmsgs import ircmsgs
class IrcMsgQueueTestCase(unittest.TestCase): class IrcMsgQueueTestCase(SupyTestCase):
mode = ircmsgs.op('#foo', 'jemfinch') mode = ircmsgs.op('#foo', 'jemfinch')
msg = ircmsgs.privmsg('#foo', 'hey, you') msg = ircmsgs.privmsg('#foo', 'hey, you')
msgs = [ircmsgs.privmsg('#foo', str(i)) for i in range(10)] msgs = [ircmsgs.privmsg('#foo', str(i)) for i in range(10)]
@ -159,7 +159,7 @@ class IrcMsgQueueTestCase(unittest.TestCase):
self.assertEqual(self.msg, q.dequeue()) self.assertEqual(self.msg, q.dequeue())
class ChannelStateTestCase(unittest.TestCase): class ChannelStateTestCase(SupyTestCase):
def testPickleCopy(self): def testPickleCopy(self):
c = irclib.ChannelState() c = irclib.ChannelState()
self.assertEqual(pickle.loads(pickle.dumps(c)), c) self.assertEqual(pickle.loads(pickle.dumps(c)), c)
@ -202,7 +202,7 @@ class ChannelStateTestCase(unittest.TestCase):
self.failIf('quuz' in c.voices) self.failIf('quuz' in c.voices)
class IrcStateTestCase(unittest.TestCase): class IrcStateTestCase(SupyTestCase):
class FakeIrc: class FakeIrc:
nick = 'nick' nick = 'nick'
prefix = 'nick!user@host' prefix = 'nick!user@host'
@ -299,14 +299,8 @@ class IrcStateTestCase(unittest.TestCase):
st = irclib.IrcState() st = irclib.IrcState()
self.assert_(st.addMsg(self.irc, ircmsgs.IrcMsg('MODE foo +i')) or 1) self.assert_(st.addMsg(self.irc, ircmsgs.IrcMsg('MODE foo +i')) or 1)
"""
def testChannels(self):
channel =
state = irclib.IrcState()
state.addMsg(self.irc, ircmsgs.join('#foo'))
"""
class IrcTestCase(unittest.TestCase): class IrcTestCase(SupyTestCase):
def setUp(self): def setUp(self):
self.irc = irclib.Irc('nick') self.irc = irclib.Irc('nick')
_ = self.irc.takeMsg() # NICK _ = self.irc.takeMsg() # NICK
@ -317,6 +311,8 @@ class IrcTestCase(unittest.TestCase):
self.assertEqual(ircmsgs.pong('123'), self.irc.takeMsg()) self.assertEqual(ircmsgs.pong('123'), self.irc.takeMsg())
def test433Response(self): def test433Response(self):
# This is necessary; it won't change nick if irc.originalName==irc.nick
self.irc.nick = 'somethingElse'
self.irc.feedMsg(ircmsgs.IrcMsg('433 * %s :Nickname already in use.' %\ self.irc.feedMsg(ircmsgs.IrcMsg('433 * %s :Nickname already in use.' %\
self.irc.nick)) self.irc.nick))
msg = self.irc.takeMsg() msg = self.irc.takeMsg()
@ -361,7 +357,7 @@ class IrcTestCase(unittest.TestCase):
self.assertEqual(list(self.irc.state.history), [msg1, msg2]) self.assertEqual(list(self.irc.state.history), [msg1, msg2])
class IrcCallbackTestCase(unittest.TestCase): class IrcCallbackTestCase(SupyTestCase):
class FakeIrc: class FakeIrc:
pass pass
irc = FakeIrc() irc = FakeIrc()

View File

@ -38,7 +38,7 @@ import random
import ircmsgs import ircmsgs
import ircutils import ircutils
class FunctionsTestCase(unittest.TestCase): class FunctionsTestCase(SupyTestCase):
hostmask = 'foo!bar@baz' hostmask = 'foo!bar@baz'
def testHostmaskPatternEqual(self): def testHostmaskPatternEqual(self):
for msg in msgs: for msg in msgs:
@ -193,7 +193,7 @@ class FunctionsTestCase(unittest.TestCase):
self.assertEqual(ip, ircutils.unDccIP(ircutils.dccIP(ip))) self.assertEqual(ip, ircutils.unDccIP(ircutils.dccIP(ip)))
class IrcDictTestCase(unittest.TestCase): class IrcDictTestCase(SupyTestCase):
def test(self): def test(self):
d = ircutils.IrcDict() d = ircutils.IrcDict()
d['#FOO'] = 'bar' d['#FOO'] = 'bar'
@ -243,7 +243,7 @@ class IrcDictTestCase(unittest.TestCase):
self.failUnless(d == copy.copy(d)) self.failUnless(d == copy.copy(d))
self.failUnless(d == copy.deepcopy(d)) self.failUnless(d == copy.deepcopy(d))
class IrcSetTestCase(unittest.TestCase): class IrcSetTestCase(SupyTestCase):
def test(self): def test(self):
s = ircutils.IrcSet() s = ircutils.IrcSet()
s.add('foo') s.add('foo')
@ -275,7 +275,7 @@ class IrcSetTestCase(unittest.TestCase):
class IrcStringTestCase(unittest.TestCase): class IrcStringTestCase(SupyTestCase):
def testEquality(self): def testEquality(self):
self.assertEqual('#foo', ircutils.IrcString('#foo')) self.assertEqual('#foo', ircutils.IrcString('#foo'))
self.assertEqual('#foo', ircutils.IrcString('#FOO')) self.assertEqual('#foo', ircutils.IrcString('#FOO'))