Cover a edge case of CryptoToFiatConverter::_find_price()
This commit is contained in:
parent
dfbc94c05b
commit
5ec3eb76eb
@ -192,6 +192,7 @@ class CryptoToFiatConverter(object):
|
||||
# return 0 for unsupported stake currencies (fiat-convert should not break the bot)
|
||||
logger.warning("unsupported crypto-symbol %s - returning 0.0", crypto_symbol)
|
||||
return 0.0
|
||||
|
||||
try:
|
||||
return float(
|
||||
self._coinmarketcap.ticker(
|
||||
|
@ -9,7 +9,7 @@ import pytest
|
||||
from requests.exceptions import RequestException
|
||||
|
||||
from freqtrade.fiat_convert import CryptoFiat, CryptoToFiatConverter
|
||||
from freqtrade.tests.conftest import patch_coinmarketcap
|
||||
from freqtrade.tests.conftest import log_has, patch_coinmarketcap
|
||||
|
||||
|
||||
def test_pair_convertion_object():
|
||||
@ -90,6 +90,13 @@ def test_fiat_convert_find_price(mocker):
|
||||
assert fiat_convert.get_price(crypto_symbol='BTC', fiat_symbol='EUR') == 13000.2
|
||||
|
||||
|
||||
def test_fiat_convert_unsupported_crypto(mocker, caplog):
|
||||
mocker.patch('freqtrade.fiat_convert.CryptoToFiatConverter._cryptomap', return_value=[])
|
||||
fiat_convert = CryptoToFiatConverter()
|
||||
assert fiat_convert._find_price(crypto_symbol='CRYPTO_123', fiat_symbol='EUR') == 0.0
|
||||
assert log_has('unsupported crypto-symbol CRYPTO_123 - returning 0.0', caplog.record_tuples)
|
||||
|
||||
|
||||
def test_fiat_convert_get_price(mocker):
|
||||
api_mock = MagicMock(return_value={
|
||||
'price_usd': 28000.0,
|
||||
|
Loading…
Reference in New Issue
Block a user