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()
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()