From ffef4bc4744b03ac35e625924c034c0b7dacb51f Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 5 May 2020 19:48:28 +0200 Subject: [PATCH] Humanize show-trades error when no database is specified --- freqtrade/commands/list_commands.py | 5 +++++ tests/commands/test_commands.py | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/freqtrade/commands/list_commands.py b/freqtrade/commands/list_commands.py index 61d6f7244..e5131f9b2 100644 --- a/freqtrade/commands/list_commands.py +++ b/freqtrade/commands/list_commands.py @@ -206,6 +206,11 @@ def start_show_trades(args: Dict[str, Any]) -> None: from freqtrade.persistence import init, Trade import json config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE) + + if 'db_url' not in config: + raise OperationalException("--db-url is required for this command.") + + logger.info(f'Using DB: "{config["db_url"]}"') init(config['db_url'], clean_open_orders=False) tfilter = [] diff --git a/tests/commands/test_commands.py b/tests/commands/test_commands.py index 2796a8b45..93b123069 100644 --- a/tests/commands/test_commands.py +++ b/tests/commands/test_commands.py @@ -1077,3 +1077,11 @@ def test_show_trades(mocker, fee, capsys, caplog): assert '"trade_id": 1' in captured.out assert '"trade_id": 2' in captured.out assert '"trade_id": 3' not in captured.out + args = [ + "show-trades", + ] + pargs = get_args(args) + pargs['config'] = None + + with pytest.raises(OperationalException, match=r"--db-url is required for this command."): + start_show_trades(pargs)