Fix some coingecko spellings

This commit is contained in:
Matthias 2024-04-25 10:27:16 +02:00
parent 3ca0be7543
commit 2d9be6c818
3 changed files with 13 additions and 13 deletions

View File

@ -39,7 +39,7 @@ class CryptoToFiatConverter(LoggingMixin):
This object is also a Singleton
"""
__instance = None
_coingekko: CoinGeckoAPI = None
_coingecko: CoinGeckoAPI = None
_coinlistings: List[Dict] = []
_backoff: float = 0.0
@ -52,9 +52,9 @@ class CryptoToFiatConverter(LoggingMixin):
try:
# Limit retires to 1 (0 and 1)
# otherwise we risk bot impact if coingecko is down.
CryptoToFiatConverter._coingekko = CoinGeckoAPI(retries=1)
CryptoToFiatConverter._coingecko = CoinGeckoAPI(retries=1)
except BaseException:
CryptoToFiatConverter._coingekko = None
CryptoToFiatConverter._coingecko = None
return CryptoToFiatConverter.__instance
def __init__(self) -> None:
@ -67,7 +67,7 @@ class CryptoToFiatConverter(LoggingMixin):
def _load_cryptomap(self) -> None:
try:
# Use list-comprehension to ensure we get a list.
self._coinlistings = [x for x in self._coingekko.get_coins_list()]
self._coinlistings = [x for x in self._coingecko.get_coins_list()]
except RequestException as request_exception:
if "429" in str(request_exception):
logger.warning(
@ -191,7 +191,7 @@ class CryptoToFiatConverter(LoggingMixin):
try:
return float(
self._coingekko.get_price(
self._coingecko.get_price(
ids=_gekko_id,
vs_currencies=fiat_symbol
)[_gekko_id][fiat_symbol]

View File

@ -490,10 +490,10 @@ def user_dir(mocker, tmp_path) -> Path:
@pytest.fixture(autouse=True)
def patch_coingekko(mocker) -> None:
def patch_coingecko(mocker) -> None:
"""
Mocker to coingekko to speed up tests
:param mocker: mocker to patch coingekko class
Mocker to coingecko to speed up tests
:param mocker: mocker to patch coingecko class
:return: None
"""

View File

@ -109,16 +109,16 @@ def test_fiat_init_network_exception(mocker):
def test_fiat_convert_without_network(mocker):
# Because CryptoToFiatConverter is a Singleton we reset the value of _coingekko
# Because CryptoToFiatConverter is a Singleton we reset the value of _coingecko
fiat_convert = CryptoToFiatConverter()
cmc_temp = CryptoToFiatConverter._coingekko
CryptoToFiatConverter._coingekko = None
cmc_temp = CryptoToFiatConverter._coingecko
CryptoToFiatConverter._coingecko = None
assert fiat_convert._coingekko is None
assert fiat_convert._coingecko is None
assert fiat_convert._find_price(crypto_symbol='btc', fiat_symbol='usd') == 0.0
CryptoToFiatConverter._coingekko = cmc_temp
CryptoToFiatConverter._coingecko = cmc_temp
def test_fiat_too_many_requests_response(mocker, caplog):