Ejemplo n.º 1
0
class AssistantBot(Bot):
    def __init__(self):
        self._client = MattermostClient(settings.BOT_URL, settings.BOT_TEAM,
                                        settings.BOT_LOGIN,
                                        settings.BOT_PASSWORD,
                                        settings.SSL_VERIFY)
        self._plugins = PluginsManager()
        self._plugins.init_plugins()
        self._dispatcher = MessageDispatcher(self._client, self._plugins)
Ejemplo n.º 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)
Ejemplo n.º 3
0
class ResponderBot(Bot):
    def __init__(self):
        self._client = MattermostClient(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.plugins = bot_settings.PLUGINS
        self._plugins.init_plugins()
        self._dispatcher = MessageDispatcher(self._client, self._plugins)
Ejemplo n.º 4
0
def test_get_plugins():
    reload(sys)
    manager = PluginsManager(plugins=[
        'tests.unit_tests.single_plugin',
        'tests.unit_tests.local_plugins'])
    manager.init_plugins()
    matched_func_names = set()
    # test: has_matching_plugin, there should be two handlers for `hello`
    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 or \
       'hello_send_alternative' not in matched_func_names:
        raise AssertionError('hello_send and hello_send_alternative should both be loaded')
    # test: not has_matching_plugin (there is no handler for `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()
Ejemplo n.º 5
0
def test_get_plugins():
    reload(sys)
    manager = PluginsManager(plugins=['single_plugin', 'local_plugins'])
    manager.init_plugins()
    matched_func_names = set()
    # test: has_matching_plugin, one plugin function for one regexp pattern only
    for func, args in manager.get_plugins('listen_to', 'hello'):
        if func:
            matched_func_names.add(func.__name__)
    if 'hello_send' in matched_func_names:
        raise AssertionError(
            'hello_send should be replaced by hello_send_alternative')
    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()