Allow deleting of UI only

This commit is contained in:
Matthias 2021-01-16 10:15:27 +01:00
parent ddc99553bd
commit f05f2c45e8
4 changed files with 29 additions and 6 deletions

View File

@ -70,6 +70,8 @@ ARGS_PLOT_DATAFRAME = ["pairs", "indicators1", "indicators2", "plot_limit",
ARGS_PLOT_PROFIT = ["pairs", "timerange", "export", "exportfilename", "db_url", ARGS_PLOT_PROFIT = ["pairs", "timerange", "export", "exportfilename", "db_url",
"trade_source", "timeframe"] "trade_source", "timeframe"]
ARGS_INSTALL_UI = ["erase_ui_only"]
ARGS_SHOW_TRADES = ["db_url", "trade_ids", "print_json"] ARGS_SHOW_TRADES = ["db_url", "trade_ids", "print_json"]
ARGS_HYPEROPT_LIST = ["hyperopt_list_best", "hyperopt_list_profitable", ARGS_HYPEROPT_LIST = ["hyperopt_list_best", "hyperopt_list_profitable",
@ -361,7 +363,7 @@ class Arguments:
help='Install FreqUI', help='Install FreqUI',
) )
install_ui_cmd.set_defaults(func=start_install_ui) install_ui_cmd.set_defaults(func=start_install_ui)
self._build_args(optionlist=[], parser=install_ui_cmd) self._build_args(optionlist=ARGS_INSTALL_UI, parser=install_ui_cmd)
# Add Plotting subcommand # Add Plotting subcommand
plot_dataframe_cmd = subparsers.add_parser( plot_dataframe_cmd = subparsers.add_parser(

View File

@ -387,6 +387,12 @@ AVAILABLE_CLI_OPTIONS = {
help='Clean all existing data for the selected exchange/pairs/timeframes.', help='Clean all existing data for the selected exchange/pairs/timeframes.',
action='store_true', action='store_true',
), ),
"erase_ui_only": Arg(
'--erase',
help="Clean UI folder, don't download new version.",
action='store_true',
default=False,
),
# Templating options # Templating options
"template": Arg( "template": Arg(
'--template', '--template',

View File

@ -191,7 +191,9 @@ def start_install_ui(args: Dict[str, Any]) -> None:
dest_folder = Path(__file__).parents[1] / 'rpc/api_server/ui' dest_folder = Path(__file__).parents[1] / 'rpc/api_server/ui'
# First make sure the assets are removed. # First make sure the assets are removed.
clean_ui_subdir(dest_folder) clean_ui_subdir(dest_folder)
if args.get('erase_ui_only'):
logger.info("Erased UI directory content. Not downloading new version.")
else:
dl_url = get_ui_download_url() dl_url = get_ui_download_url()
# Download a new version # Download a new version

View File

@ -565,11 +565,24 @@ def test_start_install_ui(mocker):
args = [ args = [
"install-ui", "install-ui",
] ]
start_install_ui(args) start_install_ui(get_args(args))
assert clean_mock.call_count == 1 assert clean_mock.call_count == 1
assert get_url_mock.call_count == 1 assert get_url_mock.call_count == 1
assert download_mock.call_count == 1 assert download_mock.call_count == 1
clean_mock.reset_mock()
get_url_mock.reset_mock()
download_mock.reset_mock()
args = [
"install-ui",
"--erase",
]
start_install_ui(get_args(args))
assert clean_mock.call_count == 1
assert get_url_mock.call_count == 0
assert download_mock.call_count == 0
def test_clean_ui_subdir(mocker, tmpdir, caplog): def test_clean_ui_subdir(mocker, tmpdir, caplog):
mocker.patch("freqtrade.commands.deploy_commands.Path.is_dir", mocker.patch("freqtrade.commands.deploy_commands.Path.is_dir",