criado ficheiro 'constants.py' para isolar chave API para CoinGecko

This commit is contained in:
2024-06-26 10:56:24 +01:00
parent f7fb66c356
commit dbe9a8c68c
6 changed files with 13 additions and 12 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
.vscode/settings.json
modulos/constantes.py

View File

@ -1,13 +1,6 @@
import modulos.coingecko_api as cgapi
import time
APY_KEY = "CG-K5RS5VXsdFDip2UvY3z8VjQP"
cgapi.headers = {
'accept': 'application/json',
'x-cg-demo-api-key': APY_KEY,
}
criptomoeda: str = 'bitcoin'
vs_currency: str = 'eur'
dias: str = '30'

Binary file not shown.

View File

@ -3,11 +3,11 @@
import requests
from typing import Any
from modulos.constantes import CHAVE_API_DEMO
CHAVE_API = 'CG-K5RS5VXsdFDip2UvY3z8VjQP'
headers = {
'accept': 'application/json',
'x-cg-demo-api-key': CHAVE_API
'x-cg-demo-api-key': CHAVE_API_DEMO
}
url_raiz_API = 'https://api.coingecko.com/api/v3/'

View File

@ -1,11 +1,14 @@
import unittest
import modulos.coingecko_api as cgapi
class Teste_API(unittest.TestCase):
'''teste API()'''
pass
def test_api_method(self):
url, codigo, data = cgapi.API('ping', {})
self.assertIsInstance(url, str)
self.assertEqual(codigo, 200)
self.assertIsInstance(data, dict)
class Teste_ping(unittest.TestCase):
@ -35,4 +38,8 @@ class Teste_coins_list(unittest.TestCase):
class Teste_coins_list_with_market_data(unittest.TestCase):
'''teste coins_list_with_market_data()'''
pass
pass
# unittest.main()
if __name__ == '__main__':
unittest.main()