Improve test
This commit is contained in:
parent
06b12c0a70
commit
d84cb3be77
@ -5,7 +5,7 @@ import pytest
|
|||||||
|
|
||||||
from freqtrade.data.dataprovider import DataProvider
|
from freqtrade.data.dataprovider import DataProvider
|
||||||
from freqtrade.pairlist.pairlistmanager import PairListManager
|
from freqtrade.pairlist.pairlistmanager import PairListManager
|
||||||
from freqtrade.exceptions import OperationalException
|
from freqtrade.exceptions import DependencyException, OperationalException
|
||||||
from freqtrade.state import RunMode
|
from freqtrade.state import RunMode
|
||||||
from tests.conftest import get_patched_exchange
|
from tests.conftest import get_patched_exchange
|
||||||
|
|
||||||
@ -154,19 +154,20 @@ def test_market(mocker, default_conf, markets):
|
|||||||
assert res is None
|
assert res is None
|
||||||
|
|
||||||
|
|
||||||
def test_ticker(mocker, default_conf, tickers, markets):
|
def test_ticker(mocker, default_conf, tickers):
|
||||||
api_mock = MagicMock()
|
ticker_mock = MagicMock(return_value=tickers()['ETH/BTC'])
|
||||||
api_mock.markets = markets
|
mocker.patch("freqtrade.exchange.Exchange.fetch_ticker", ticker_mock)
|
||||||
api_mock.fetch_ticker = MagicMock(side_effect=lambda x: tickers().get(x))
|
exchange = get_patched_exchange(mocker, default_conf)
|
||||||
exchange = get_patched_exchange(mocker, default_conf, api_mock=api_mock)
|
|
||||||
|
|
||||||
dp = DataProvider(default_conf, exchange)
|
dp = DataProvider(default_conf, exchange)
|
||||||
res = dp.ticker('ETH/BTC')
|
res = dp.ticker('ETH/BTC')
|
||||||
|
|
||||||
assert type(res) is dict
|
assert type(res) is dict
|
||||||
assert 'symbol' in res
|
assert 'symbol' in res
|
||||||
assert res['symbol'] == 'ETH/BTC'
|
assert res['symbol'] == 'ETH/BTC'
|
||||||
|
|
||||||
|
ticker_mock = MagicMock(side_effect=DependencyException('Pair not found'))
|
||||||
|
mocker.patch("freqtrade.exchange.Exchange.fetch_ticker", ticker_mock)
|
||||||
|
exchange = get_patched_exchange(mocker, default_conf)
|
||||||
|
dp = DataProvider(default_conf, exchange)
|
||||||
res = dp.ticker('UNITTEST/BTC')
|
res = dp.ticker('UNITTEST/BTC')
|
||||||
assert res == {}
|
assert res == {}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user