Exemple #1
0
def test_backup(testbot):
    bot = testbot.bot  # used while restoring
    bot.push_message('!repos install https://github.com/errbotio/err-helloworld.git')
    assert 'Installing' in testbot.pop_message()
    assert 'err-helloworld' in testbot.pop_message(timeout=60)
    assert 'reload' in testbot.pop_message()
    bot.push_message('!backup')
    msg = testbot.pop_message()
    assert 'has been written in' in msg
    filename = re.search(r"'([:A-Za-z0-9_./\\-]*)'", msg).group(1)

    # At least the backup should mention the installed plugin
    assert 'errbotio/err-helloworld' in open(filename).read()

    # Now try to clean the bot and restore
    for p in testbot.bot.plugin_manager.get_all_active_plugin_objects():
        p.close_storage()

    assert 'Plugin HelloWorld deactivated.' in testbot.exec_command('!plugin deactivate HelloWorld')

    plugins_dir = path.join(testbot.bot_config.BOT_DATA_DIR, 'plugins')
    bot.repo_manager['installed_repos'] = {}
    bot.plugin_manager['configs'] = {}
    rmtree(plugins_dir)
    mkdir(plugins_dir)

    from errbot.bootstrap import restore_bot_from_backup
    log = logging.getLogger(__name__)  # noqa
    restore_bot_from_backup(filename, bot=bot, log=log)

    assert 'Plugin HelloWorld activated.' in testbot.exec_command('!plugin activate HelloWorld')
    assert 'Hello World !' in testbot.exec_command('!hello')
    testbot.push_message('!repos uninstall errbotio/err-helloworld')
Exemple #2
0
def test_backup(testbot):
    bot = testbot.bot  # used while restoring
    bot.push_message(
        "!repos install https://github.com/errbotio/err-helloworld.git")
    assert "Installing" in testbot.pop_message()
    assert "err-helloworld" in testbot.pop_message(timeout=60)
    assert "reload" in testbot.pop_message()
    bot.push_message("!backup")
    msg = testbot.pop_message()
    assert "has been written in" in msg
    filename = re.search(r'"(.*)"', msg).group(1)

    # At least the backup should mention the installed plugin
    assert "errbotio/err-helloworld" in open(filename).read()

    # Now try to clean the bot and restore
    for p in testbot.bot.plugin_manager.get_all_active_plugins():
        p.close_storage()

    assert "Plugin HelloWorld deactivated." in testbot.exec_command(
        "!plugin deactivate HelloWorld")

    plugins_dir = path.join(testbot.bot_config.BOT_DATA_DIR, "plugins")
    bot.repo_manager["installed_repos"] = {}
    bot.plugin_manager["configs"] = {}
    rmtree(plugins_dir)
    mkdir(plugins_dir)

    from errbot.bootstrap import restore_bot_from_backup

    log = logging.getLogger(__name__)  # noqa
    restore_bot_from_backup(filename, bot=bot, log=log)

    assert "Plugin HelloWorld activated." in testbot.exec_command(
        "!plugin activate HelloWorld")
    assert "Hello World !" in testbot.exec_command("!hello")
    testbot.push_message("!repos uninstall errbotio/err-helloworld")
Exemple #3
0
def test_backup(testbot):
    bot = testbot.bot  # used while restoring
    bot.push_message(
        '!repos install https://github.com/errbotio/err-helloworld.git')
    assert 'Installing' in testbot.pop_message()
    assert 'err-helloworld' in testbot.pop_message(timeout=60)
    assert 'reload' in testbot.pop_message()
    bot.push_message('!backup')
    msg = testbot.pop_message()
    assert 'has been written in' in msg
    filename = re.search(r"'([:A-Za-z0-9_./\\-]*)'", msg).group(1)

    # At least the backup should mention the installed plugin
    assert 'errbotio/err-helloworld' in open(filename).read()

    # Now try to clean the bot and restore
    for p in testbot.bot.plugin_manager.get_all_active_plugin_objects():
        p.close_storage()

    assert 'Plugin HelloWorld deactivated.' in testbot.exec_command(
        '!plugin deactivate HelloWorld')

    plugins_dir = path.join(testbot.bot_config.BOT_DATA_DIR, 'plugins')
    bot.repo_manager['installed_repos'] = {}
    bot.plugin_manager['configs'] = {}
    rmtree(plugins_dir)
    mkdir(plugins_dir)

    from errbot.bootstrap import restore_bot_from_backup
    log = logging.getLogger(__name__)  # noqa
    restore_bot_from_backup(filename, bot=bot, log=log)

    assert 'Plugin HelloWorld activated.' in testbot.exec_command(
        '!plugin activate HelloWorld')
    assert 'Hello World !' in testbot.exec_command('!hello')
    testbot.push_message('!repos uninstall errbotio/err-helloworld')