Ejemplo n.º 1
0
def test_build_config_from_files_no_files(mocker):
    settings.build_config_from_files.cache_clear()
    mocker.patch("vault_cli.settings.read_config_file", return_value=None)

    result = settings.build_config_from_files("a")

    assert result == settings.DEFAULTS._as_dict()
Ejemplo n.º 2
0
def load_config(ctx: click.Context, param: click.Parameter, value: str) -> None:
    if value == "no":
        ctx.default_map = {}
        return

    if value is None:
        config_files = settings.CONFIG_FILES
    else:
        config_files = [value]

    config = settings.build_config_from_files(*config_files)
    ctx.default_map = config
Ejemplo n.º 3
0
def test_build_config_from_files(mocker):
    settings.build_config_from_files.cache_clear()
    config_file = {"test-a": "b"}
    mocker.patch("vault_cli.settings.read_config_file",
                 return_value=config_file)
    read_all_files = mocker.patch("vault_cli.settings.read_all_files",
                                  side_effect=lambda x: x)

    result = settings.build_config_from_files("a")

    assert result["test_a"] == "b"
    assert "url" in result
    assert read_all_files.called is True