diff --git a/freqtrade/commands/trade_commands.py b/freqtrade/commands/trade_commands.py index ca1451778..3c3f3db9f 100644 --- a/freqtrade/commands/trade_commands.py +++ b/freqtrade/commands/trade_commands.py @@ -1,6 +1,7 @@ import logging from typing import Any, Dict + logger = logging.getLogger(__name__) @@ -32,9 +33,9 @@ def start_webserver(args: Dict[str, Any]) -> None: """ Main entry point for webserver mode """ - from freqtrade.rpc.api_server import ApiServer from freqtrade.configuration import Configuration from freqtrade.enums import RunMode + from freqtrade.rpc.api_server import ApiServer # Initialize configuration config = Configuration(args, RunMode.WEBSERVER).get_config() diff --git a/tests/commands/test_commands.py b/tests/commands/test_commands.py index dcceb3ea1..bef421c89 100644 --- a/tests/commands/test_commands.py +++ b/tests/commands/test_commands.py @@ -16,6 +16,7 @@ from freqtrade.commands import (start_convert_data, start_create_userdir, start_ start_test_pairlist, start_trading) from freqtrade.commands.deploy_commands import (clean_ui_subdir, download_and_install_ui, get_ui_download_url, read_ui_version) +from freqtrade.commands.trade_commands import start_webserver from freqtrade.configuration import setup_utils_configuration from freqtrade.enums import RunMode from freqtrade.exceptions import OperationalException @@ -58,6 +59,18 @@ def test_start_trading_fail(mocker, caplog): assert log_has('Fatal exception!', caplog) +def test_start_webserver(mocker, caplog): + + api_server_mock = mocker.patch("freqtrade.rpc.api_server.ApiServer", ) + + args = [ + 'webserver', + '-c', 'config_bittrex.json.example' + ] + start_webserver(get_args(args)) + assert api_server_mock.call_count == 1 + + def test_list_exchanges(capsys): args = [