From 19fcbc92a7d0fe4570f34c9ed5cdb9394373aa15 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 29 Oct 2020 07:43:40 +0100 Subject: [PATCH 1/4] Remove stake-currency for download-data - it's not needed --- freqtrade/commands/data_commands.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/freqtrade/commands/data_commands.py b/freqtrade/commands/data_commands.py index 7102eee38..df4c52de0 100644 --- a/freqtrade/commands/data_commands.py +++ b/freqtrade/commands/data_commands.py @@ -35,6 +35,9 @@ def start_download_data(args: Dict[str, Any]) -> None: if 'timerange' in config: timerange = timerange.parse_timerange(config['timerange']) + # Remove stake-currency to skip checks which are not relevant for datadownload + config['stake_currency'] = '' + if 'pairs' not in config: raise OperationalException( "Downloading data requires a list of pairs. " From f4d39f2a12538a3e75d921f737b961ee0ee29b38 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 29 Oct 2020 07:44:03 +0100 Subject: [PATCH 2/4] Improve test coverage of deploy_commands --- freqtrade/commands/deploy_commands.py | 2 +- tests/commands/test_commands.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/freqtrade/commands/deploy_commands.py b/freqtrade/commands/deploy_commands.py index 0a49c55de..a0105e140 100644 --- a/freqtrade/commands/deploy_commands.py +++ b/freqtrade/commands/deploy_commands.py @@ -133,7 +133,7 @@ def start_new_hyperopt(args: Dict[str, Any]) -> None: if new_path.exists(): raise OperationalException(f"`{new_path}` already exists. " - "Please choose another Strategy Name.") + "Please choose another Hyperopt Name.") deploy_new_hyperopt(args['hyperopt'], new_path, args['template']) else: raise OperationalException("`new-hyperopt` requires --hyperopt to be set.") diff --git a/tests/commands/test_commands.py b/tests/commands/test_commands.py index 713386a8e..6861e0cd9 100644 --- a/tests/commands/test_commands.py +++ b/tests/commands/test_commands.py @@ -476,6 +476,12 @@ def test_start_new_strategy(mocker, caplog): assert "CoolNewStrategy" in wt_mock.call_args_list[0][0][0] assert log_has_re("Writing strategy to .*", caplog) + mocker.patch('freqtrade.commands.deploy_commands.setup_utils_configuration') + mocker.patch.object(Path, "exists", MagicMock(return_value=True)) + with pytest.raises(OperationalException, + match=r".* already exists. Please choose another Strategy Name\."): + start_new_strategy(get_args(args)) + def test_start_new_strategy_DefaultStrat(mocker, caplog): args = [ @@ -512,6 +518,12 @@ def test_start_new_hyperopt(mocker, caplog): assert "CoolNewhyperopt" in wt_mock.call_args_list[0][0][0] assert log_has_re("Writing hyperopt to .*", caplog) + mocker.patch('freqtrade.commands.deploy_commands.setup_utils_configuration') + mocker.patch.object(Path, "exists", MagicMock(return_value=True)) + with pytest.raises(OperationalException, + match=r".* already exists. Please choose another Hyperopt Name\."): + start_new_hyperopt(get_args(args)) + def test_start_new_hyperopt_DefaultHyperopt(mocker, caplog): args = [ From d8ff79a2faa69ac714d5898ca1b1386cf70afacf Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 29 Oct 2020 07:54:42 +0100 Subject: [PATCH 3/4] Improve tests of list commands --- tests/commands/test_commands.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/commands/test_commands.py b/tests/commands/test_commands.py index 6861e0cd9..305b6b376 100644 --- a/tests/commands/test_commands.py +++ b/tests/commands/test_commands.py @@ -435,6 +435,16 @@ def test_list_markets(mocker, markets, capsys): assert re.search(r"^BLK/BTC$", captured.out, re.MULTILINE) assert re.search(r"^LTC/USD$", captured.out, re.MULTILINE) + mocker.patch('freqtrade.exchange.Exchange.markets', PropertyMock(side_effect=ValueError)) + # Test --one-column + args = [ + "list-markets", + '--config', 'config.json.example', + "--one-column" + ] + with pytest.raises(OperationalException, match=r"Cannot get markets.*"): + start_list_markets(get_args(args), False) + def test_create_datadir_failed(caplog): @@ -707,6 +717,7 @@ def test_start_list_strategies(mocker, caplog, capsys): "list-strategies", "--strategy-path", str(Path(__file__).parent.parent / "strategy" / "strats"), + '--no-color', ] pargs = get_args(args) # pargs['config'] = None From 3ca97223f21c820363386aa0a68570388660b31c Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 29 Oct 2020 08:09:50 +0100 Subject: [PATCH 4/4] Improve test for test_pairlist --- tests/commands/test_commands.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/commands/test_commands.py b/tests/commands/test_commands.py index 305b6b376..a392b74cf 100644 --- a/tests/commands/test_commands.py +++ b/tests/commands/test_commands.py @@ -792,6 +792,25 @@ def test_start_test_pairlist(mocker, caplog, tickers, default_conf, capsys): assert re.match(r"Pairs for .*", captured.out) assert re.match("['ETH/BTC', 'TKN/BTC', 'BLK/BTC', 'LTC/BTC', 'XRP/BTC']", captured.out) + args = [ + 'test-pairlist', + '-c', 'config.json.example', + '--one-column', + ] + start_test_pairlist(get_args(args)) + captured = capsys.readouterr() + assert re.match(r"ETH/BTC\nTKN/BTC\nBLK/BTC\nLTC/BTC\nXRP/BTC\n", captured.out) + + args = [ + 'test-pairlist', + '-c', 'config.json.example', + '--print-json', + ] + start_test_pairlist(get_args(args)) + captured = capsys.readouterr() + assert re.match(r'Pairs for BTC: \n\["ETH/BTC","TKN/BTC","BLK/BTC","LTC/BTC","XRP/BTC"\]\n', + captured.out) + def test_hyperopt_list(mocker, capsys, caplog, hyperopt_results): mocker.patch(