Beispiel #1
0
 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)
Beispiel #2
0
class DriverBot(Bot):
    def __init__(self):
        self._client = MattermostClientv4(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)
Beispiel #3
0
    def __init__(self, client, body, pool):
        from mattermost_bot.bot import PluginsManager

        self._plugins = PluginsManager()
        self._client = client
        self._body = body
        self._pool = pool
def test_load_single_plugin():
    reload(sys)
    PluginsManager()._load_plugins('single_plugin')
    if 'single_plugin' not in sys.modules:
        raise AssertionError()
    if 'single_plugin.mock_plugin' not in sys.modules:
        raise AssertionError()
Beispiel #5
0
 def __init__(self):
     self._client = MattermostClient(local_settings.BOT_URL,
                                     local_settings.BOT_TEAM,
                                     local_settings.BOT_LOGIN,
                                     local_settings.BOT_PASSWORD,
                                     local_settings.SSL_VERIFY)
     self._plugins = PluginsManager(local_settings.PLUGINS)
     self._dispatcher = MessageDispatcher(self._client, self._plugins)
def test_load_local_plugins():
    reload(sys)
    PluginsManager(plugins=['local_plugins']).init_plugins()
    if 'local_plugins' not in sys.modules:
        raise AssertionError()
    if 'local_plugins.hello' not in sys.modules:
        raise AssertionError()
    if 'local_plugins.busy' not in sys.modules:
        raise AssertionError()
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()
def test_load_init_plugins():
    reload(sys)
    PluginsManager().init_plugins()
    if 'mattermost_bot.plugins' not in sys.modules:
        raise AssertionError()