def test_admin_dispatching():
    from botnet.modules.builtin.admin import Admin
    from modules.builtin.test_admin import admin_make_message, data4, send_data

    def make_admin_config(command_prefix='.'):
        config = {
            'module_config': {
                'botnet': {
                    'admin': {
                        'admins': ['nick4']
                    }
                }
            }
        }
        config = Config(config)
        return config

    admin_config = make_admin_config()

    t = Tester(Config())
    ad = Admin(admin_config)

    msg = make_privmsg('#channel :.test')
    message_in.send(None, msg=msg)
    assert t.launched_main
    assert t.launched_command
    assert t.launched_priv
    assert not t.launched_admin_command
    assert not t.launched_admin_priv

    msg = admin_make_message('nick4', '.test')
    message_in.send(None, msg=msg)
    send_data(data4)
    assert t.launched_admin_command
    assert t.launched_admin_priv
예제 #2
0
def test_reload_tv_with_admin(cl, msg_l, make_privmsg, rec_msg):
    """Load, send, unload, send, load, send."""
    from botnet.manager import Manager
    from modules.builtin.test_admin import admin_make_message, data4, send_data

    msg = make_privmsg('.next_episode a')

    manager = Manager()
    manager.config = make_admin_config()
    manager.load_module_by_name('admin')

    # load
    amsg = admin_make_message('nick4', ':.module_load tv')
    rec_msg(amsg)
    send_data(data4)
    assert len(msg_l.msgs) == 2  # WHOIS, loaded module

    # send
    rec_msg(msg)
    assert len(msg_l.msgs) == 3  # response

    # unload
    amsg = admin_make_message('nick4', ':.module_unload tv')
    rec_msg(amsg)
    assert len(msg_l.msgs) == 4  # unloaded module

    # send
    rec_msg(msg)
    assert len(msg_l.msgs) == 4  # should not respond

    # load
    amsg = admin_make_message('nick4', ':.module_load tv')
    rec_msg(amsg)
    assert len(msg_l.msgs) == 5  # loaded module

    # send
    rec_msg(msg)
    assert len(msg_l.msgs) == 6  # response
예제 #3
0
파일: test_reload.py 프로젝트: boreq/botnet
def test_reload_meta_with_admin(cl, msg_l, make_privmsg, rec_msg):
    """Load, send, unload, send, load, send."""
    from botnet.manager import Manager
    from modules.builtin.test_admin import admin_make_message, data4, send_data

    msg = make_privmsg('.bots')

    manager = Manager()
    manager.config = make_admin_config()
    manager.load_module_by_name('admin')

    # load
    amsg = admin_make_message('nick4', ':.module_load meta')
    rec_msg(amsg)
    send_data(data4)
    assert len(msg_l.msgs) == 2 # WHOIS, loaded module

    # send
    rec_msg(msg)
    assert len(msg_l.msgs) == 3 # response

    # unload
    amsg = admin_make_message('nick4', ':.module_unload meta')
    rec_msg(amsg)
    assert len(msg_l.msgs) == 4 # unloaded module

    # send
    rec_msg(msg)
    assert len(msg_l.msgs) == 4 # should not respond 

    # load
    amsg = admin_make_message('nick4', ':.module_load meta')
    rec_msg(amsg)
    assert len(msg_l.msgs) == 5 # loaded module

    # send
    rec_msg(msg)
    assert len(msg_l.msgs) == 6 # response
예제 #4
0
def test_admin_dispatching():
    from botnet.modules.builtin.admin import Admin
    from modules.builtin.test_admin import admin_make_message, data4, send_data

    def make_admin_config(command_prefix='.'):
        config = {
            'module_config': {
                'botnet': {
                    'admin': {
                        'admins': [
                            'nick4'
                        ]
                    }
                }
            }
        }
        config = Config(config)
        return config

    admin_config = make_admin_config()

    t = Tester(Config())
    ad = Admin(admin_config)

    msg = make_privmsg('#channel :.test')
    message_in.send(None, msg=msg)
    assert t.launched_main
    assert t.launched_command
    assert t.launched_priv
    assert not t.launched_admin_command
    assert not t.launched_admin_priv

    msg = admin_make_message('nick4', '.test')
    message_in.send(None, msg=msg)
    send_data(data4)
    assert t.launched_admin_command
    assert t.launched_admin_priv