mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-28 13:01:38 +00:00
* small bug
* small bug on routines list
* guest as default
* limit logout to users2
* simpler this way
* add logout
* move logout to account & add env var
* put authentication under env var
* fix tests
* remove login
* remove openbb vars on login
* ruff
* revert .toml
* Delete Icon
* Update .env
* fix sdk guest not loading keys
* ruff
* remove press enter & --login
* ruff
* move env load
* load env
* move dot env loading to terminal.py
* fix user sdk login mixing .env with user
* now it works
* fix reset
* fix tests
* ruff
* Login on the SDK using the OpenBB Personal Access Token (#4206)
* openbb key on keys menu
* adding sdk endpoints
* adding login via token to the sdk
* base url
* rename to personal access token
* added docstrings and examples
* openbb is special
* removing extra break line
* making keys working with the personal access token
* resolve conflicting tests
* Revert "resolve conflicting tests"
This reverts commit 2fca2c0ec3.
* using custom requests
* tests
* tests
* tests
* using process_session_response instead
* rewriting some tests
* Fix sdk guest not loading keys (#4207)
* fix sdk guest not loading keys
* ruff
* remove comment
* tests
---------
Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com>
Co-authored-by: Diogo Sousa <montezdesousa@gmail.com>
Co-authored-by: James Maslek <jmaslek11@gmail.com>
* test record mode vcr none
* remove yes from tests yml
* specify modules to reload
* try disable check api
* UPdate spec file
* Small stocks bug
* avoid reloading in test mode
* will this work?
* skip session tests
* try with env var as well
* mock sdk reload
* pylint
* bump poetry on python 3.8
* adapt to python 3.8
* adapt to python 3.8 remaining tests
* Tests : update cassettes
* Fix linting
* Makes login conditions simpler
* Tests : txt
---------
Co-authored-by: James Maslek <jmaslek11@gmail.com>
Co-authored-by: Chavithra <chavithra@gmail.com>
Co-authored-by: Henrique Joaquim <h.joaquim@campus.fct.unl.pt>
254 lines
7.7 KiB
Python
254 lines
7.7 KiB
Python
import pytest
|
|
|
|
from openbb_terminal.keys_controller import KeysController
|
|
|
|
controller = KeysController(menu_usage=False)
|
|
|
|
# pylint: disable=R0902,R0903,W1404
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def no_change_env(mocker):
|
|
mocker.patch("openbb_terminal.keys_model.dotenv.set_key")
|
|
|
|
|
|
class MockCFG:
|
|
def __init__(self, **kwargs):
|
|
self.API_GITHUB_KEY = kwargs.get("GITHUB", None)
|
|
self.API_KEY_ALPHAVANTAGE = kwargs.get("AV", None)
|
|
self.API_KEY_FINANCIALMODELINGPREP = kwargs.get("FMP", None)
|
|
self.API_KEY_QUANDL = kwargs.get("QUANDL", None)
|
|
self.API_POLYGON_KEY = kwargs.get("POLYGON", None)
|
|
self.API_FRED_KEY = kwargs.get("FRED", None)
|
|
self.API_NEWS_TOKEN = kwargs.get("NEWS", None)
|
|
self.API_TRADIER_TOKEN = kwargs.get("TRADIER", None)
|
|
self.API_CMC_KEY = kwargs.get("CMC", None)
|
|
self.API_FINNHUB_KEY = kwargs.get("FINNHUB", None)
|
|
self.API_IEX_TOKEN = kwargs.get("IEX", None)
|
|
self.API_REDDIT_CLIENT_ID = kwargs.get("REDDIT_CLIENT", None)
|
|
self.API_REDDIT_CLIENT_SECRET = kwargs.get("REDDIT_SECRET", None)
|
|
self.API_REDDIT_USERNAME = kwargs.get("REDDIT_USERNAME", None)
|
|
self.API_REDDIT_PASSWORD = kwargs.get("REDDIT_PASSWORD", None)
|
|
self.API_REDDIT_USER_AGENT = kwargs.get("REDDIT_USER", None)
|
|
self.API_TWITTER_KEY = kwargs.get("TWITTER", None)
|
|
self.API_TWITTER_SECRET_KEY = kwargs.get("TWITTER", None)
|
|
self.API_TWITTER_BEARER_TOKEN = kwargs.get("TWITTER", None)
|
|
self.RH_USERNAME = kwargs.get("RH", None)
|
|
self.RH_PASSWORD = kwargs.get("RH", None)
|
|
self.DG_USERNAME = kwargs.get("DEGIRO", None)
|
|
self.DG_PASSWORD = kwargs.get("DEGIRO", None)
|
|
self.DG_TOTP_SECRET = kwargs.get("DEGIRO", None)
|
|
self.OANDA_TOKEN = kwargs.get("OANDA", None)
|
|
self.OANDA_ACCOUNT = kwargs.get("OANDA", None)
|
|
self.API_BINANCE_KEY = kwargs.get("BINANCE", None)
|
|
self.API_BINANCE_SECRET = kwargs.get("BINANCE", None)
|
|
self.API_BITQUERY_KEY = kwargs.get("BITQUERY", None)
|
|
self.API_SENTIMENTINVESTOR_TOKEN = kwargs.get("SI", None)
|
|
self.API_COINBASE_KEY = kwargs.get("COINBASE", None)
|
|
self.API_COINBASE_SECRET = kwargs.get("COINBASE", None)
|
|
self.API_COINBASE_PASS_PHRASE = kwargs.get("COINBASE", None)
|
|
self.API_WHALE_ALERT_KEY = kwargs.get("WALERT", None)
|
|
self.API_GLASSNODE_KEY = kwargs.get("GLASSNODE", None)
|
|
self.API_COINGLASS_KEY = kwargs.get("COINGLASS", None)
|
|
self.API_CRYPTO_PANIC_KEY = kwargs.get("CPANIC", None)
|
|
self.API_ETHPLORER_KEY = kwargs.get("ETHPLOR", None)
|
|
self.API_SMARTSTAKE_TOKEN = kwargs.get("SMARTSTAKE", None)
|
|
self.API_SMARTSTAKE_KEY = kwargs.get("SMARTSTAKE", None)
|
|
self.API_MESSARI_KEY = kwargs.get("MESSARI", None)
|
|
self.API_SANTIMENT_KEY = kwargs.get("SANTIMENT", None)
|
|
self.API_TOKENTERMINAL_KEY = kwargs.get("TOKENTERMINAL", None)
|
|
self.API_SHROOM_KEY = kwargs.get("SHROOM", None)
|
|
|
|
|
|
@pytest.mark.skip
|
|
def test_print_help(mocker):
|
|
mocker.patch("openbb_terminal.keys_controller.KeysController.check_keys_status")
|
|
controller.print_help()
|
|
|
|
|
|
@pytest.mark.vcr
|
|
@pytest.mark.parametrize("other", [[], ["-k", "1234"], ["1234"]])
|
|
def test_call_av(other):
|
|
controller.call_av(other)
|
|
|
|
|
|
@pytest.mark.vcr
|
|
@pytest.mark.parametrize("other", [[], ["-k", "1234"], ["1234"]])
|
|
def test_call_fmp(other):
|
|
controller.call_fmp(other)
|
|
|
|
|
|
@pytest.mark.vcr
|
|
@pytest.mark.parametrize("other", [[], ["-k", "1234"], ["1234"]])
|
|
def test_call_quandl(other):
|
|
controller.call_quandl(other)
|
|
|
|
|
|
@pytest.mark.vcr
|
|
@pytest.mark.parametrize("other", [[], ["-k", "1234"], ["1234"]])
|
|
def test_call_polygon(other):
|
|
controller.call_polygon(other)
|
|
|
|
|
|
@pytest.mark.vcr
|
|
@pytest.mark.parametrize("other", [[], ["-k", "1234"], ["1234"]])
|
|
def test_call_fred(other):
|
|
controller.call_fred(other)
|
|
|
|
|
|
@pytest.mark.vcr
|
|
@pytest.mark.parametrize("other", [[], ["-k", "1234"], ["1234"]])
|
|
def test_call_news(other):
|
|
controller.call_news(other)
|
|
|
|
|
|
@pytest.mark.vcr
|
|
@pytest.mark.parametrize("other", [[], ["-k", "1234"], ["1234"]])
|
|
def test_call_tradier(other):
|
|
controller.call_tradier(other)
|
|
|
|
|
|
@pytest.mark.vcr
|
|
@pytest.mark.parametrize("other", [[], ["-k", "1234"], ["1234"]])
|
|
def test_call_cmc(other):
|
|
controller.call_cmc(other)
|
|
|
|
|
|
@pytest.mark.vcr
|
|
@pytest.mark.parametrize("other", [[], ["-k", "1234"]])
|
|
def test_call_finnhub(other):
|
|
controller.call_finnhub(other)
|
|
|
|
|
|
@pytest.mark.vcr
|
|
@pytest.mark.parametrize(
|
|
"other", [[], ["-i", "1234", "-s", "4", "-u", "5", "-p", "6", "-a", "7"]]
|
|
)
|
|
def test_call_reddit(other):
|
|
controller.call_reddit(other)
|
|
|
|
|
|
@pytest.mark.vcr
|
|
@pytest.mark.parametrize("other", [[], ["-k", "1234", "-s", "4567", "-t", "890"]])
|
|
def test_call_twitter(other):
|
|
controller.call_twitter(other)
|
|
|
|
|
|
@pytest.mark.vcr
|
|
@pytest.mark.parametrize("other", [[], ["-u", "1234", "-p", "4567"]])
|
|
def test_call_rh(other):
|
|
controller.call_rh(other)
|
|
|
|
|
|
@pytest.mark.vcr
|
|
@pytest.mark.parametrize("other", [[], ["-u", "1234", "-p" "4567", "-s" "890"]])
|
|
def test_call_degiro(other):
|
|
controller.call_degiro(other)
|
|
|
|
|
|
@pytest.mark.vcr
|
|
@pytest.mark.parametrize("other", [[], ["-a", "1234", "-t", "4567", "-at", "practice"]])
|
|
def test_call_oanda(other):
|
|
controller.call_oanda(other)
|
|
|
|
|
|
@pytest.mark.vcr
|
|
@pytest.mark.parametrize("other", [[], ["-k", "1234", "-s", "4567"]])
|
|
def test_call_binance(other):
|
|
controller.call_binance(other)
|
|
|
|
|
|
@pytest.mark.vcr
|
|
@pytest.mark.parametrize("other", [[], ["-k", "1234"], ["1234"]])
|
|
def test_call_bitquery(other):
|
|
controller.call_bitquery(other)
|
|
|
|
|
|
@pytest.mark.vcr
|
|
@pytest.mark.parametrize("other", [[], ["-k", "1234", "-s", "4567", "-p" "890"]])
|
|
def test_call_coinbase(other):
|
|
controller.call_coinbase(other)
|
|
|
|
|
|
@pytest.mark.vcr
|
|
@pytest.mark.parametrize("other", [[], ["-k", "1234"], ["1234"]])
|
|
def test_call_walert(other):
|
|
controller.call_walert(other)
|
|
|
|
|
|
@pytest.mark.vcr
|
|
@pytest.mark.parametrize("other", [[], ["-k", "1234"], ["1234"]])
|
|
def test_call_glassnode(other):
|
|
controller.call_glassnode(other)
|
|
|
|
|
|
@pytest.mark.vcr
|
|
@pytest.mark.parametrize("other", [[], ["-k", "1234"], ["1234"]])
|
|
def test_call_coinglass(other):
|
|
controller.call_coinglass(other)
|
|
|
|
|
|
@pytest.mark.vcr
|
|
@pytest.mark.parametrize("other", [[], ["-k", "1234"], ["1234"]])
|
|
def test_call_cpanic(other):
|
|
controller.call_cpanic(other)
|
|
|
|
|
|
@pytest.mark.vcr
|
|
@pytest.mark.parametrize("other", [[], ["-k", "1234"], ["1234"]])
|
|
def test_call_ethplorer(other):
|
|
controller.call_ethplorer(other)
|
|
|
|
|
|
@pytest.mark.vcr
|
|
@pytest.mark.parametrize("other", [[], ["-k", "1234", "-t", "456"]])
|
|
def test_call_smartstake(other):
|
|
controller.call_smartstake(other)
|
|
|
|
|
|
@pytest.mark.vcr
|
|
@pytest.mark.parametrize("other", [[], ["-k", "1234"], ["1234"]])
|
|
def test_call_github(other):
|
|
controller.call_github(other)
|
|
|
|
|
|
@pytest.mark.vcr
|
|
@pytest.mark.parametrize("other", [[], ["-k", "1234"], ["1234"]])
|
|
def test_call_santiment(other):
|
|
controller.call_santiment(other)
|
|
|
|
|
|
@pytest.mark.vcr
|
|
@pytest.mark.parametrize("other", [[], ["-k", "1234", "-t", "456"]])
|
|
def test_call_messari(other):
|
|
controller.call_messari(other)
|
|
|
|
|
|
@pytest.mark.vcr
|
|
@pytest.mark.parametrize("other", [[], ["-k", "1234", "-t", "456"]])
|
|
def test_call_tokenterminal(other):
|
|
controller.call_tokenterminal(other)
|
|
|
|
|
|
@pytest.mark.vcr
|
|
@pytest.mark.parametrize("other", [[], ["-k", "1234", "-t", "456"]])
|
|
def test_call_shroom(other):
|
|
controller.call_shroom(other)
|
|
|
|
|
|
@pytest.mark.vcr
|
|
@pytest.mark.parametrize("other", [[], ["-k", "1234", "-t", "456"]])
|
|
def test_call_openbb(mocker, other):
|
|
# MOCK GET
|
|
attrs = {
|
|
"status_code": 200,
|
|
"json.return_value": {"token": "MOCK_TOKEN"},
|
|
}
|
|
mock_response = mocker.Mock(**attrs)
|
|
mocker.patch(
|
|
target="openbb_terminal.keys_model.request",
|
|
new=mocker.Mock(return_value=mock_response),
|
|
)
|
|
|
|
controller.call_openbb(other)
|