Пример #1
0
 def _create_msg(self, message, source=None, is_admin=False):
     if not isinstance(message, irc.Message):
         if not source:
             source = "[email protected]"
         message = irc.Message(source, "#test", message)
     message.user.is_admin = is_admin
     return message
Пример #2
0
 def assert_reply(input, output):
     bot._send_msg = mock.MagicMock()
     bot._handle_privmsg(irc.Message('foo!bar@baz', '#chan', input))
     if output:
         bot._send_msg.assert_called_with(output, '#chan')
     else:
         bot._send_msg.assert_not_called()
     bot._send_msg.close()
Пример #3
0
 def assert_reply(input, output):
     bot.send_msg = mock.MagicMock()
     bot._handle_privmsg(irc.Message("foo!bar@baz", "#chan", input))
     if output:
         bot.send_msg.assert_called_with("#chan", output)
     else:
         bot.send_msg.assert_not_called()
     bot.send_msg.close()
Пример #4
0
 def test_commands_and_args_are_parsed(self):
     msg = irc.Message('[email protected]', '#channel', '!foo bar baz')
     cmd = botologist.bot.CommandMessage(msg)
     self.assertEqual('!foo', cmd.command)
     self.assertEqual(['bar', 'baz'], cmd.args)
Пример #5
0
 def test_is_private(self):
     msg = irc.Message("[email protected]", "#chan", "foo bar baz")
     self.assertFalse(msg.is_private)
     msg = irc.Message("[email protected]", "nick", "foo bar baz")
     self.assertTrue(msg.is_private)
Пример #6
0
 def test_init(self):
     msg = irc.Message("[email protected]", "#chan", "foo bar baz")
     self.do_assertions(msg)
Пример #7
0
 def test_is_private(self):
     msg = irc.Message('[email protected]', '#chan', 'foo bar baz')
     self.assertFalse(msg.is_private)
     msg = irc.Message('[email protected]', 'nick', 'foo bar baz')
     self.assertTrue(msg.is_private)
Пример #8
0
 def test_init(self):
     msg = irc.Message('[email protected]', '#chan', 'foo bar baz')
     self.do_assertions(msg)
Пример #9
0
 def test_commands_and_args_are_parsed(self):
     msg = irc.Message("[email protected]", "#channel", "!foo bar baz")
     cmd = botologist.bot.CommandMessage(msg)
     self.assertEqual("!foo", cmd.command)
     self.assertEqual(["bar", "baz"], cmd.args)