mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-12-03 10:33:08 +00:00
Merge pull request #9986 from freqtrade/feat/show_config
add show-config command
This commit is contained in:
@@ -12,9 +12,9 @@ from freqtrade.commands import (start_backtesting_show, start_convert_data, star
|
||||
start_create_userdir, start_download_data, start_hyperopt_list,
|
||||
start_hyperopt_show, start_install_ui, start_list_data,
|
||||
start_list_exchanges, start_list_markets, start_list_strategies,
|
||||
start_list_timeframes, start_new_strategy, start_show_trades,
|
||||
start_strategy_update, start_test_pairlist, start_trading,
|
||||
start_webserver)
|
||||
start_list_timeframes, start_new_strategy, start_show_config,
|
||||
start_show_trades, start_strategy_update, start_test_pairlist,
|
||||
start_trading, start_webserver)
|
||||
from freqtrade.commands.db_commands import start_convert_db
|
||||
from freqtrade.commands.deploy_commands import (clean_ui_subdir, download_and_install_ui,
|
||||
get_ui_download_url, read_ui_version)
|
||||
@@ -39,6 +39,14 @@ def test_setup_utils_configuration():
|
||||
assert "exchange" in config
|
||||
assert config['dry_run'] is True
|
||||
|
||||
args = [
|
||||
'list-exchanges', '--config', 'tests/testdata/testconfigs/testconfig.json',
|
||||
]
|
||||
|
||||
config = setup_utils_configuration(get_args(args), RunMode.OTHER, set_dry=False)
|
||||
assert "exchange" in config
|
||||
assert config['dry_run'] is False
|
||||
|
||||
|
||||
def test_start_trading_fail(mocker, caplog):
|
||||
|
||||
@@ -1572,3 +1580,33 @@ def test_start_strategy_updater(mocker, tmp_path):
|
||||
start_strategy_update(pargs)
|
||||
# Number of strategies in the test directory
|
||||
assert sc_mock.call_count == 2
|
||||
|
||||
|
||||
def test_start_show_config(capsys, caplog):
|
||||
args = [
|
||||
"show-config",
|
||||
"--config",
|
||||
"tests/testdata/testconfigs/main_test_config.json",
|
||||
]
|
||||
pargs = get_args(args)
|
||||
start_show_config(pargs)
|
||||
|
||||
captured = capsys.readouterr()
|
||||
assert "Your combined configuration is:" in captured.out
|
||||
assert '"max_open_trades":' in captured.out
|
||||
assert '"secret": "REDACTED"' in captured.out
|
||||
|
||||
args = [
|
||||
"show-config",
|
||||
"--config",
|
||||
"tests/testdata/testconfigs/main_test_config.json",
|
||||
"--show-sensitive"
|
||||
]
|
||||
pargs = get_args(args)
|
||||
start_show_config(pargs)
|
||||
|
||||
captured = capsys.readouterr()
|
||||
assert "Your combined configuration is:" in captured.out
|
||||
assert '"max_open_trades":' in captured.out
|
||||
assert '"secret": "REDACTED"' not in captured.out
|
||||
assert log_has_re(r'Sensitive information will be shown in the upcomming output.*', caplog)
|
||||
|
||||
@@ -10,6 +10,7 @@ from jsonschema import ValidationError
|
||||
|
||||
from freqtrade.commands import Arguments
|
||||
from freqtrade.configuration import Configuration, validate_config_consistency
|
||||
from freqtrade.configuration.config_secrets import sanitize_config
|
||||
from freqtrade.configuration.config_validation import validate_config_schema
|
||||
from freqtrade.configuration.deprecated_settings import (check_conflicting_settings,
|
||||
process_deprecated_setting,
|
||||
@@ -1426,7 +1427,7 @@ def test_flat_vars_to_nested_dict(caplog):
|
||||
assert not log_has("Loading variable 'NOT_RELEVANT'", caplog)
|
||||
|
||||
|
||||
def test_setup_hyperopt_freqai(mocker, default_conf, caplog) -> None:
|
||||
def test_setup_hyperopt_freqai(mocker, default_conf) -> None:
|
||||
patched_configuration_load_config_file(mocker, default_conf)
|
||||
mocker.patch(
|
||||
'freqtrade.configuration.configuration.create_datadir',
|
||||
@@ -1459,7 +1460,7 @@ def test_setup_hyperopt_freqai(mocker, default_conf, caplog) -> None:
|
||||
validate_config_consistency(config)
|
||||
|
||||
|
||||
def test_setup_freqai_backtesting(mocker, default_conf, caplog) -> None:
|
||||
def test_setup_freqai_backtesting(mocker, default_conf) -> None:
|
||||
patched_configuration_load_config_file(mocker, default_conf)
|
||||
mocker.patch(
|
||||
'freqtrade.configuration.configuration.create_datadir',
|
||||
@@ -1506,3 +1507,17 @@ def test_setup_freqai_backtesting(mocker, default_conf, caplog) -> None:
|
||||
OperationalException, match=r".* pass --timerange if you intend to use FreqAI .*"
|
||||
):
|
||||
validate_config_consistency(conf)
|
||||
|
||||
|
||||
def test_sanitize_config(default_conf_usdt):
|
||||
assert default_conf_usdt['exchange']['key'] != 'REDACTED'
|
||||
res = sanitize_config(default_conf_usdt)
|
||||
# Didn't modify original dict
|
||||
assert default_conf_usdt['exchange']['key'] != 'REDACTED'
|
||||
|
||||
assert res['exchange']['key'] == 'REDACTED'
|
||||
assert res['exchange']['secret'] == 'REDACTED'
|
||||
|
||||
res = sanitize_config(default_conf_usdt, show_sensitive=True)
|
||||
assert res['exchange']['key'] == default_conf_usdt['exchange']['key']
|
||||
assert res['exchange']['secret'] == default_conf_usdt['exchange']['secret']
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"stake_currency": "",
|
||||
"dry_run": true,
|
||||
"dry_run": false,
|
||||
"exchange": {
|
||||
"name": "",
|
||||
"key": "",
|
||||
|
||||
Reference in New Issue
Block a user