コード例 #1
0
def test_prepare_command():
    backend = MockIRCBackend(BotCollector())

    result = backend.prepare_command('INFO')
    assert result == 'INFO\r\n'

    result = backend.prepare_command('NICK', 'Sopel')
    assert result == 'NICK Sopel\r\n'
コード例 #2
0
def test_prepare_command_text():
    backend = MockIRCBackend(BotCollector())

    result = backend.prepare_command('PRIVMSG', '#sopel', text='Hello world!')
    assert result == 'PRIVMSG #sopel :Hello world!\r\n'

    max_length = 510 - len('PRIVMSG #sopel :')
    text = '-' * max_length
    expected = 'PRIVMSG #sopel :%s\r\n' % text
    result = backend.prepare_command('PRIVMSG', '#sopel', text=text)
    assert result == expected
コード例 #3
0
def test_prepare_command_text_too_long():
    backend = MockIRCBackend(BotCollector())

    max_length = 510 - len('PRIVMSG #sopel :')
    text = '-' * (max_length + 1)  # going above max length by one
    expected = 'PRIVMSG #sopel :%s\r\n' % text[:max_length]
    result = backend.prepare_command('PRIVMSG', '#sopel', text=text)
    assert result == expected