Mock ccxt.exchange.has as property instead of method for tests.

This commit is contained in:
enenn 2018-02-09 22:43:32 +01:00
parent a5f179c18e
commit f2fa75a4ec
2 changed files with 3 additions and 2 deletions

View File

@ -210,7 +210,7 @@ def get_ticker(pair: str, refresh: Optional[bool] = True) -> dict:
@cached(TTLCache(maxsize=100, ttl=30))
def get_ticker_history(pair: str, tick_interval: str) -> List[Dict]:
if not _API.hasFetchOHLCV():
if 'fetchOHLCV' not in _API.has or not _API.has['fetchOHLCV']:
raise OperationalException(
'Exhange {} does not support fetching historical candlestick data.'.format(_API.name)
)

View File

@ -313,7 +313,8 @@ def test_get_ticker_history(default_conf, mocker):
5, # volume (in quote currency)
]
]
api_mock.hasFetchOHLVC = MagicMock(return_value=True)
has = PropertyMock(return_value={'fetchOHLCV': True})
type(api_mock).has = has
api_mock.fetch_ohlcv = MagicMock(return_value=tick)
mocker.patch('freqtrade.exchange._API', api_mock)