示例#1
0
 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)
示例#2
0
 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)
示例#3
0
 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?')
示例#4
0
 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))
示例#5
0
 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))
示例#6
0
 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)
示例#7
0
 def test_inequality(self):
     msg1 = IrcMessage('[email protected]', 'PRIVMSG', '#bar',
                       'hello?')
     self.assertFalse(msg1 == object())
示例#8
0
 def test_equality(self):
     msg1 = IrcMessage('[email protected]', 'PRIVMSG', '#bar',
                       'hello?')
     msg2 = IrcMessage('[email protected]', 'PRIVMSG', '#bar',
                       'hello?')
     self.assertTrue(msg1 == msg2)
示例#9
0
 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'))
示例#10
0
 def test_nick(self):
     msg = IrcMessage('[email protected]', 'PRIVMSG', '#bar',
                      'hello?', 'nicktest')
     self.assertEqual(msg.nickname, 'nicktest')
示例#11
0
 def test_action(self):
     msg = IrcMessage('[email protected]', 'ACTION', '#bar',
                      'hello?')
     self.assertEqual(msg.command, 'ACTION')
示例#12
0
 def test_consume_message_action(self):
     self.vb.consume_message(
         IrcMessage('[email protected]', 'ACTION', '#bar', 'hello?'))
     self.check(["PRIVMSG #bar :\x01ACTION hello?\x01"])
示例#13
0
 def test_consume_message_privmsg(self):
     self.vb.consume_message(
         IrcMessage('[email protected]', 'PRIVMSG', '#bar',
                    'hello?'))
     self.check(["PRIVMSG #bar :hello?"])
示例#14
0
 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'))