예제 #1
0
def test_respond(msg_t):
    """Test if BaseResponder.respond sends messages to proper targets."""
    params = (
        ('#channel :test message', '#channel', False),
        ('bot_nick :test message', 'nick', False),
        ('#channel :test message', 'nick', True),
        ('bot_nick :test message', 'nick', True),
    )
    re = BaseResponder(Config())

    for text, target, pm in params:
        msg_t.reset()
        msg = make_message(text)
        re.respond(msg, 'response', pm=pm)
        assert msg_t.msg.params[0] == target
예제 #2
0
def test_respond(msg_t):
    """Test if BaseResponder.respond sends messages to proper targets."""
    params = (
        ('#channel :test message', '#channel', False),
        ('bot_nick :test message', 'nick', False),
        ('#channel :test message', 'nick', True),
        ('bot_nick :test message', 'nick', True),
    )
    re = BaseResponder(Config())

    for text, target, pm in params:
        msg_t.reset()
        msg = make_message(text)
        re.respond(msg, 'response', pm=pm)
        assert msg_t.msg.params[0] == target
예제 #3
0
def test_help(msg_t):
    """Test help command. Only Meta module should respond to that command
    without any parameters."""
    msg = make_message('#channel :.help')

    re = BaseResponder(Config())
    message_in.send(None, msg=msg)

    assert not msg_t.msg
예제 #4
0
def test_unsubscribe_from_all(cl):
    r = BaseResponder(Config())

    assert signals.message_in.receivers
    assert signals.admin_message_in.receivers

    signals.unsubscribe_from_all(r)

    assert not signals.message_in.receivers
    assert not signals.admin_message_in.receivers
예제 #5
0
def test_is_command():
    re = BaseResponder(Config())

    msg = make_message('#channel :.test')
    assert re.is_command(msg)

    msg = make_message('#channel :.test arg1 arg2')
    assert re.is_command(msg)

    msg = make_message('#channel :.test arg1 arg2')
    assert re.is_command(msg, 'test')

    msg = make_message('#channel :.testing arg1 arg2')
    assert re.is_command(msg, 'testing')
    assert not re.is_command(msg, 'test')

    msg = make_message('#channel :.testing')
    assert re.is_command(msg, 'testing')
    assert not re.is_command(msg, 'test')

    msg = make_message('#channel :.')
    assert not re.is_command(msg, 'test')

    msg = make_message('#channel ::test')
    assert re.is_command(msg, 'test', ':')
    assert re.is_command(msg, 'test', command_prefix=':')
    assert not re.is_command(msg, 'test')

    msg = make_message('#channel : ')
    assert not re.is_command(msg, 'test')
예제 #6
0
def test_is_command():
    re = BaseResponder(Config())

    msg = make_message('#channel :.test')
    assert re.is_command(msg)

    msg = make_message('#channel :.test arg1 arg2')
    assert re.is_command(msg)

    msg = make_message('#channel :.test arg1 arg2')
    assert re.is_command(msg, 'test')

    msg = make_message('#channel :.testing arg1 arg2')
    assert re.is_command(msg, 'testing')
    assert not re.is_command(msg, 'test')

    msg = make_message('#channel :.testing')
    assert re.is_command(msg, 'testing')
    assert not re.is_command(msg, 'test')

    msg = make_message('#channel :.')
    assert not re.is_command(msg, 'test')

    msg = make_message('#channel ::test')
    assert re.is_command(msg, 'test', ':')
    assert re.is_command(msg, 'test', command_prefix=':')
    assert not re.is_command(msg, 'test')