def test_send_command_args_text_safe(): bot = BotCollector() backend = MockIRCBackend(bot) backend.send_command('PRIVMSG', '#sopel', text='Unsafe\ntext') expected = 'PRIVMSG #sopel :Unsafetext\r\n' assert backend.message_sent == [expected.encode('utf-8')] assert bot.message_sent == [expected]
def test_send_command_args_text(): bot = BotCollector() backend = MockIRCBackend(bot) backend.send_command('KICK', 'Exirel', text='Too many PRs!') expected = 'KICK Exirel :Too many PRs!\r\n' assert backend.message_sent == [expected.encode('utf-8')] assert bot.message_sent == [expected]
def test_send_command_text(): bot = BotCollector() backend = MockIRCBackend(bot) backend.send_command('HELP', text='?') expected = 'HELP :?\r\n' assert backend.message_sent == [expected.encode('utf-8')] assert bot.message_sent == [expected]
def test_send_command_args(): bot = BotCollector() backend = MockIRCBackend(bot) backend.send_command('NICK', 'Sopel') expected = 'NICK Sopel\r\n' assert backend.message_sent == [expected.encode('utf-8')] assert bot.message_sent == [expected]
def test_send_command(): bot = BotCollector() backend = MockIRCBackend(bot) backend.send_command('INFO') expected = 'INFO\r\n' assert backend.message_sent == [expected.encode('utf-8')] assert bot.message_sent == [expected]
def test_send_command_args_text_many(): bot = BotCollector() backend = MockIRCBackend(bot) backend.send_command('PRIVMSG', '#sopel', text='Hello here!') backend.send_command('PRIVMSG', '#sopel', text='I have a question.') expected_1 = 'PRIVMSG #sopel :Hello here!\r\n' expected_2 = 'PRIVMSG #sopel :I have a question.\r\n' assert backend.message_sent == [ expected_1.encode('utf-8'), expected_2.encode('utf-8') ] assert bot.message_sent == [expected_1, expected_2]