mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
Add tests for download_data entrypoint
This commit is contained in:
parent
89257832d7
commit
b2c215029d
|
@ -1,8 +1,11 @@
|
||||||
from freqtrade.utils import setup_utils_configuration, start_list_exchanges
|
|
||||||
from freqtrade.tests.conftest import get_args
|
|
||||||
from freqtrade.state import RunMode
|
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
from pathlib import Path
|
||||||
|
from unittest.mock import MagicMock, PropertyMock
|
||||||
|
|
||||||
|
from freqtrade.state import RunMode
|
||||||
|
from freqtrade.tests.conftest import get_args, log_has, patch_exchange
|
||||||
|
from freqtrade.utils import (setup_utils_configuration, start_download_data,
|
||||||
|
start_list_exchanges)
|
||||||
|
|
||||||
|
|
||||||
def test_setup_utils_configuration():
|
def test_setup_utils_configuration():
|
||||||
|
@ -40,3 +43,43 @@ def test_list_exchanges(capsys):
|
||||||
assert not re.match(r"Exchanges supported by ccxt and available.*", captured.out)
|
assert not re.match(r"Exchanges supported by ccxt and available.*", captured.out)
|
||||||
assert re.search(r"^binance$", captured.out, re.MULTILINE)
|
assert re.search(r"^binance$", captured.out, re.MULTILINE)
|
||||||
assert re.search(r"^bittrex$", captured.out, re.MULTILINE)
|
assert re.search(r"^bittrex$", captured.out, re.MULTILINE)
|
||||||
|
|
||||||
|
|
||||||
|
def test_download_data(mocker, markets, caplog):
|
||||||
|
dl_mock = mocker.patch('freqtrade.utils.download_pair_history', MagicMock())
|
||||||
|
patch_exchange(mocker)
|
||||||
|
mocker.patch(
|
||||||
|
'freqtrade.exchange.Exchange.markets', PropertyMock(return_value=markets)
|
||||||
|
)
|
||||||
|
mocker.patch.object(Path, "exists", MagicMock(return_value=True))
|
||||||
|
mocker.patch.object(Path, "unlink", MagicMock())
|
||||||
|
|
||||||
|
args = [
|
||||||
|
"download-data",
|
||||||
|
"--exchange", "binance",
|
||||||
|
"--pairs", "ETH/BTC", "XRP/BTC",
|
||||||
|
"--erase"
|
||||||
|
]
|
||||||
|
start_download_data(get_args(args))
|
||||||
|
|
||||||
|
assert dl_mock.call_count == 4
|
||||||
|
assert log_has("Deleting existing data for pair ETH/BTC, interval 1m.", caplog)
|
||||||
|
assert log_has("Downloading pair ETH/BTC, interval 1m.", caplog)
|
||||||
|
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user