Add additional test scenarios

This commit is contained in:
Matthias
2020-06-14 10:49:15 +02:00
parent 1c1a7150ae
commit 8b186dbe0e
6 changed files with 43 additions and 9 deletions

View File

@@ -787,6 +787,7 @@ def limit_buy_order():
'price': 0.00001099,
'amount': 90.99181073,
'filled': 90.99181073,
'cost': 0.0009999,
'remaining': 0.0,
'status': 'closed'
}

View File

@@ -57,9 +57,9 @@ def test_returns_latest_signal(mocker, default_conf, ohlcv_history):
def test_trade_no_dataprovider(default_conf, mocker, caplog):
strategy = DefaultStrategy({})
# Delete DP for sure (suffers from test leakage, as we update this in the base class)
if strategy.dp:
del strategy.dp
# Delete DP for sure (suffers from test leakage, as this is updated in the base class)
if strategy.dp is not None:
strategy.dp = None
with pytest.raises(OperationalException, match="DataProvider not found."):
strategy.get_signal('ETH/BTC', '5m')

View File

@@ -1070,6 +1070,39 @@ def test_execute_buy(mocker, default_conf, fee, limit_buy_order) -> None:
assert not freqtrade.execute_buy(pair, stake_amount)
def test_execute_buy_confirm_error(mocker, default_conf, fee, limit_buy_order) -> None:
freqtrade = get_patched_freqtradebot(mocker, default_conf)
mocker.patch.multiple(
'freqtrade.freqtradebot.FreqtradeBot',
get_buy_rate=MagicMock(return_value=0.11),
_get_min_pair_stake_amount=MagicMock(return_value=1)
)
mocker.patch.multiple(
'freqtrade.exchange.Exchange',
fetch_ticker=MagicMock(return_value={
'bid': 0.00001172,
'ask': 0.00001173,
'last': 0.00001172
}),
buy=MagicMock(return_value=limit_buy_order),
get_fee=fee,
)
stake_amount = 2
pair = 'ETH/BTC'
freqtrade.strategy.confirm_trade_entry = MagicMock(side_effect=ValueError)
assert freqtrade.execute_buy(pair, stake_amount)
freqtrade.strategy.confirm_trade_entry = MagicMock(side_effect=Exception)
assert freqtrade.execute_buy(pair, stake_amount)
freqtrade.strategy.confirm_trade_entry = MagicMock(return_value=True)
assert freqtrade.execute_buy(pair, stake_amount)
freqtrade.strategy.confirm_trade_entry = MagicMock(return_value=False)
assert not freqtrade.execute_buy(pair, stake_amount)
def test_add_stoploss_on_exchange(mocker, default_conf, limit_buy_order) -> None:
patch_RPCManager(mocker)
patch_exchange(mocker)