mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
Increase code coverage for FreqtradeBot.process_maybe_execute_sell()
This commit is contained in:
parent
5ec3eb76eb
commit
20082f52a2
|
@ -569,8 +569,10 @@ def test_process_maybe_execute_sell(mocker, default_conf, limit_buy_order, caplo
|
|||
trade.open_fee = 0.001
|
||||
assert not freqtrade.process_maybe_execute_sell(trade)
|
||||
# Test amount not modified by fee-logic
|
||||
assert not log_has('Applying fee to amount for Trade {} from 90.99181073 to 90.81'.format(
|
||||
trade), caplog.record_tuples)
|
||||
assert not log_has(
|
||||
'Applying fee to amount for Trade {} from 90.99181073 to 90.81'.format(trade),
|
||||
caplog.record_tuples
|
||||
)
|
||||
|
||||
mocker.patch('freqtrade.freqtradebot.FreqtradeBot.get_real_amount', return_value=90.81)
|
||||
# test amount modified by fee-logic
|
||||
|
@ -581,6 +583,38 @@ def test_process_maybe_execute_sell(mocker, default_conf, limit_buy_order, caplo
|
|||
# Assert we call handle_trade() if trade is feasible for execution
|
||||
assert freqtrade.process_maybe_execute_sell(trade)
|
||||
|
||||
regexp = re.compile('Found open order for.*')
|
||||
assert filter(regexp.match, caplog.record_tuples)
|
||||
|
||||
|
||||
def test_process_maybe_execute_sell_exception(mocker, default_conf,
|
||||
limit_buy_order, caplog) -> None:
|
||||
"""
|
||||
Test the exceptions in process_maybe_execute_sell()
|
||||
"""
|
||||
freqtrade = get_patched_freqtradebot(mocker, default_conf)
|
||||
mocker.patch('freqtrade.freqtradebot.exchange.get_order', return_value=limit_buy_order)
|
||||
|
||||
trade = MagicMock()
|
||||
trade.open_order_id = '123'
|
||||
trade.open_fee = 0.001
|
||||
|
||||
# Test raise of OperationalException exception
|
||||
mocker.patch(
|
||||
'freqtrade.freqtradebot.FreqtradeBot.get_real_amount',
|
||||
side_effect=OperationalException()
|
||||
)
|
||||
freqtrade.process_maybe_execute_sell(trade)
|
||||
assert log_has('could not update trade amount: ', caplog.record_tuples)
|
||||
|
||||
# Test raise of DependencyException exception
|
||||
mocker.patch(
|
||||
'freqtrade.freqtradebot.FreqtradeBot.get_real_amount',
|
||||
side_effect=DependencyException()
|
||||
)
|
||||
freqtrade.process_maybe_execute_sell(trade)
|
||||
assert log_has('Unable to sell trade: ', caplog.record_tuples)
|
||||
|
||||
|
||||
def test_handle_trade(default_conf, limit_buy_order, limit_sell_order, fee, mocker) -> None:
|
||||
"""
|
||||
|
@ -1355,7 +1389,7 @@ def test_get_real_amount_no_trade(default_conf, buy_order_fee, caplog, mocker):
|
|||
caplog.record_tuples)
|
||||
|
||||
|
||||
def test_get_real_amount_stake(default_conf, trades_for_order, buy_order_fee, caplog, mocker):
|
||||
def test_get_real_amount_stake(default_conf, trades_for_order, buy_order_fee, mocker):
|
||||
"""
|
||||
Test get_real_amount - fees in Stake currency
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue
Block a user