Fix some obtruse (test)bugs

This commit is contained in:
Matthias
2021-12-07 07:25:00 +01:00
parent ba1091b9e4
commit a870e0962a
4 changed files with 64 additions and 55 deletions

View File

@@ -7,6 +7,7 @@ import pytest
import time_machine
from freqtrade.constants import AVAILABLE_PAIRLISTS
from freqtrade.enums.candletype import CandleType
from freqtrade.enums.runmode import RunMode
from freqtrade.exceptions import OperationalException
from freqtrade.persistence import Trade
@@ -461,11 +462,11 @@ def test_VolumePairList_whitelist_gen(mocker, whitelist_conf, shitcoinmarkets, t
ohlcv_history_high_vola.loc[ohlcv_history_high_vola.index == 1, 'close'] = 0.00090
ohlcv_data = {
('ETH/BTC', '1d', ''): ohlcv_history,
('TKN/BTC', '1d', ''): ohlcv_history,
('LTC/BTC', '1d', ''): ohlcv_history.append(ohlcv_history),
('XRP/BTC', '1d', ''): ohlcv_history,
('HOT/BTC', '1d', ''): ohlcv_history_high_vola,
('ETH/BTC', '1d', CandleType.SPOT_): ohlcv_history,
('TKN/BTC', '1d', CandleType.SPOT_): ohlcv_history,
('LTC/BTC', '1d', CandleType.SPOT_): ohlcv_history.append(ohlcv_history),
('XRP/BTC', '1d', CandleType.SPOT_): ohlcv_history,
('HOT/BTC', '1d', CandleType.SPOT_): ohlcv_history_high_vola,
}
mocker.patch('freqtrade.exchange.Exchange.exchange_has', MagicMock(return_value=True))
@@ -579,11 +580,11 @@ def test_VolumePairList_range(mocker, whitelist_conf, shitcoinmarkets, tickers,
ohlcv_history_high_volume.loc[:, 'volume'] = 10
ohlcv_data = {
('ETH/BTC', '1d', ''): ohlcv_history,
('TKN/BTC', '1d', ''): ohlcv_history,
('LTC/BTC', '1d', ''): ohlcv_history_medium_volume,
('XRP/BTC', '1d', ''): ohlcv_history_high_vola,
('HOT/BTC', '1d', ''): ohlcv_history_high_volume,
('ETH/BTC', '1d', CandleType.SPOT_): ohlcv_history,
('TKN/BTC', '1d', CandleType.SPOT_): ohlcv_history,
('LTC/BTC', '1d', CandleType.SPOT_): ohlcv_history_medium_volume,
('XRP/BTC', '1d', CandleType.SPOT_): ohlcv_history_high_vola,
('HOT/BTC', '1d', CandleType.SPOT_): ohlcv_history_high_volume,
}
mocker.patch('freqtrade.exchange.Exchange.exchange_has', MagicMock(return_value=True))
@@ -855,9 +856,9 @@ def test_agefilter_min_days_listed_too_large(mocker, default_conf, markets, tick
def test_agefilter_caching(mocker, markets, whitelist_conf_agefilter, tickers, ohlcv_history):
with time_machine.travel("2021-09-01 05:00:00 +00:00") as t:
ohlcv_data = {
('ETH/BTC', '1d', ''): ohlcv_history,
('TKN/BTC', '1d', ''): ohlcv_history,
('LTC/BTC', '1d', ''): ohlcv_history,
('ETH/BTC', '1d', CandleType.SPOT_): ohlcv_history,
('TKN/BTC', '1d', CandleType.SPOT_): ohlcv_history,
('LTC/BTC', '1d', CandleType.SPOT_): ohlcv_history,
}
mocker.patch.multiple(
'freqtrade.exchange.Exchange',
@@ -879,10 +880,10 @@ def test_agefilter_caching(mocker, markets, whitelist_conf_agefilter, tickers, o
assert freqtrade.exchange.refresh_latest_ohlcv.call_count == 2
ohlcv_data = {
('ETH/BTC', '1d', ''): ohlcv_history,
('TKN/BTC', '1d', ''): ohlcv_history,
('LTC/BTC', '1d', ''): ohlcv_history,
('XRP/BTC', '1d', ''): ohlcv_history.iloc[[0]],
('ETH/BTC', '1d', CandleType.SPOT_): ohlcv_history,
('TKN/BTC', '1d', CandleType.SPOT_): ohlcv_history,
('LTC/BTC', '1d', CandleType.SPOT_): ohlcv_history,
('XRP/BTC', '1d', CandleType.SPOT_): ohlcv_history.iloc[[0]],
}
mocker.patch('freqtrade.exchange.Exchange.refresh_latest_ohlcv', return_value=ohlcv_data)
freqtrade.pairlists.refresh_pairlist()
@@ -900,10 +901,10 @@ def test_agefilter_caching(mocker, markets, whitelist_conf_agefilter, tickers, o
t.move_to("2021-09-03 01:00:00 +00:00")
# Called once for XRP/BTC
ohlcv_data = {
('ETH/BTC', '1d', ''): ohlcv_history,
('TKN/BTC', '1d', ''): ohlcv_history,
('LTC/BTC', '1d', ''): ohlcv_history,
('XRP/BTC', '1d', ''): ohlcv_history,
('ETH/BTC', '1d', CandleType.SPOT_): ohlcv_history,
('TKN/BTC', '1d', CandleType.SPOT_): ohlcv_history,
('LTC/BTC', '1d', CandleType.SPOT_): ohlcv_history,
('XRP/BTC', '1d', CandleType.SPOT_): ohlcv_history,
}
mocker.patch('freqtrade.exchange.Exchange.refresh_latest_ohlcv', return_value=ohlcv_data)
freqtrade.pairlists.refresh_pairlist()
@@ -964,12 +965,12 @@ def test_rangestabilityfilter_caching(mocker, markets, default_conf, tickers, oh
get_tickers=tickers
)
ohlcv_data = {
('ETH/BTC', '1d', ''): ohlcv_history,
('TKN/BTC', '1d', ''): ohlcv_history,
('LTC/BTC', '1d', ''): ohlcv_history,
('XRP/BTC', '1d', ''): ohlcv_history,
('HOT/BTC', '1d', ''): ohlcv_history,
('BLK/BTC', '1d', ''): ohlcv_history,
('ETH/BTC', '1d', CandleType.SPOT_): ohlcv_history,
('TKN/BTC', '1d', CandleType.SPOT_): ohlcv_history,
('LTC/BTC', '1d', CandleType.SPOT_): ohlcv_history,
('XRP/BTC', '1d', CandleType.SPOT_): ohlcv_history,
('HOT/BTC', '1d', CandleType.SPOT_): ohlcv_history,
('BLK/BTC', '1d', CandleType.SPOT_): ohlcv_history,
}
mocker.patch.multiple(
'freqtrade.exchange.Exchange',