Update remaining exchange mock occurances

This commit is contained in:
Matthias 2023-03-01 20:19:14 +01:00
parent 2ca8b0b12e
commit feabed30a3
3 changed files with 8 additions and 8 deletions

View File

@ -3120,24 +3120,24 @@ def test_cancel_stoploss_order(default_conf, mocker, exchange_name):
def test_cancel_stoploss_order_with_result(default_conf, mocker, exchange_name): def test_cancel_stoploss_order_with_result(default_conf, mocker, exchange_name):
default_conf['dry_run'] = False default_conf['dry_run'] = False
mocker.patch(f'{EXMS}.fetch_stoploss_order', return_value={'for': 123}) mocker.patch(f'{EXMS}.fetch_stoploss_order', return_value={'for': 123})
mocker.patch('freqtrade.exchange.Gate.fetch_stoploss_order', return_value={'for': 123}) mocker.patch('freqtrade.exchange.gate.Gate.fetch_stoploss_order', return_value={'for': 123})
exchange = get_patched_exchange(mocker, default_conf, id=exchange_name) exchange = get_patched_exchange(mocker, default_conf, id=exchange_name)
res = {'fee': {}, 'status': 'canceled', 'amount': 1234} res = {'fee': {}, 'status': 'canceled', 'amount': 1234}
mocker.patch(f'{EXMS}.cancel_stoploss_order', return_value=res) mocker.patch(f'{EXMS}.cancel_stoploss_order', return_value=res)
mocker.patch('freqtrade.exchange.Gate.cancel_stoploss_order', return_value=res) mocker.patch('freqtrade.exchange.gate.Gate.cancel_stoploss_order', return_value=res)
co = exchange.cancel_stoploss_order_with_result(order_id='_', pair='TKN/BTC', amount=555) co = exchange.cancel_stoploss_order_with_result(order_id='_', pair='TKN/BTC', amount=555)
assert co == res assert co == res
mocker.patch(f'{EXMS}.cancel_stoploss_order', return_value='canceled') mocker.patch(f'{EXMS}.cancel_stoploss_order', return_value='canceled')
mocker.patch('freqtrade.exchange.Gate.cancel_stoploss_order', return_value='canceled') mocker.patch('freqtrade.exchange.gate.Gate.cancel_stoploss_order', return_value='canceled')
# Fall back to fetch_stoploss_order # Fall back to fetch_stoploss_order
co = exchange.cancel_stoploss_order_with_result(order_id='_', pair='TKN/BTC', amount=555) co = exchange.cancel_stoploss_order_with_result(order_id='_', pair='TKN/BTC', amount=555)
assert co == {'for': 123} assert co == {'for': 123}
exc = InvalidOrderException("") exc = InvalidOrderException("")
mocker.patch(f'{EXMS}.fetch_stoploss_order', side_effect=exc) mocker.patch(f'{EXMS}.fetch_stoploss_order', side_effect=exc)
mocker.patch('freqtrade.exchange.Gate.fetch_stoploss_order', side_effect=exc) mocker.patch('freqtrade.exchange.gate.Gate.fetch_stoploss_order', side_effect=exc)
co = exchange.cancel_stoploss_order_with_result(order_id='_', pair='TKN/BTC', amount=555) co = exchange.cancel_stoploss_order_with_result(order_id='_', pair='TKN/BTC', amount=555)
assert co['amount'] == 555 assert co['amount'] == 555
assert co == {'fee': {}, 'status': 'canceled', 'amount': 555, 'info': {}} assert co == {'fee': {}, 'status': 'canceled', 'amount': 555, 'info': {}}
@ -3145,7 +3145,7 @@ def test_cancel_stoploss_order_with_result(default_conf, mocker, exchange_name):
with pytest.raises(InvalidOrderException): with pytest.raises(InvalidOrderException):
exc = InvalidOrderException("Did not find order") exc = InvalidOrderException("Did not find order")
mocker.patch(f'{EXMS}.cancel_stoploss_order', side_effect=exc) mocker.patch(f'{EXMS}.cancel_stoploss_order', side_effect=exc)
mocker.patch('freqtrade.exchange.Gate.cancel_stoploss_order', side_effect=exc) mocker.patch('freqtrade.exchange.gate.Gate.cancel_stoploss_order', side_effect=exc)
exchange = get_patched_exchange(mocker, default_conf, id=exchange_name) exchange = get_patched_exchange(mocker, default_conf, id=exchange_name)
exchange.cancel_stoploss_order_with_result(order_id='_', pair='TKN/BTC', amount=123) exchange.cancel_stoploss_order_with_result(order_id='_', pair='TKN/BTC', amount=123)

View File

@ -146,8 +146,8 @@ def test_kucoin_create_order(default_conf, mocker, side, ordertype, rate):
'amount': 1 'amount': 1
}) })
default_conf['dry_run'] = False default_conf['dry_run'] = False
mocker.patch('freqtrade.exchange.Exchange.amount_to_precision', lambda s, x, y: y) mocker.patch(f'{EXMS}.amount_to_precision', lambda s, x, y: y)
mocker.patch('freqtrade.exchange.Exchange.price_to_precision', lambda s, x, y: y) mocker.patch(f'{EXMS}.price_to_precision', lambda s, x, y: y)
exchange = get_patched_exchange(mocker, default_conf, api_mock, id='kucoin') exchange = get_patched_exchange(mocker, default_conf, api_mock, id='kucoin')
exchange._set_leverage = MagicMock() exchange._set_leverage = MagicMock()
exchange.set_margin_mode = MagicMock() exchange.set_margin_mode = MagicMock()

View File

@ -46,7 +46,7 @@ def test_get_maintenance_ratio_and_amt_okx(
default_conf['margin_mode'] = 'isolated' default_conf['margin_mode'] = 'isolated'
default_conf['dry_run'] = False default_conf['dry_run'] = False
mocker.patch.multiple( mocker.patch.multiple(
'freqtrade.exchange.Okx', 'freqtrade.exchange.okx.Okx',
exchange_has=MagicMock(return_value=True), exchange_has=MagicMock(return_value=True),
load_leverage_tiers=MagicMock(return_value={ load_leverage_tiers=MagicMock(return_value={
'ETH/USDT:USDT': [ 'ETH/USDT:USDT': [