criado ficheiro 'constants.py' para isolar chave API para CoinGecko
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
.vscode/settings.json
|
||||
modulos/constantes.py
|
||||
|
||||
@ -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.
BIN
modulos/__pycache__/constantes.cpython-312.pyc
Normal file
BIN
modulos/__pycache__/constantes.cpython-312.pyc
Normal file
Binary file not shown.
@ -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/'
|
||||
|
||||
@ -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()
|
||||
Reference in New Issue
Block a user