How to use the opsdroid.configuration.load_config_file function in opsdroid

To help you get started, we’ve selected a few opsdroid examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github opsdroid / opsdroid / tests / test_loader.py View on Github external
def test_load_pre_0_17_config_file(self):
        config = load_config_file(
            [os.path.abspath("tests/configs/minimal_pre_0_17_layout.yaml")]
        )
        self.assertLogs("_LOGGER", "warning")
        self.assertEqual(
            config, {"connectors": {"shell": {}}, "skills": {"hello": {}, "seen": {}}}
        )
github opsdroid / opsdroid / tests / test_configuration.py View on Github external
def test_load_config_broken(self):

        with self.assertRaises(SystemExit) as cm:
            _ = load_config_file([os.path.abspath("tests/configs/full_broken.yaml")])
        self.assertEqual(cm.exception.code, 1)
github opsdroid / opsdroid / tests / test_configuration.py View on Github external
def test_load_non_existant_config_file(self):
        with mock.patch("sys.exit") as mock_sysexit, mock.patch(
            "opsdroid.configuration.create_default_config"
        ) as mocked_create_default_config:
            mocked_create_default_config.return_value = os.path.abspath(
                "/tmp/my_nonexistant_config"
            )
            load_config_file(["file_which_does_not_exist"])
            self.assertTrue(mocked_create_default_config.called)
            self.assertLogs("_LOGGER", "critical")
            self.assertTrue(mock_sysexit.called)
github opsdroid / opsdroid / tests / test_configuration.py View on Github external
def test_load_bad_config_broken(self):
        with mock.patch("sys.exit") as mock_sysexit, mock.patch(
            "opsdroid.configuration.validate_data_type"
        ) as mocked_func:
            mocked_func.side_effect = TypeError()
            load_config_file(["file_which_does_not_exist"])
            self.assertTrue(mocked_func.called)
            self.assertLogs("_LOGGER", "critical")
            self.assertTrue(mock_sysexit.called)
github opsdroid / opsdroid / tests / test_loader.py View on Github external
def test_setup_module_bad_config(self):
        opsdroid, loader = self.setup()
        with mock.patch("sys.exit") as mock_sysexit:
            config = load_config_file(
                [os.path.abspath("tests/configs/broken_modules.yaml")]
            )
            loader.load_modules_from_config(config)
            self.assertTrue(mock_sysexit.called)
            self.assertLogs("_LOGGER", "critical")
github opsdroid / opsdroid / tests / test_configuration.py View on Github external
def test_load_config_valid_case_sensitivity(self):
        opsdroid, loader = self.setup()
        config = load_config_file(
            [os.path.abspath("tests/configs/valid_case_sensitivity.yaml")]
        )
        self.assertIsNotNone(config)
github opsdroid / opsdroid / tests / test_configuration.py View on Github external
def test_generate_config_if_none_exist(self):
        # cdf_backup = create_default_config("tests/configs/minimal.yaml")
        with mock.patch(
            "opsdroid.configuration.create_default_config"
        ) as mocked_create_config:
            mocked_create_config.return_value = os.path.abspath(
                "tests/configs/minimal.yaml"
            )
            load_config_file(["file_which_does_not_exist"])
            self.assertTrue(mocked_create_config.called)
github opsdroid / opsdroid / opsdroid / core.py View on Github external
async def reload(self):
        """Reload opsdroid."""
        await self.unload()
        self.config = load_config_file(
            [
                "configuration.yaml",
                DEFAULT_CONFIG_PATH,
                "/etc/opsdroid/configuration.yaml",
            ]
        )
        await self.load()
github opsdroid / opsdroid / opsdroid / cli / start.py View on Github external
def start(path):
    """Start the opsdroid bot.

    If the `-f` flag is used with this command, opsdroid will load the
    configuration specified on that path otherwise it will use the default
    configuration.

    """
    check_dependencies()

    config = load_config_file([path] if path else DEFAULT_CONFIG_LOCATIONS)

    configure_lang(config)
    configure_logging(config)
    welcome_message(config)

    with OpsDroid(config=config) as opsdroid:
        opsdroid.run()
github opsdroid / opsdroid / opsdroid / cli / utils.py View on Github external
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")