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
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()
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()
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)
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)
def test_init(self): msg = irc.Message("[email protected]", "#chan", "foo bar baz") self.do_assertions(msg)
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)
def test_init(self): msg = irc.Message('[email protected]', '#chan', 'foo bar baz') self.do_assertions(msg)
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)