mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 08:33:07 +00:00
Eliminate unnecessary lazy import
This commit is contained in:
@@ -3,6 +3,8 @@ import secrets
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Dict, List
|
from typing import Any, Dict, List
|
||||||
|
|
||||||
|
from questionary import Separator, prompt
|
||||||
|
|
||||||
from freqtrade.constants import UNLIMITED_STAKE_AMOUNT
|
from freqtrade.constants import UNLIMITED_STAKE_AMOUNT
|
||||||
from freqtrade.enums import RunMode
|
from freqtrade.enums import RunMode
|
||||||
from freqtrade.exceptions import OperationalException
|
from freqtrade.exceptions import OperationalException
|
||||||
@@ -28,8 +30,6 @@ def validate_is_float(val):
|
|||||||
|
|
||||||
|
|
||||||
def ask_user_overwrite(config_path: Path) -> bool:
|
def ask_user_overwrite(config_path: Path) -> bool:
|
||||||
from questionary import prompt
|
|
||||||
|
|
||||||
questions = [
|
questions = [
|
||||||
{
|
{
|
||||||
"type": "confirm",
|
"type": "confirm",
|
||||||
@@ -48,7 +48,6 @@ def ask_user_config() -> Dict[str, Any]:
|
|||||||
Interactive questions built using https://github.com/tmbo/questionary
|
Interactive questions built using https://github.com/tmbo/questionary
|
||||||
:returns: Dict with keys to put into template
|
:returns: Dict with keys to put into template
|
||||||
"""
|
"""
|
||||||
from questionary import Separator, prompt
|
|
||||||
|
|
||||||
from freqtrade.configuration.detect_environment import running_in_docker
|
from freqtrade.configuration.detect_environment import running_in_docker
|
||||||
from freqtrade.exchange import available_exchanges
|
from freqtrade.exchange import available_exchanges
|
||||||
|
|||||||
@@ -90,13 +90,17 @@ def test_ask_user_overwrite(mocker):
|
|||||||
"""
|
"""
|
||||||
Once https://github.com/tmbo/questionary/issues/35 is implemented, improve this test.
|
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 not ask_user_overwrite(Path("test.json"))
|
||||||
assert prompt_mock.call_count == 1
|
assert prompt_mock.call_count == 1
|
||||||
|
|
||||||
prompt_mock.reset_mock()
|
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 ask_user_overwrite(Path("test.json"))
|
||||||
assert prompt_mock.call_count == 1
|
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.
|
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()
|
answers = ask_user_config()
|
||||||
assert isinstance(answers, dict)
|
assert isinstance(answers, dict)
|
||||||
assert prompt_mock.call_count == 1
|
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\."):
|
with pytest.raises(OperationalException, match=r"User interrupted interactive questions\."):
|
||||||
ask_user_config()
|
ask_user_config()
|
||||||
|
|||||||
@@ -693,7 +693,9 @@ def test_get_ui_download_url(mocker):
|
|||||||
[{"browser_download_url": "http://download.zip"}],
|
[{"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()
|
x, last_version = get_ui_download_url()
|
||||||
assert get_mock.call_count == 2
|
assert get_mock.call_count == 2
|
||||||
assert last_version == "0.0.1"
|
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()
|
x, last_version = get_ui_download_url()
|
||||||
assert get_mock.call_count == 1
|
assert get_mock.call_count == 1
|
||||||
assert last_version == "0.0.2"
|
assert last_version == "0.0.2"
|
||||||
|
|||||||
Reference in New Issue
Block a user