From c3fa8a4c45b8f2381fe8fe40aeb5d0743181ab63 Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 22 May 2024 20:30:35 +0200 Subject: [PATCH] feat: Allow empty fiat_display_currency (instead of completely deleting that key) --- freqtrade/constants.py | 1 + tests/rpc/test_rpc_telegram.py | 8 ++++++-- tests/test_configuration.py | 10 ++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/freqtrade/constants.py b/freqtrade/constants.py index c6a46dae3..f8f1ac7ee 100644 --- a/freqtrade/constants.py +++ b/freqtrade/constants.py @@ -156,6 +156,7 @@ SUPPORTED_FIAT = [ "LTC", "BCH", "BNB", + "", # Allow empty field in config. ] MINIMAL_CONFIG = { diff --git a/tests/rpc/test_rpc_telegram.py b/tests/rpc/test_rpc_telegram.py index 3063e644b..6e4aa3384 100644 --- a/tests/rpc/test_rpc_telegram.py +++ b/tests/rpc/test_rpc_telegram.py @@ -2564,10 +2564,14 @@ def test_send_msg_buy_notification_no_fiat( ("Short", "short_signal_01", 2.0), ], ) +@pytest.mark.parametrize("fiat", ["", None]) def test_send_msg_exit_notification_no_fiat( - default_conf, mocker, direction, enter_signal, leverage, time_machine + default_conf, mocker, direction, enter_signal, leverage, time_machine, fiat ) -> None: - del default_conf["fiat_display_currency"] + if fiat is None: + del default_conf["fiat_display_currency"] + else: + default_conf["fiat_display_currency"] = fiat time_machine.move_to("2022-05-02 00:00:00 +00:00", tick=False) telegram, _, msg_mock = get_telegram_testobject(mocker, default_conf) diff --git a/tests/test_configuration.py b/tests/test_configuration.py index 7faa35c4a..d0e0aa2c6 100644 --- a/tests/test_configuration.py +++ b/tests/test_configuration.py @@ -659,6 +659,16 @@ def test_validate_default_conf(default_conf) -> None: validate_config_schema(default_conf) +@pytest.mark.parametrize("fiat", ["EUR", "USD", "", None]) +def test_validate_fiat_currency_options(default_conf, fiat) -> None: + # Validate via our validator - we allow setting defaults! + if fiat is not None: + default_conf["fiat_display_currency"] = fiat + else: + del default_conf["fiat_display_currency"] + validate_config_schema(default_conf) + + def test_validate_max_open_trades(default_conf): default_conf["max_open_trades"] = float("inf") default_conf["stake_amount"] = "unlimited"