Exemple #1
0
class LocalBot(Bot):
    def __init__(self):
        self._client = MattermostClientv4(bot_settings.BOT_URL,
                                          bot_settings.BOT_TEAM,
                                          bot_settings.BOT_LOGIN,
                                          bot_settings.BOT_PASSWORD,
                                          bot_settings.SSL_VERIFY)
        self._plugins = PluginsManager()
        self._plugins.init_plugins()
        self._dispatcher = MessageDispatcher(self._client, self._plugins)
Exemple #2
0
class DriverBot(Bot):
    def __init__(self):
        self._client = MattermostClient(driver_settings.BOT_URL,
                                        driver_settings.BOT_TEAM,
                                        driver_settings.BOT_LOGIN,
                                        driver_settings.BOT_PASSWORD,
                                        driver_settings.SSL_VERIFY)
        self._plugins = PluginsManager()
        self._plugins.init_plugins()
        self._dispatcher = MessageDispatcher(self._client, self._plugins)
def test_get_plugins():
    reload(sys)
    manager = PluginsManager(plugins=['single_plugin', 'local_plugins'])
    manager.init_plugins()
    matched_func_names = set()
    # test: has_matching_plugin
    for func, args in manager.get_plugins('listen_to', 'hello'):
        if func:
            matched_func_names.add(func.__name__)
    if 'hello_send' not in matched_func_names:
        raise AssertionError()
    if 'hello_send_alternative' not in matched_func_names:
        raise AssertionError()
    # test: not has_matching_plugin (there is no such plugin `hallo`)
    reload(sys)
    matched_func_names = set()
    for func, args in manager.get_plugins('listen_to', 'hallo'):
        if func:
            matched_func_names.add(func.__name__)
    if 'hello_send' in matched_func_names:
        raise AssertionError()
    if 'hello_send_alternative' in matched_func_names:
        raise AssertionError()