From b6ac898f8f3c6e3eee4142da45313c629ab49059 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 28 Sep 2019 10:45:16 +0200 Subject: [PATCH] Add test for exception handler --- tests/exchange/test_exchange.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/exchange/test_exchange.py b/tests/exchange/test_exchange.py index 081a36e19..707a815d1 100644 --- a/tests/exchange/test_exchange.py +++ b/tests/exchange/test_exchange.py @@ -1371,9 +1371,6 @@ def test_get_historic_trades(default_conf, mocker, caplog, exchange_name, trades exchange._async_get_trade_history_id = get_mock_coro((pair, trades_history)) exchange._async_get_trade_history_time = get_mock_coro((pair, trades_history)) - # one_call calculation * 1.8 should do 2 calls - since = 5 * 60 * 500 * 1.8 - print(f"since = {since}") ret = exchange.get_historic_trades(pair, since=trades_history[0]["timestamp"], until=trades_history[-1]["timestamp"]) @@ -1386,6 +1383,20 @@ def test_get_historic_trades(default_conf, mocker, caplog, exchange_name, trades assert len(ret[1]) == 3 +@pytest.mark.parametrize("exchange_name", EXCHANGES) +def test_get_historic_trades_notsupported(default_conf, mocker, caplog, exchange_name, + trades_history): + mocker.patch('freqtrade.exchange.Exchange.exchange_has', return_value=False) + exchange = get_patched_exchange(mocker, default_conf, id=exchange_name) + + pair = 'ETH/BTC' + + with pytest.raises(OperationalException, + match="This exchange does not suport downloading Trades."): + exchange.get_historic_trades(pair, since=trades_history[0]["timestamp"], + until=trades_history[-1]["timestamp"]) + + @pytest.mark.parametrize("exchange_name", EXCHANGES) def test_cancel_order_dry_run(default_conf, mocker, exchange_name): default_conf['dry_run'] = True