rename test-function
This commit is contained in:
parent
15c7854e7f
commit
dcdc18a338
@ -14,8 +14,8 @@ from freqtrade.exchange import Exchange, API_RETRY_COUNT
|
||||
from freqtrade.tests.conftest import log_has, get_patched_exchange
|
||||
|
||||
|
||||
def validate_exceptionhandlers(mocker, default_conf, api_mock, fun, innerfun, **kwargs):
|
||||
"""Function to test exception handling """
|
||||
def ccxt_exceptionhandlers(mocker, default_conf, api_mock, fun, innerfun, **kwargs):
|
||||
"""Function to test ccxt exception handling """
|
||||
|
||||
with pytest.raises(TemporaryError):
|
||||
api_mock.__dict__[innerfun] = MagicMock(side_effect=ccxt.NetworkError)
|
||||
@ -278,7 +278,7 @@ def test_get_balances_prod(default_conf, mocker):
|
||||
assert exchange.get_balances()['1ST']['total'] == 10.0
|
||||
assert exchange.get_balances()['1ST']['used'] == 0.0
|
||||
|
||||
validate_exceptionhandlers(mocker, default_conf, api_mock,
|
||||
ccxt_exceptionhandlers(mocker, default_conf, api_mock,
|
||||
"get_balances", "fetch_balance")
|
||||
|
||||
|
||||
@ -308,7 +308,7 @@ def test_get_tickers(default_conf, mocker):
|
||||
assert tickers['BCH/BTC']['bid'] == 0.6
|
||||
assert tickers['BCH/BTC']['ask'] == 0.5
|
||||
|
||||
validate_exceptionhandlers(mocker, default_conf, api_mock,
|
||||
ccxt_exceptionhandlers(mocker, default_conf, api_mock,
|
||||
"get_tickers", "fetch_tickers")
|
||||
|
||||
with pytest.raises(OperationalException):
|
||||
@ -364,7 +364,7 @@ def test_get_ticker(default_conf, mocker):
|
||||
exchange.get_ticker(pair='ETH/BTC', refresh=False)
|
||||
assert api_mock.fetch_ticker.call_count == 0
|
||||
|
||||
validate_exceptionhandlers(mocker, default_conf, api_mock,
|
||||
ccxt_exceptionhandlers(mocker, default_conf, api_mock,
|
||||
"get_ticker", "fetch_ticker",
|
||||
pair='ETH/BTC', refresh=True)
|
||||
|
||||
@ -429,7 +429,7 @@ def test_get_ticker_history(default_conf, mocker):
|
||||
assert ticks[0][4] == 9
|
||||
assert ticks[0][5] == 10
|
||||
|
||||
validate_exceptionhandlers(mocker, default_conf, api_mock,
|
||||
ccxt_exceptionhandlers(mocker, default_conf, api_mock,
|
||||
"get_ticker_history", "fetch_ohlcv",
|
||||
pair='ABCD/BTC', tick_interval=default_conf['ticker_interval'])
|
||||
|
||||
@ -531,7 +531,7 @@ def test_cancel_order(default_conf, mocker):
|
||||
exchange.cancel_order(order_id='_', pair='TKN/BTC')
|
||||
assert api_mock.cancel_order.call_count == API_RETRY_COUNT + 1
|
||||
|
||||
validate_exceptionhandlers(mocker, default_conf, api_mock,
|
||||
ccxt_exceptionhandlers(mocker, default_conf, api_mock,
|
||||
"cancel_order", "cancel_order",
|
||||
order_id='_', pair='TKN/BTC')
|
||||
|
||||
@ -557,7 +557,7 @@ def test_get_order(default_conf, mocker):
|
||||
exchange.get_order(order_id='_', pair='TKN/BTC')
|
||||
assert api_mock.fetch_order.call_count == API_RETRY_COUNT + 1
|
||||
|
||||
validate_exceptionhandlers(mocker, default_conf, api_mock,
|
||||
ccxt_exceptionhandlers(mocker, default_conf, api_mock,
|
||||
'get_order', 'fetch_order',
|
||||
order_id='_', pair='TKN/BTC')
|
||||
|
||||
@ -644,7 +644,7 @@ def test_get_trades_for_order(default_conf, mocker):
|
||||
assert len(orders) == 1
|
||||
assert orders[0]['price'] == 165
|
||||
|
||||
validate_exceptionhandlers(mocker, default_conf, api_mock,
|
||||
ccxt_exceptionhandlers(mocker, default_conf, api_mock,
|
||||
'get_trades_for_order', 'fetch_my_trades',
|
||||
order_id=order_id, pair='LTC/BTC', since=since)
|
||||
|
||||
@ -663,7 +663,7 @@ def test_get_markets(default_conf, mocker, markets):
|
||||
assert ret[0]["id"] == "ethbtc"
|
||||
assert ret[0]["symbol"] == "ETH/BTC"
|
||||
|
||||
validate_exceptionhandlers(mocker, default_conf, api_mock,
|
||||
ccxt_exceptionhandlers(mocker, default_conf, api_mock,
|
||||
'get_markets', 'fetch_markets')
|
||||
|
||||
|
||||
@ -679,7 +679,7 @@ def test_get_fee(default_conf, mocker):
|
||||
|
||||
assert exchange.get_fee() == 0.025
|
||||
|
||||
validate_exceptionhandlers(mocker, default_conf, api_mock,
|
||||
ccxt_exceptionhandlers(mocker, default_conf, api_mock,
|
||||
'get_fee', 'calculate_fee')
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user