Add test to async
This commit is contained in:
parent
a6b69da391
commit
69cc6aa958
@ -135,7 +135,6 @@ class FreqtradeBot(object):
|
|||||||
"""
|
"""
|
||||||
Refresh tickers asyncronously and return the result.
|
Refresh tickers asyncronously and return the result.
|
||||||
"""
|
"""
|
||||||
# TODO: maybe add since_ms to use async in the download-script?
|
|
||||||
# TODO: Add tests for this and the async stuff above
|
# TODO: Add tests for this and the async stuff above
|
||||||
logger.debug("Refreshing klines for %d pairs", len(pair_list))
|
logger.debug("Refreshing klines for %d pairs", len(pair_list))
|
||||||
datatups = asyncio.get_event_loop().run_until_complete(
|
datatups = asyncio.get_event_loop().run_until_complete(
|
||||||
|
@ -624,11 +624,6 @@ async def test_async_get_candles_history(default_conf, mocker):
|
|||||||
# await exchange.async_get_candles_history('ETH/BTC', "5m")
|
# await exchange.async_get_candles_history('ETH/BTC', "5m")
|
||||||
|
|
||||||
|
|
||||||
def test_refresh_tickers():
|
|
||||||
# TODO: Implement test for this
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def make_fetch_ohlcv_mock(data):
|
def make_fetch_ohlcv_mock(data):
|
||||||
def fetch_ohlcv_mock(pair, timeframe, since):
|
def fetch_ohlcv_mock(pair, timeframe, since):
|
||||||
if since:
|
if since:
|
||||||
|
@ -137,6 +137,36 @@ def test_throttle_with_assets(mocker, default_conf) -> None:
|
|||||||
assert result == -1
|
assert result == -1
|
||||||
|
|
||||||
|
|
||||||
|
def test_refresh_tickers(mocker, default_conf, caplog) -> None:
|
||||||
|
tick = [
|
||||||
|
[
|
||||||
|
1511686200000, # unix timestamp ms
|
||||||
|
1, # open
|
||||||
|
2, # high
|
||||||
|
3, # low
|
||||||
|
4, # close
|
||||||
|
5, # volume (in quote currency)
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
|
async def async_get_candles_history(pairlist, timeframe):
|
||||||
|
return [(pair, tick) for pair in pairlist]
|
||||||
|
|
||||||
|
caplog.set_level(logging.DEBUG)
|
||||||
|
freqtrade = get_patched_freqtradebot(mocker, default_conf)
|
||||||
|
freqtrade.exchange.async_get_candles_history = async_get_candles_history
|
||||||
|
|
||||||
|
pairs = ['IOTA/ETH', 'XRP/ETH']
|
||||||
|
# empty dicts
|
||||||
|
assert not freqtrade._klines
|
||||||
|
freqtrade.refresh_tickers(['IOTA/ETH', 'XRP/ETH'])
|
||||||
|
|
||||||
|
assert log_has(f'Refreshing klines for {len(pairs)} pairs', caplog.record_tuples)
|
||||||
|
assert freqtrade._klines
|
||||||
|
for pair in pairs:
|
||||||
|
assert freqtrade._klines[pair]
|
||||||
|
|
||||||
|
|
||||||
def test_gen_pair_whitelist(mocker, default_conf, tickers) -> None:
|
def test_gen_pair_whitelist(mocker, default_conf, tickers) -> None:
|
||||||
freqtrade = get_patched_freqtradebot(mocker, default_conf)
|
freqtrade = get_patched_freqtradebot(mocker, default_conf)
|
||||||
mocker.patch('freqtrade.exchange.Exchange.get_tickers', tickers)
|
mocker.patch('freqtrade.exchange.Exchange.get_tickers', tickers)
|
||||||
|
Loading…
Reference in New Issue
Block a user