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.pairlist.pairlistmanager import PairListManager
|
||||
from freqtrade.exceptions import OperationalException
|
||||
from freqtrade.exceptions import DependencyException, OperationalException
|
||||
from freqtrade.state import RunMode
|
||||
from tests.conftest import get_patched_exchange
|
||||
|
||||
@ -154,19 +154,20 @@ def test_market(mocker, default_conf, markets):
|
||||
assert res is None
|
||||
|
||||
|
||||
def test_ticker(mocker, default_conf, tickers, markets):
|
||||
api_mock = MagicMock()
|
||||
api_mock.markets = markets
|
||||
api_mock.fetch_ticker = MagicMock(side_effect=lambda x: tickers().get(x))
|
||||
exchange = get_patched_exchange(mocker, default_conf, api_mock=api_mock)
|
||||
|
||||
def test_ticker(mocker, default_conf, tickers):
|
||||
ticker_mock = MagicMock(return_value=tickers()['ETH/BTC'])
|
||||
mocker.patch("freqtrade.exchange.Exchange.fetch_ticker", ticker_mock)
|
||||
exchange = get_patched_exchange(mocker, default_conf)
|
||||
dp = DataProvider(default_conf, exchange)
|
||||
res = dp.ticker('ETH/BTC')
|
||||
|
||||
assert type(res) is dict
|
||||
assert 'symbol' in res
|
||||
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')
|
||||
assert res == {}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user