mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 02:12:01 +00:00
Add test, invert logic
This commit is contained in:
parent
9e0ccb1cf4
commit
94e0a808b7
|
@ -16,10 +16,11 @@ class FtCoinGeckoApi(CoinGeckoAPI):
|
|||
# Doint' pass api_key to parent, instead set the header on the session directly
|
||||
self._api_key = api_key
|
||||
|
||||
if api_key and is_demo:
|
||||
# Use demo api key
|
||||
self.api_base_url = self.__API_URL_BASE
|
||||
self.session.params.update({"x_cg_demo_api_key": api_key})
|
||||
else:
|
||||
if api_key and not is_demo:
|
||||
self.api_base_url = self.__PRO_API_URL_BASE
|
||||
self.session.params.update({"x_cg_pro_api_key": api_key})
|
||||
else:
|
||||
# Use demo api key
|
||||
self.api_base_url = self.__API_URL_BASE
|
||||
if api_key:
|
||||
self.session.params.update({"x_cg_demo_api_key": api_key})
|
||||
|
|
|
@ -8,6 +8,7 @@ import pytest
|
|||
from requests.exceptions import RequestException
|
||||
|
||||
from freqtrade.rpc.fiat_convert import CryptoToFiatConverter
|
||||
from freqtrade.util.coin_gecko import FtCoinGeckoApi
|
||||
from tests.conftest import log_has, log_has_re
|
||||
|
||||
|
||||
|
@ -201,3 +202,18 @@ def test_convert_amount(mocker):
|
|||
crypto_amount="1.23", crypto_symbol="BTC", fiat_symbol="BTC"
|
||||
)
|
||||
assert result == 1.23
|
||||
|
||||
|
||||
def test_FtCoinGeckoApi():
|
||||
ftc = FtCoinGeckoApi()
|
||||
assert ftc._api_key == ""
|
||||
assert ftc.api_base_url == "https://api.coingecko.com/api/v3/"
|
||||
|
||||
# defaults to demo
|
||||
ftc = FtCoinGeckoApi(api_key="123456")
|
||||
assert ftc._api_key == "123456"
|
||||
assert ftc.api_base_url == "https://api.coingecko.com/api/v3/"
|
||||
|
||||
ftc = FtCoinGeckoApi(api_key="123456", is_demo=False)
|
||||
assert ftc._api_key == "123456"
|
||||
assert ftc.api_base_url == "https://pro-api.coingecko.com/api/v3/"
|
||||
|
|
Loading…
Reference in New Issue
Block a user