示例#1
0
def test_optional_prefix(testbot):
    testbot.bot_config.BOT_PREFIX_OPTIONAL_ON_CHAT = False
    assert 'Yes I am alive' in testbot.exec_command('!status')

    testbot.bot_config.BOT_PREFIX_OPTIONAL_ON_CHAT = True
    assert 'Yes I am alive' in testbot.exec_command('!status')
    assert 'Yes I am alive' in testbot.exec_command('status')
示例#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"'([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)

    # emulates the restore environment
    log = logging.getLogger(__name__)  # noqa
    with open(filename) as f:
        exec(f.read())

    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')
示例#3
0
def test_optional_prefix(testbot):
    testbot.bot_config.BOT_PREFIX_OPTIONAL_ON_CHAT = False
    assert 'Yes I am alive' in testbot.exec_command('!status')

    testbot.bot_config.BOT_PREFIX_OPTIONAL_ON_CHAT = True
    assert 'Yes I am alive' in testbot.exec_command('!status')
    assert 'Yes I am alive' in testbot.exec_command('status')
示例#4
0
def test_optional_prefix_re_cmd(testbot):
    testbot.bot_config.BOT_PREFIX_OPTIONAL_ON_CHAT = False
    assert 'bar' in testbot.exec_command('!plz dont match this')

    testbot.bot_config.BOT_PREFIX_OPTIONAL_ON_CHAT = True
    assert 'bar' in testbot.exec_command('!plz dont match this')
    assert 'bar' in testbot.exec_command('plz dont match this')
示例#5
0
def test_no_duplicate_autotrigger(testbot):
    assert 'c' in testbot.exec_command('!c')
    flow_message = testbot.pop_message()
    assert 'You are in the flow w2, you can continue with' in flow_message
    assert 'c' in testbot.exec_command('!c')
    assert len(testbot.bot.flow_executor.in_flight) == 1
    assert testbot.bot.flow_executor.in_flight[0].name == 'w2'
示例#6
0
def test_optional_prefix_re_cmd(testbot):
    testbot.bot_config.BOT_PREFIX_OPTIONAL_ON_CHAT = False
    assert 'bar' in testbot.exec_command('!plz dont match this')

    testbot.bot_config.BOT_PREFIX_OPTIONAL_ON_CHAT = True
    assert 'bar' in testbot.exec_command('!plz dont match this')
    assert 'bar' in testbot.exec_command('plz dont match this')
示例#7
0
def test_no_duplicate_autotrigger(testbot):
    assert 'c' in testbot.exec_command('!c')
    flow_message = testbot.pop_message()
    assert 'You are in the flow w2, you can continue with' in flow_message
    assert 'c' in testbot.exec_command('!c')
    assert len(testbot.bot.flow_executor.in_flight) == 1
    assert testbot.bot.flow_executor.in_flight[0].name == 'w2'
示例#8
0
def test_help(testbot):
    assert '!about' in testbot.exec_command('!help Help')
    assert 'That command is not defined.' in testbot.exec_command('!help beurk')

    # Ensure that help reports on re_commands.
    assert 'runs foo' in testbot.exec_command('!help foo')  # Part of Dummy
    assert 'runs re_foo' in testbot.exec_command('!help re_foo')  # Part of Dummy
    assert 'runs re_foo' in testbot.exec_command('!help re foo')  # Part of Dummy
def test_add_remove_list_queries(testbot):
    prepare(testbot)
    assert 'Your query has been stored, you can execute it with !bq 0.' in testbot.exec_command(
        "!bq addquery SELECT metadata.timestamp, protoPayload.resource AS version "
        "FROM (TABLE_DATE_RANGE(version_logs.appengine_googleapis_com_request_log_, "
        "DATE_ADD(CURRENT_TIMESTAMP(), -1, 'DAY'), CURRENT_TIMESTAMP()))")
    assert '0' in testbot.exec_command("!bq queries")
    assert '0 queries have been defined.' in testbot.exec_command(
        "!bq delquery 0")
示例#10
0
def test_room_flow(testbot):
    assert 'Flow w3 started' in testbot.exec_command('!flows start w3')
    flow_message = testbot.pop_message()
    assert 'You are in the flow w3, you can continue with' in flow_message
    assert '!a' in flow_message
    assert 'a' in testbot.exec_command('!a')
    flow_message = testbot.pop_message()
    assert 'You are in the flow w3, you can continue with' in flow_message
    assert '!b' in flow_message
示例#11
0
def test_room_flow(testbot):
    assert 'Flow w3 started' in testbot.exec_command('!flows start w3')
    flow_message = testbot.pop_message()
    assert 'You are in the flow w3, you can continue with' in flow_message
    assert '!a' in flow_message
    assert 'a' in testbot.exec_command('!a')
    flow_message = testbot.pop_message()
    assert 'You are in the flow w3, you can continue with' in flow_message
    assert '!b' in flow_message
示例#12
0
def test_manual_flow(testbot):
    assert 'Flow w1 started' in testbot.exec_command('!flows start w1')
    flow_message = testbot.pop_message()
    assert 'You are in the flow w1, you can continue with' in flow_message
    assert '!a' in flow_message
    assert 'a' in testbot.exec_command('!a')
    flow_message = testbot.pop_message()
    assert 'You are in the flow w1, you can continue with' in flow_message
    assert '!b' in flow_message
    assert '!c' in flow_message
示例#13
0
def test_manual_flow(testbot):
    assert 'Flow w1 started' in testbot.exec_command('!flows start w1')
    flow_message = testbot.pop_message()
    assert 'You are in the flow w1, you can continue with' in flow_message
    assert '!a' in flow_message
    assert 'a' in testbot.exec_command('!a')
    flow_message = testbot.pop_message()
    assert 'You are in the flow w1, you can continue with' in flow_message
    assert '!b' in flow_message
    assert '!c' in flow_message
示例#14
0
def test_help(testbot):
    assert '!about' in testbot.exec_command('!help Help')
    assert 'That command is not defined.' in testbot.exec_command(
        '!help beurk')

    # Ensure that help reports on re_commands.
    assert 'runs foo' in testbot.exec_command('!help foo')  # Part of Dummy
    assert 'runs re_foo' in testbot.exec_command(
        '!help re_foo')  # Part of Dummy
    assert 'runs re_foo' in testbot.exec_command(
        '!help re foo')  # Part of Dummy
示例#15
0
def test_config_cycle(testbot):
    testbot.push_message('!plugin config Webserver')
    m = testbot.pop_message()
    assert 'Default configuration for this plugin (you can copy and paste this directly as a command)' in m
    assert 'Current configuration' not in m

    testbot.assertCommand("!plugin config Webserver {'HOST': 'localhost', 'PORT': 3141, 'SSL':  None}",
                          'Plugin configuration done.')

    assert 'Current configuration' in testbot.exec_command('!plugin config Webserver')
    assert 'localhost' in testbot.exec_command('!plugin config Webserver')
示例#16
0
def test_config_cycle(testbot):
    testbot.push_message('!plugin config Webserver')
    m = testbot.pop_message()
    assert 'Default configuration for this plugin (you can copy and paste this directly as a command)' in m
    assert 'Current configuration' not in m

    testbot.assertCommand(
        "!plugin config Webserver {'HOST': 'localhost', 'PORT': 3141, 'SSL':  None}",
        'Plugin configuration done.')

    assert 'Current configuration' in testbot.exec_command(
        '!plugin config Webserver')
    assert 'localhost' in testbot.exec_command('!plugin config Webserver')
示例#17
0
def test_history(testbot):
    assert 'up' in testbot.exec_command('!uptime')
    assert 'uptime' in testbot.exec_command('!history')

    orig_sender = testbot.bot.sender
    # Pretend to be someone else. History should be empty
    testbot.bot.sender = testbot.bot.build_identifier('non_default_person')
    testbot.push_message('!history')
    with pytest.raises(Empty):
        testbot.pop_message(timeout=1)
    assert 'should be a separate history' in testbot.exec_command('!echo should be a separate history')
    assert 'should be a separate history' in testbot.exec_command('!history')
    testbot.bot.sender = orig_sender
    # Pretend to be the original person again. History should still contain uptime
    assert 'uptime' in testbot.exec_command('!history')
示例#18
0
def test_no_flyby_trigger_flow(testbot):
    testbot.bot.push_message('!flows start w1')
    # One message or the other can arrive first.
    flow_message = testbot.pop_message()
    assert 'Flow w1 started' in flow_message or 'You are in the flow w1' in flow_message
    flow_message = testbot.pop_message()
    assert 'Flow w1 started' in flow_message or 'You are in the flow w1' in flow_message
    assert 'a' in testbot.exec_command('!a')
    flow_message = testbot.pop_message()
    assert 'You are in the flow w1' in flow_message

    assert 'c' in testbot.exec_command('!c')  # c is a trigger for w2 but it should not trigger now.
    flow_message = testbot.pop_message()
    assert 'You are in the flow w1' in flow_message
    assert len(testbot.bot.flow_executor.in_flight) == 1
示例#19
0
def test_no_flyby_trigger_flow(testbot):
    testbot.bot.push_message('!flows start w1')
    # One message or the other can arrive first.
    flow_message = testbot.pop_message()
    assert 'Flow w1 started' in flow_message or 'You are in the flow w1' in flow_message
    flow_message = testbot.pop_message()
    assert 'Flow w1 started' in flow_message or 'You are in the flow w1' in flow_message
    assert 'a' in testbot.exec_command('!a')
    flow_message = testbot.pop_message()
    assert 'You are in the flow w1' in flow_message

    assert 'c' in testbot.exec_command('!c')  # c is a trigger for w2 but it should not trigger now.
    flow_message = testbot.pop_message()
    assert 'You are in the flow w1' in flow_message
    assert len(testbot.bot.flow_executor.in_flight) == 1
示例#20
0
def test_secondary_autotrigger(testbot):
    assert 'e' in testbot.exec_command('!e')
    second_message = testbot.pop_message()
    assert 'You are in the flow w2, you can continue with' in second_message
    assert '!d' in second_message
    assert len(testbot.bot.flow_executor.in_flight) == 1
    assert testbot.bot.flow_executor.in_flight[0].name == 'w2'
示例#21
0
def test_secondary_autotrigger(testbot):
    assert 'e' in testbot.exec_command('!e')
    second_message = testbot.pop_message()
    assert 'You are in the flow w2, you can continue with' in second_message
    assert '!d' in second_message
    assert len(testbot.bot.flow_executor.in_flight) == 1
    assert testbot.bot.flow_executor.in_flight[0].name == 'w2'
示例#22
0
def test_history(testbot):
    assert 'up' in testbot.exec_command('!uptime')
    assert 'uptime' in testbot.exec_command('!history')

    orig_sender = testbot.bot.sender
    # Pretend to be someone else. History should be empty
    testbot.bot.sender = testbot.bot.build_identifier('non_default_person')
    testbot.push_message('!history')
    with pytest.raises(Empty):
        testbot.pop_message(timeout=1)
    assert 'should be a separate history' in testbot.exec_command(
        '!echo should be a separate history')
    assert 'should be a separate history' in testbot.exec_command('!history')
    testbot.bot.sender = orig_sender
    # Pretend to be the original person again. History should still contain uptime
    assert 'uptime' in testbot.exec_command('!history')
示例#23
0
def test_botcommands(testbot):  # noqa
    rooms = testbot.bot.rooms()
    room = testbot.bot.query_room('testroom')
    assert len(rooms) == 1
    assert rooms[0] == room

    assert room.joined
    assert "Left the room testroom" in testbot.exec_command(
        "!room leave testroom")
    room = testbot.bot.query_room('testroom')
    assert not room.joined

    assert "I'm not currently in any rooms." in testbot.exec_command(
        "!room list")

    assert "Destroyed the room testroom" in testbot.exec_command(
        "!room destroy testroom")

    rooms = testbot.bot.rooms()
    room = testbot.bot.query_room('testroom')
    assert not room.exists
    assert room not in rooms

    assert "Created the room testroom" in testbot.exec_command(
        "!room create testroom")
    rooms = testbot.bot.rooms()
    room = testbot.bot.query_room('testroom')
    assert room.exists
    assert room not in rooms
    assert not room.joined

    assert "Joined the room testroom" in testbot.exec_command(
        "!room join testroom")
    rooms = testbot.bot.rooms()
    room = testbot.bot.query_room('testroom')
    assert room.exists
    assert room.joined
    assert room in rooms

    assert "testroom" in testbot.exec_command("!room list")
    assert "err" in testbot.exec_command("!room occupants testroom")
    assert "No topic is set for testroom" in testbot.exec_command(
        "!room topic testroom")
    assert "Topic for testroom set." in testbot.exec_command(
        "!room topic testroom 'Errbot rocks!'")
    assert "Topic for testroom: Errbot rocks!" in testbot.exec_command(
        "!room topic testroom")
示例#24
0
def test_plugin_cycle(testbot):

    plugins = [
        'errbotio/err-helloworld',
    ]

    for plugin in plugins:
        testbot.assertCommand(
            '!repos install {0}'.format(plugin),
            'Installing {0}...'.format(plugin)
        ),
        assert 'A new plugin repository has been installed correctly from errbotio/err-helloworld' in \
               testbot.pop_message(timeout=60)
        assert 'Plugins reloaded' in testbot.pop_message()

        assert 'this command says hello' in testbot.exec_command('!help hello')
        assert 'Hello World !' in testbot.exec_command('!hello')

        testbot.push_message('!plugin reload HelloWorld')
        assert 'Plugin HelloWorld reloaded.' == testbot.pop_message()

        testbot.push_message('!hello')  # should still respond
        assert 'Hello World !' == testbot.pop_message()

        testbot.push_message('!plugin blacklist HelloWorld')
        assert 'Plugin HelloWorld is now blacklisted' == testbot.pop_message()
        testbot.push_message('!plugin deactivate HelloWorld')
        assert 'HelloWorld is already deactivated.' == testbot.pop_message()

        testbot.push_message('!hello')  # should not respond
        assert 'Command "hello" not found' in testbot.pop_message()

        testbot.push_message('!plugin unblacklist HelloWorld')
        assert 'Plugin HelloWorld removed from blacklist' == testbot.pop_message()
        testbot.push_message('!plugin activate HelloWorld')
        assert 'HelloWorld is already activated.' == testbot.pop_message()

        testbot.push_message('!hello')  # should respond back
        assert 'Hello World !' == testbot.pop_message()

        testbot.push_message('!repos uninstall errbotio/err-helloworld')
        assert 'Repo errbotio/err-helloworld removed.' == testbot.pop_message()

        testbot.push_message('!hello')  # should not respond
        assert 'Command "hello" not found' in testbot.pop_message()
示例#25
0
def test_plugin_cycle(testbot):

    plugins = [
        'errbotio/err-helloworld',
    ]

    for plugin in plugins:
        testbot.assertCommand('!repos install {0}'.format(plugin),
                              'Installing {0}...'.format(plugin)),
        assert 'A new plugin repository has been installed correctly from errbotio/err-helloworld' in \
               testbot.pop_message(timeout=60)
        assert 'Plugins reloaded' in testbot.pop_message()

        assert 'this command says hello' in testbot.exec_command('!help hello')
        assert 'Hello World !' in testbot.exec_command('!hello')

        testbot.push_message('!plugin reload HelloWorld')
        assert 'Plugin HelloWorld reloaded.' == testbot.pop_message()

        testbot.push_message('!hello')  # should still respond
        assert 'Hello World !' == testbot.pop_message()

        testbot.push_message('!plugin blacklist HelloWorld')
        assert 'Plugin HelloWorld is now blacklisted' == testbot.pop_message()
        testbot.push_message('!plugin deactivate HelloWorld')
        assert 'HelloWorld is already deactivated.' == testbot.pop_message()

        testbot.push_message('!hello')  # should not respond
        assert 'Command "hello" not found' in testbot.pop_message()

        testbot.push_message('!plugin unblacklist HelloWorld')
        assert 'Plugin HelloWorld removed from blacklist' == testbot.pop_message(
        )
        testbot.push_message('!plugin activate HelloWorld')
        assert 'HelloWorld is already activated.' == testbot.pop_message()

        testbot.push_message('!hello')  # should respond back
        assert 'Hello World !' == testbot.pop_message()

        testbot.push_message('!repos uninstall errbotio/err-helloworld')
        assert 'Repo errbotio/err-helloworld removed.' == testbot.pop_message()

        testbot.push_message('!hello')  # should not respond
        assert 'Command "hello" not found' in testbot.pop_message()
示例#26
0
def test_clashing(testbot):
    assert 'original' in testbot.exec_command('!clash')
    assert 'clashing.clash clashes with Dyna.clash so it has been renamed clashing-clash' in \
           testbot.exec_command('!add_clashing')
    assert 'added' in testbot.pop_message()
    assert 'original' in testbot.exec_command('!clash')
    assert 'dynamic' in testbot.exec_command('!clashing-clash')
    assert 'removed' in testbot.exec_command('!remove_clashing')
    assert 'original' in testbot.exec_command('!clash')
    assert 'not found' in testbot.exec_command('!clashing-clash')
示例#27
0
def test_simple(testbot):
    assert "added" in testbot.exec_command("!add_simple")
    assert "yep" in testbot.exec_command("!say_yep")
    assert "foo" in testbot.exec_command("!say_foo")
    assert "documented" in testbot.exec_command("!help")
    assert "removed" in testbot.exec_command("!remove_simple")
    assert 'Command "say_foo" not found' in testbot.exec_command("!say_foo")
示例#28
0
def test_simple(testbot):
    assert 'added' in testbot.exec_command('!add_simple')
    assert 'yep' in testbot.exec_command('!say_yep')
    assert 'foo' in testbot.exec_command('!say_foo')
    assert 'documented' in testbot.exec_command('!help')
    assert 'removed' in testbot.exec_command('!remove_simple')
    assert 'Command "say_foo" not found' in testbot.exec_command('!say_foo')
示例#29
0
def test_botcommands(testbot):  # noqa
    rooms = testbot.bot.rooms()
    room = testbot.bot.query_room("testroom")
    assert len(rooms) == 1
    assert rooms[0] == room

    assert room.joined
    assert "Left the room testroom" in testbot.exec_command("!room leave testroom")
    room = testbot.bot.query_room("testroom")
    assert not room.joined

    assert "I'm not currently in any rooms." in testbot.exec_command("!room list")

    assert "Destroyed the room testroom" in testbot.exec_command("!room destroy testroom")

    rooms = testbot.bot.rooms()
    room = testbot.bot.query_room("testroom")
    assert not room.exists
    assert room not in rooms

    assert "Created the room testroom" in testbot.exec_command("!room create testroom")
    rooms = testbot.bot.rooms()
    room = testbot.bot.query_room("testroom")
    assert room.exists
    assert room not in rooms
    assert not room.joined

    assert "Joined the room testroom" in testbot.exec_command("!room join testroom")
    rooms = testbot.bot.rooms()
    room = testbot.bot.query_room("testroom")
    assert room.exists
    assert room.joined
    assert room in rooms

    assert "testroom" in testbot.exec_command("!room list")
    assert "err" in testbot.exec_command("!room occupants testroom")
    assert "No topic is set for testroom" in testbot.exec_command("!room topic testroom")
    assert "Topic for testroom set." in testbot.exec_command("!room topic testroom 'Err rocks!'")
    assert "Topic for testroom: Err rocks!" in testbot.exec_command("!room topic testroom")
示例#30
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)

    # emulates the restore environment
    log = logging.getLogger(__name__)  # noqa
    with open(filename) as f:
        exec(f.read())

    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')
示例#31
0
def test_broken_plugin(testbot):

    borken_plugin_dir = path.join(path.dirname(path.realpath(__file__)), 'borken_plugin')
    try:
        tempd = mkdtemp()
        tgz = os.path.join(tempd, "borken.tar.gz")
        with tarfile.open(tgz, "w:gz") as tar:
            tar.add(borken_plugin_dir, arcname='borken')
        assert 'Installing' in testbot.exec_command('!repos install file://' + tgz,
                                                    timeout=120)
        assert 'import borken  # fails' in testbot.pop_message()
        assert 'as it did not load correctly.' in testbot.pop_message()
        assert 'Plugins reloaded.' in testbot.pop_message()
    finally:
        rmtree(tempd)
示例#32
0
def test_clashing(testbot):
    assert "original" in testbot.exec_command("!clash")
    assert "clashing.clash clashes with Dyna.clash so it has been renamed clashing-clash" in testbot.exec_command(
        "!add_clashing"
    )
    assert "added" in testbot.pop_message()
    assert "original" in testbot.exec_command("!clash")
    assert "dynamic" in testbot.exec_command("!clashing-clash")
    assert "removed" in testbot.exec_command("!remove_clashing")
    assert "original" in testbot.exec_command("!clash")
    assert "not found" in testbot.exec_command("!clashing-clash")
示例#33
0
def test_broken_plugin(testbot):

    borken_plugin_dir = path.join(path.dirname(path.realpath(__file__)),
                                  'borken_plugin')
    try:
        tempd = mkdtemp()
        tgz = os.path.join(tempd, "borken.tar.gz")
        with tarfile.open(tgz, "w:gz") as tar:
            tar.add(borken_plugin_dir, arcname='borken')
        assert 'Installing' in testbot.exec_command('!repos install file://' +
                                                    tgz,
                                                    timeout=120)
        assert 'import borken  # fails' in testbot.pop_message()
        assert 'as it did not load correctly.' in testbot.pop_message()
        assert 'Plugins reloaded.' in testbot.pop_message()
    finally:
        rmtree(tempd)
示例#34
0
def test_foreign_mention(testbot):
    assert 'Somebody mentioned toto!' in testbot.exec_command('I am telling you something @toto')
示例#35
0
def test_multiple_mentions(testbot):
    assert 'Somebody mentioned toto,titi!' in testbot.exec_command('I am telling you something @toto and @titi')
示例#36
0
def test_testbot_mention(testbot):
    assert 'Somebody mentioned me!' in testbot.exec_command('I am telling you something @Err')
示例#37
0
def test_dependency_retrieval(testbot):
    assert 'youpi' in testbot.exec_command('!depfunc')
示例#38
0
def test_logtail(testbot):
    assert 'DEBUG' in testbot.exec_command('!log tail')
示例#39
0
def test_help_is_still_here(testbot):
    assert 'All commands' in testbot.exec_command('!help')
示例#40
0
def test_echo_still_here(testbot):
    assert 'toto' in testbot.exec_command('!echo toto')
示例#41
0
def test_flows_stop(testbot):
    assert 'c' in testbot.exec_command('!c')
    flow_message = testbot.bot.pop_message()
    assert 'You are in the flow w2' in flow_message
    assert 'w2 stopped' in testbot.exec_command('!flows stop w2')
    assert len(testbot.bot.flow_executor.in_flight) == 0
示例#42
0
def test_flow_only(testbot):
    assert 'a' in testbot.exec_command('!a')  # non flow_only should respond.
    testbot.push_message('!d')
    with pytest.raises(Empty):
        testbot.pop_message(timeout=1)
示例#43
0
def test_apropos(testbot):
    assert '!about: Return information about' in testbot.exec_command(
        '!apropos about')
示例#44
0
def test_no_autotrigger(testbot):
    assert 'a' in testbot.exec_command('!a')
    assert len(testbot.bot.flow_executor.in_flight) == 0
示例#45
0
def test_backup_help_not_here(testbot):
    assert 'That command is not defined.' in testbot.exec_command('!help backup')
示例#46
0
def test_backup_should_not_be_there(testbot):
    assert 'Command "backup" not found.' in testbot.exec_command('!backup')
def test_vm_list(testbot):
    prepare(testbot)
    assert 'Bucket errbot-graphs set.' in testbot.exec_command(
        '!bucket set errbot-graphs')
    assert 'name' in testbot.exec_command('!vm list')
示例#48
0
def test_bot_prefix_replaced(testbot):
    assert '$help - Returns a help string' in testbot.exec_command('$help')
示例#49
0
def test_templates_1(testbot):
    assert 'ok' in testbot.exec_command('!test template1')
示例#50
0
def test_failed_config(testbot):
    assert 'Plugin configuration done.' in testbot.exec_command(
        '!plugin config Config {"One": "two"}')
示例#51
0
def test_flows_kill(testbot):
    assert 'c' in testbot.exec_command('!c')
    flow_message = testbot.bot.pop_message()
    assert 'You are in the flow w2' in flow_message
    assert 'w2 killed' in testbot.exec_command('!flows kill gbin@localhost w2')