def test_get_config_option_exception(self): module_config = None result = get_config_option( ["repo", "path", "gist"], module_config, True, "module" ) assert result == ("module", "module", "module")
def list_all_modules(ctx, path): """List the active modules from config. This function will try to get information from the modules that are active in the configuration file and print them as a table or will just print a sentence saying that there are no active modules for that type. Args: ctx (:obj:`click.Context`): The current click cli context. path (str): a str that contains a path passed. Returns: int: the exit code. Always returns 0 in this case. """ config = load_config_file([path] if path else DEFAULT_CONFIG_LOCATIONS) click.echo( click.style( f"{'NAME':15} {'TYPE':15} {'MODE':15} {'CACHED':15} {'LOCATION':15}", fg="blue", bold=True, ) ) for module_type, module in config.items(): if module_type in ("connectors", "databases", "parsers", "skills"): for name, options in module.items(): mode = get_config_option( ["repo", "path", "gist"], options, True, "module" ) cache = get_config_option(["no-cache"], options, "no", "yes") location = get_config_option( ["repo", "path", "gist"], options, True, f"opsdroid.{module_type}.{name}", ) click.echo( f"{name:15} {module_type:15} {mode[1]:15} {cache[0]:15} {location[2]:15}" ) ctx.exit(0)
def test_get_config_no_option(self): module_config = { "bot-name": "mybot", "max-connections": 10, "connection-timeout": 10, } result = get_config_option(["repo", "path", "gist"], module_config, True, "module") assert result == ("module", "module", "module")
def test_get_config_option(self): module_config = {"repo": "test"} result = get_config_option( ["repo", "path", "gist"], module_config, True, "opsdroid.connectors.websocket", ) assert result == (True, "repo", "test")