def test_download_data_keyboardInterrupt(mocker, caplog, markets): dl_mock = mocker.patch('freqtrade.utils.refresh_backtest_ohlcv_data', MagicMock(side_effect=KeyboardInterrupt)) patch_exchange(mocker) mocker.patch( 'freqtrade.exchange.Exchange.markets', PropertyMock(return_value=markets) ) args = [ "download-data", "--exchange", "binance", "--pairs", "ETH/BTC", "XRP/BTC", ] with pytest.raises(SystemExit): start_download_data(get_args(args)) assert dl_mock.call_count == 1
def test_download_data_trades(mocker, caplog): dl_mock = mocker.patch('freqtrade.utils.refresh_backtest_trades_data', MagicMock(return_value=[])) convert_mock = mocker.patch('freqtrade.utils.convert_trades_to_ohlcv', MagicMock(return_value=[])) patch_exchange(mocker) mocker.patch('freqtrade.exchange.Exchange.markets', PropertyMock(return_value={})) args = [ "download-data", "--exchange", "kraken", "--pairs", "ETH/BTC", "XRP/BTC", "--days", "20", "--dl-trades" ] start_download_data(get_args(args)) assert dl_mock.call_args[1]['timerange'].starttype == "date" assert dl_mock.call_count == 1 assert convert_mock.call_count == 1
def test_download_data_no_pairs(mocker, caplog): mocker.patch.object(Path, "exists", MagicMock(return_value=False)) mocker.patch('freqtrade.utils.refresh_backtest_ohlcv_data', MagicMock(return_value=["ETH/BTC", "XRP/BTC"])) patch_exchange(mocker) mocker.patch('freqtrade.exchange.Exchange.markets', PropertyMock(return_value={})) args = [ "download-data", "--exchange", "binance", ] pargs = get_args(args) pargs['config'] = None with pytest.raises(OperationalException, match=r"Downloading data requires a list of pairs\..*"): start_download_data(pargs)
def test_download_data_no_markets(mocker, caplog): dl_mock = mocker.patch('freqtrade.utils.download_pair_history', MagicMock()) patch_exchange(mocker) mocker.patch('freqtrade.exchange.Exchange.markets', PropertyMock(return_value={})) args = [ "download-data", "--exchange", "binance", "--pairs", "ETH/BTC", "XRP/BTC", ] start_download_data(get_args(args)) assert dl_mock.call_count == 0 assert log_has("Skipping pair ETH/BTC...", caplog) assert log_has( "Pairs [ETH/BTC,XRP/BTC] not available on exchange binance.", caplog)