Exemplo n.º 1
0
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]
Exemplo n.º 2
0
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]
Exemplo n.º 3
0
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]
Exemplo n.º 4
0
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]
Exemplo n.º 5
0
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]
Exemplo n.º 6
0
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]