Esempio n. 1
0
def test_create_userdata_dir_and_chown(mocker, tmpdir, caplog) -> None:
    sp_mock = mocker.patch('subprocess.check_output')
    path = Path(tmpdir / 'bar')
    assert not path.is_dir()

    x = create_userdata_dir(str(path), create_dir=True)
    assert sp_mock.call_count == 0
    assert log_has(f'Created user-data directory: {path}', caplog)
    assert isinstance(x, Path)
    assert path.is_dir()
    assert (path / 'data').is_dir()

    os.environ['FT_APP_ENV'] = 'docker'
    chown_user_directory(path / 'data')
    assert sp_mock.call_count == 1
    del os.environ['FT_APP_ENV']
Esempio n. 2
0
def start_new_config(args: Dict[str, Any]) -> None:
    """
    Create a new strategy from a template
    Asking the user questions to fill out the template accordingly.
    """

    config_path = Path(args['config'][0])
    chown_user_directory(config_path.parent)
    if config_path.exists():
        overwrite = ask_user_overwrite(config_path)
        if overwrite:
            config_path.unlink()
        else:
            raise OperationalException(
                f"Configuration file `{config_path}` already exists. "
                "Please delete it or use a different configuration file name.")
    selections = ask_user_config()
    deploy_new_config(config_path, selections)