def test_channel(self): msg = IrcMessage('[email protected]', 'PRIVMSG', '#bar', 'hello?') self.assertEqual(msg.channel(), '#bar') msg = IrcMessage('[email protected]', 'PRIVMSG', '[email protected]', 'hello?') self.assertEqual(msg.channel(), None)
def test_publish_message(self): msg = IrcMessage('[email protected]', 'PRIVMSG', '#bar', 'hello?') self.vb.publish_message(msg) self.check([]) [recvd_msg] = self.recvd_messages self.assertEqual(recvd_msg, msg)
def test_message(self): msg = IrcMessage('[email protected]', 'PRIVMSG', '#bar', 'hello?') self.assertEqual(msg.sender, 'user') self.assertEqual(msg.command, 'PRIVMSG') self.assertEqual(msg.recipient, '#bar') self.assertEqual(msg.content, 'hello?')
def test_action(self): sender, command, recipient, text = (self.nick, 'ACTION', "#zoo", "waves at zooites") self.vb.action(sender, recipient, text) [recvd_msg] = self.recvd_messages self.assertEqual( recvd_msg, IrcMessage(sender, command, recipient, text, self.vb.nickname))
def test_privmsg(self): sender, command, recipient, text = (self.nick, 'PRIVMSG', "#zoo", "Hello zooites") self.vb.privmsg(sender, recipient, text) [recvd_msg] = self.recvd_messages self.assertEqual( recvd_msg, IrcMessage(sender, command, recipient, text, self.vb.nickname))
def test_inequality(self): msg1 = IrcMessage('[email protected]', 'PRIVMSG', '#bar', 'hello?') self.assertFalse(msg1 == object())
def test_equality(self): msg1 = IrcMessage('[email protected]', 'PRIVMSG', '#bar', 'hello?') msg2 = IrcMessage('[email protected]', 'PRIVMSG', '#bar', 'hello?') self.assertTrue(msg1 == msg2)
def test_addressed_to(self): msg = IrcMessage('[email protected]', 'PRIVMSG', '[email protected]', 'hello?', 'nicktest') self.assertFalse(msg.addressed_to('user')) self.assertTrue(msg.addressed_to('otheruser'))
def test_nick(self): msg = IrcMessage('[email protected]', 'PRIVMSG', '#bar', 'hello?', 'nicktest') self.assertEqual(msg.nickname, 'nicktest')
def test_action(self): msg = IrcMessage('[email protected]', 'ACTION', '#bar', 'hello?') self.assertEqual(msg.command, 'ACTION')
def test_consume_message_action(self): self.vb.consume_message( IrcMessage('[email protected]', 'ACTION', '#bar', 'hello?')) self.check(["PRIVMSG #bar :\x01ACTION hello?\x01"])
def test_consume_message_privmsg(self): self.vb.consume_message( IrcMessage('[email protected]', 'PRIVMSG', '#bar', 'hello?')) self.check(["PRIVMSG #bar :hello?"])