diff --git a/freqtrade/commands/build_config_commands.py b/freqtrade/commands/build_config_commands.py index 3bcc5254f..27e3f395a 100644 --- a/freqtrade/commands/build_config_commands.py +++ b/freqtrade/commands/build_config_commands.py @@ -3,6 +3,8 @@ import secrets from pathlib import Path from typing import Any, Dict, List +from questionary import Separator, prompt + from freqtrade.constants import UNLIMITED_STAKE_AMOUNT from freqtrade.enums import RunMode from freqtrade.exceptions import OperationalException @@ -28,8 +30,6 @@ def validate_is_float(val): def ask_user_overwrite(config_path: Path) -> bool: - from questionary import prompt - questions = [ { "type": "confirm", @@ -48,7 +48,6 @@ def ask_user_config() -> Dict[str, Any]: Interactive questions built using https://github.com/tmbo/questionary :returns: Dict with keys to put into template """ - from questionary import Separator, prompt from freqtrade.configuration.detect_environment import running_in_docker from freqtrade.exchange import available_exchanges diff --git a/tests/commands/test_build_config.py b/tests/commands/test_build_config.py index 6efda2ff8..805d76e25 100644 --- a/tests/commands/test_build_config.py +++ b/tests/commands/test_build_config.py @@ -90,13 +90,17 @@ def test_ask_user_overwrite(mocker): """ Once https://github.com/tmbo/questionary/issues/35 is implemented, improve this test. """ - prompt_mock = mocker.patch("questionary.prompt", return_value={"overwrite": False}) + prompt_mock = mocker.patch( + "freqtrade.commands.build_config_commands.prompt", return_value={"overwrite": False} + ) assert not ask_user_overwrite(Path("test.json")) assert prompt_mock.call_count == 1 prompt_mock.reset_mock() - prompt_mock = mocker.patch("questionary.prompt", return_value={"overwrite": True}) + prompt_mock = mocker.patch( + "freqtrade.commands.build_config_commands.prompt", return_value={"overwrite": False} + ) assert ask_user_overwrite(Path("test.json")) assert prompt_mock.call_count == 1 @@ -105,12 +109,16 @@ def test_ask_user_config(mocker): """ Once https://github.com/tmbo/questionary/issues/35 is implemented, improve this test. """ - prompt_mock = mocker.patch("questionary.prompt", return_value={"overwrite": False}) + prompt_mock = mocker.patch( + "freqtrade.commands.build_config_commands.prompt", return_value={"overwrite": False} + ) answers = ask_user_config() assert isinstance(answers, dict) assert prompt_mock.call_count == 1 - prompt_mock = mocker.patch("questionary.prompt", return_value={}) + prompt_mock = mocker.patch( + "freqtrade.commands.build_config_commands.prompt", return_value={"overwrite": False} + ) with pytest.raises(OperationalException, match=r"User interrupted interactive questions\."): ask_user_config() diff --git a/tests/commands/test_commands.py b/tests/commands/test_commands.py index 9be7f9506..ebc83e5e9 100644 --- a/tests/commands/test_commands.py +++ b/tests/commands/test_commands.py @@ -693,7 +693,9 @@ def test_get_ui_download_url(mocker): [{"browser_download_url": "http://download.zip"}], ] ) - get_mock = mocker.patch("requests.get", return_value=response) + get_mock = mocker.patch( + "freqtrade.commands.deploy_commands.requests.get", return_value=response + ) x, last_version = get_ui_download_url() assert get_mock.call_count == 2 assert last_version == "0.0.1" @@ -716,7 +718,9 @@ def test_get_ui_download_url_direct(mocker): }, ] ) - get_mock = mocker.patch("requests.get", return_value=response) + get_mock = mocker.patch( + "freqtrade.commands.deploy_commands.requests.get", return_value=response + ) x, last_version = get_ui_download_url() assert get_mock.call_count == 1 assert last_version == "0.0.2"