Update test to verify we're not spamming messages

This commit is contained in:
Matthias
2020-05-17 11:12:30 +02:00
parent dd55d2eea3
commit 2074d986a6
2 changed files with 26 additions and 9 deletions

View File

@@ -2407,30 +2407,47 @@ def test_handle_cancel_buy_corder_empty(mocker, default_conf, limit_buy_order,
assert cancel_order_mock.call_count == 1
def test_handle_cancel_sell_limit(mocker, default_conf) -> None:
patch_RPCManager(mocker)
def test_handle_cancel_sell_limit(mocker, default_conf, fee) -> None:
send_msg_mock = patch_RPCManager(mocker)
patch_exchange(mocker)
cancel_order_mock = MagicMock()
mocker.patch.multiple(
'freqtrade.exchange.Exchange',
cancel_order=cancel_order_mock
cancel_order=cancel_order_mock,
)
mocker.patch('freqtrade.freqtradebot.FreqtradeBot.get_sell_rate', return_value=0.245441)
freqtrade = FreqtradeBot(default_conf)
freqtrade._notify_sell_cancel = MagicMock()
trade = MagicMock()
trade = Trade(
pair='LTC/ETH',
amount=2,
exchange='binance',
open_rate=0.245441,
open_order_id="123456",
open_date=arrow.utcnow().datetime,
fee_open=fee.return_value,
fee_close=fee.return_value,
)
order = {'remaining': 1,
'amount': 1,
'status': "open"}
reason = CANCEL_REASON['TIMEOUT']
assert freqtrade.handle_cancel_sell(trade, order, reason)
assert cancel_order_mock.call_count == 1
assert send_msg_mock.call_count == 1
send_msg_mock.reset_mock()
order['amount'] = 2
assert (freqtrade.handle_cancel_sell(trade, order, reason)
== CANCEL_REASON['PARTIALLY_FILLED'])
assert freqtrade.handle_cancel_sell(trade, order, reason) == CANCEL_REASON['PARTIALLY_FILLED']
# Assert cancel_order was not called (callcount remains unchanged)
assert cancel_order_mock.call_count == 1
assert send_msg_mock.call_count == 1
assert freqtrade.handle_cancel_sell(trade, order, reason) == CANCEL_REASON['PARTIALLY_FILLED']
# Message should not be iterated again
assert trade.sell_order_status == CANCEL_REASON['PARTIALLY_FILLED']
assert send_msg_mock.call_count == 1
def test_handle_cancel_sell_cancel_exception(mocker, default_conf) -> None: