Files
OpenBB/tests/openbb_terminal/test_keys_controller.py
James Maslek 707ae7e317 Release 2.5.0 (#4355)
* Rename SDK folder

* Fixing all the tests I hope

* Depreciate the sia menu

* Fix routine script

* Update SDK generation scripts

* This needed fixing anyways

* Regenerate SDK files

* Update paths in sdk helpers

* Regenerate the remains of the SDK

* Fix candle not working with symbol via the sdk

* Fix pydocstyle errors

* deps

* Add in Docstrings

* Push to website since I need to upload images

* typos

* Add in Fixed Income Guide

* Tests : fix cassette

* changes to layout and adding more content

* trailmap

* poetry

* updates to requirements files

* add `_try_to_login` to sdk generation, fix `_chart` in `about()` url

* sentiment analysis

* refactor

* changing to base model default

* rounding

* renewing poetry

* fixed poetry

* spacing

* black

* adds selectable models for realized volatility calculations

* fixes line too long

* Add intro guides to Fixed Income

* Fix some missing docstrings

* Fix website not working

* missed a few

* fix /economy/test_yfinance_view tests

* fix etf/test_stockanalysis_model.py

* fix etf/test_stockanalysis_view.py

* fix test_stocks_controller

* deprecating non used function

* update financedatabase to 2.0.4

* Delete SIA from OpenBB Docs and SDK

* Searching was not done properly for short name and index

* changes the default data source for crypto.load

* Fix tests I broke

* Little fixy fix to remove duplicates

* Fix tests

* typo

* adds check for empty dataframe

* Patch Equity Report

* Update so that image links to website

* linting v2

* silly imports

* adding tempfile

* add imap unordered

* reordering imports

* Adding databento as a source (#4293)

* First commit

* Baby steps

* Keys and sdk

* Fix import for api key

* Add SDK endpoints

* Test + api checks

* tests

* roque print of api key

* Changes

* minor

* custom timeout

* improve timeouts

---------

Co-authored-by: hjoaquim <h.joaquim@campus.fct.unl.pt>

* Tests

* Integration test

* frozendict remove

* update spec

* rename sdk faq to troubleshooting

* add hidden import

* add hidden imports

* imports again

* valid url check

* new lines and prompt

* split imports

* more spec

* adds cones to the crypto-ta menu

* Fix tests

* Update code to reflect new changes to FinanceDatabase

* Small bugfix for DCF if you have no ticker loaded

* remove yfinance from news

* add reverse fx choices

* black

* ruff

* Add options greeks to the SDK

* Linting

* Delete rogue file and update test and add fixedincome to en.yml

* fix for options screener

* ruff

* updates tests for options screener

* reqs

* updates more test files

* rewrite for test_github_model

* rewrite test for test_syncretism_view

* removes test_view_available_presets[]

* black

* coverage

* adds option screener preset

* Update directories.py

* len & set

* set all list

* adds unit testing for cones

* ruff

* pylint

* adds options screener endpoint to SDK

* test markers

* Testing draft PR mode

* Update package to v2.0.7

* Remove etf/screener and tests

* Updated

* Merge reqs

* Updated readme

* hook test for pyinstaller

* Little fixy fix

* Remove etf/scr from SDK

* Update tests

* Update hook-whisper.py

* oops lol

* Update sdk

* update

* Etf

* removed old trailmap csv's

* Update fixedincome text

* add greeks to trail

* rouge file

* merge killed it

* fix test

* fix build failure

* catch for error message

* fix for frozendict

* caching search and prompting on hub

* whisper model prompts

* Fix long/short issue and fix transform issue

* separates volatility models from cones function

* Introduce CPI functionality

* improves error handling for volatility models when window length is too small

* ur welcome <3

* additional sanity check for volatility_view

* updates volatility_model test

* black

* Fix linting

* Make cpi a little bit more robust

* Add in missing value

* sdk updates

* update dep files

* Update trail_map_forecasting.csv

* import ordering pylint?

* fix trailing comma

* sorted trailmaps

* remove one test artifact

* rewrite test

* Adds the missing pieces.

* adds clickable URL in keys + Databento

* adds databento images

* adds images for Databento

* update deps

* req files

* swap order in databento

* ruff

* mypy

* lint

* sdk

* makes requested changes

* ruff v2..

* replaces screenshot.

* Removed because it shouldn't have been in this PR.

* ruff v3

* Minor edit, move installation to position 2 instead of last

* util linting changes

* linting for controller

* fix test

* test

* Revert some tests

* Guess not

* see if this sticks

* fixes

* Fix linters.  Add --video if not provided

* Checkout develop tests for keys

* Release time

* Revert papermill and update gh pages action

* Fix shortname (#4356)

* uninstall brotli on conda test

* Fix issue 4316 (#4357)

* Fix issue 4316

* Updating polygon_model + options_controller

* Tests : FRED

* ruff

---------

Co-authored-by: Theodore Aptekarev <aptekarev@gmail.com>
Co-authored-by: Jeroen Bouma <jer.bouma@gmail.com>
Co-authored-by: Danglewood <85772166+deeleeramone@users.noreply.github.com>
Co-authored-by: hjoaquim <h.joaquim@campus.fct.unl.pt>
Co-authored-by: Chavithra PARANA <chavithra@gmail.com>
Co-authored-by: teh_coderer <me@tehcoderer.com>
Co-authored-by: martinb-bb <105685594+martinb-bb@users.noreply.github.com>
Co-authored-by: Diogo Sousa <montezdesousa@gmail.com>
Co-authored-by: northern-64bit <75195383+northern-64bit@users.noreply.github.com>
Co-authored-by: luqazino@gmail.com <luqazino@gmail.com>
Co-authored-by: colin99d <colin99delahunty@gmail.com>
Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com>
Co-authored-by: andrewkenreich <andrew.kenreich@gmail.com>
2023-03-01 08:47:12 -05:00

252 lines
7.6 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_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)