mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-28 13:01:38 +00:00
* implement user and change is guest * replace User methods * move remaining functions to user * fix bug * portfolio test * fix tests * fix tests * uncomment skip * ruff * start credentials model implementation * change deault structure * refacto quandl * change default struct and file names * bug * start using global user * add comments * move update flair * change cfg references in keys model * reddit & fmp * refactore additional keys * remaing config keys * remove unsude imports and fix hub keys * ruff * fix line too long * unblock unittests * fix keys model tests * remove os patch * fix account controller tests * fix account controller tests * fix account model * account fixed * fix user tests * User Model * User Model * User Model * Move session folder * User Model : grouping the models * User Model : fix bugs * Config Plot + bug fix * User Model : Refactoring plots * Feature flags * Remove dup * clean comments a fix some vars * fix feature flags controller * refactor obbff from settings controller * refactor a bunch of obbff variables * fix bug blocking terminal * fix integration tests * refactor controllers with obbff * refactor remaining ffs * remove comments * log not started * mispelled variable * set current user on local model * User Model : moving files + updating * User Preferences * User : Refactor is_guest function + bug fix * User : refactor is_guest function * Fix conftest.py * remove lost obbffs * typo on fileoverwrite * Plot config: move variables and start plot dpi * User : tests * refactor plot dpi references * remove plot dpi imports * refactor some config terminal leftover * /account/sync : fix bug * remove configs reload * start path refactor * installation paths vs user paths * remove cfg_plot * Tests : User Refactoring * user prefix only for preferences * user prefix only for preferences * move user paths * remove comment * update apply remote configs * fix tz not updating * save some copys * small fix * create interface for credentials and preferences * wrong docstrings fixed * ruff core * fix some pref setting * login is better * ruff * ruff * remove Literal * add small comment * Tests : User Refactoring * Credentials Model : add DataBento * Fix helper_funcs * Fixing code * Tests : fixing * User Model : freezing the models * Fixed Income + Databento * Tests : fixing keys * black * ruff * Tests : user model * Tests : user model * Fix linting * Fix linting * Linting * Linting * Fixing code and tests * Fix tests * mypy * SDK * Clean ruff cache * Fix syntax issue * Update fred_view * Black * Linting * Update code * Update tests * Linting * Linting * Tests * Black * Linting * Linting * Mock os.listdir to avoid looking for file that doesnt exist * Mock options paths * lint * Tests : fix * Code : update * Tests + Linting * Tests * Ruff * Code : update * Tests * Code : update * Fix workflow * Code : update --------- Co-authored-by: Chavithra PARANA <chavithra@gmail.com> Co-authored-by: luqazino@gmail.com <luqazino@gmail.com> Co-authored-by: James Maslek <jmaslek11@gmail.com>
272 lines
8.1 KiB
Python
272 lines
8.1 KiB
Python
# IMPORTATION STANDARD
|
|
|
|
# IMPORTATION THIRDPARTY
|
|
import pytest
|
|
|
|
# IMPORTATION INTERNAL
|
|
from openbb_terminal.core.session.current_user import (
|
|
PreferencesModel,
|
|
copy_user,
|
|
)
|
|
from openbb_terminal.keys_controller import KeysController
|
|
|
|
controller = KeysController(menu_usage=False)
|
|
|
|
# pylint: disable=R0902,R0903,W1404
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def revert_current_user(mocker):
|
|
mocker.patch(
|
|
target="openbb_terminal.keys_model.set_credential",
|
|
)
|
|
preferences = PreferencesModel(
|
|
ENABLE_CHECK_API=False,
|
|
)
|
|
mock_current_user = copy_user(preferences=preferences)
|
|
mocker.patch(
|
|
target="openbb_terminal.core.session.current_user.__current_user",
|
|
new=mock_current_user,
|
|
)
|
|
|
|
yield
|
|
|
|
|
|
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_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)
|