mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-11-01 23:12:21 +00:00
* init * fix tables * add shortcuts * handle svgs * test * test2 * test3 * Update loggers.py * Update sdk_helpers.py * Update loggers.py * Update loggers.py * updates * updates * update * handle add text high/low for candlestick traces when updating * adding save overlay to tables * maybe fix * prints * asdf * working * working * removing prints * update * fix no figure title text * add trace labels space * download finished popup for MacOS * bump pywry * update * update table * Update plotly_helper.py * only format numbers over 10_000 on tables * Delete generate_index.py * turn off logs in generations * update tables * bump pywry, fix tables, added ichimoku ta indicator * Update backend.py * mypy * update tables * updates * juan more * tables * test * bump pywry * bump pywry * Update loggers.py * test * fixing some formatting * add update button to indicators dashboard * fix oecd dates to be full dates * prepare charts/tables for pywry update * Update poetry.lock * Update finviz_view.py * tests * tests * tests * tests * testss? * tests * Create test_call_func[call_sec-nasdaq_view.sec_filings-other_args37-called_with37].yaml * testtss please * Update loggers.py * testss * `with open(newline="\n")` * tests * tests -__- * why * Revert "`with open(newline="\n")`" This reverts commit554e0f53f4. * Revert "why" This reverts commit89f1d9b823. * Revert "tests -__-" This reverts commita9c694ae96. * Revert "tests" This reverts commit5463249498. * whelp * . * rename `streamlit.py` -> `streamlit_run.py`, bump pywry/finviz/streamlit * Update backend.py * update * Revert "update file" --------- Co-authored-by: andrewkenreich <andrew.kenreich@gmail.com> Co-authored-by: James Maslek <jmaslek11@gmail.com>
94 lines
2.1 KiB
Python
94 lines
2.1 KiB
Python
import json
|
|
|
|
import pandas as pd
|
|
import pytest
|
|
from pycoingecko import CoinGeckoAPI
|
|
|
|
from openbb_terminal.cryptocurrency.cryptocurrency_helpers import (
|
|
_create_closest_match_df,
|
|
_load_coin_map,
|
|
load,
|
|
load_coins_list,
|
|
read_data_file,
|
|
)
|
|
|
|
# pylint: disable=unused-import
|
|
|
|
base = "openbb_terminal.cryptocurrency."
|
|
|
|
|
|
def test_load_coin_map():
|
|
with pytest.raises(TypeError):
|
|
_load_coin_map("test.test")
|
|
|
|
|
|
def test_read_data_file(recorder):
|
|
file = read_data_file("coinbase_gecko_map.json")
|
|
|
|
recorder.capture(file)
|
|
|
|
|
|
def test_read_data_file_invalid():
|
|
with pytest.raises(TypeError):
|
|
read_data_file("sample.bad")
|
|
|
|
|
|
def test_load_coins_list(recorder):
|
|
value = load_coins_list("coinbase_gecko_map.json", True)
|
|
|
|
recorder.capture(value)
|
|
|
|
|
|
def test_load_coins_list_invalud():
|
|
with pytest.raises(TypeError):
|
|
load_coins_list("bad.bad")
|
|
|
|
|
|
def test_create_closet_match_df(recorder):
|
|
df = pd.DataFrame({"id": ["btc", "eth"], "index": [1, 2]})
|
|
value = _create_closest_match_df("btc", df, 5, 0.2)
|
|
|
|
recorder.capture(value)
|
|
|
|
|
|
@pytest.mark.vcr
|
|
@pytest.mark.parametrize(
|
|
"coin, vs",
|
|
[
|
|
("btc", "usd"),
|
|
],
|
|
)
|
|
def test_load_none(coin, vs):
|
|
df = load(symbol=coin, to_symbol=vs)
|
|
assert df is not None
|
|
|
|
|
|
@pytest.fixture(name="get_bitcoin")
|
|
def fixture_get_bitcoin(mocker):
|
|
# pylint: disable=unused-argument
|
|
mock_load = mocker.patch(
|
|
base
|
|
+ "due_diligence.pycoingecko_model.CoinGeckoAPI.get_coin_market_chart_by_id"
|
|
)
|
|
|
|
with open(
|
|
"tests/openbb_terminal/cryptocurrency/json/test_cryptocurrency_helpers/btc_usd_test_data.json",
|
|
encoding="utf8",
|
|
newline="\n",
|
|
) as f:
|
|
sample_return = json.load(f)
|
|
mock_load.return_value = sample_return
|
|
df = load("BTC", to_symbol="usd", source="YahooFinance")
|
|
return df
|
|
|
|
|
|
@pytest.mark.record_stdout
|
|
@pytest.mark.vcr
|
|
def test_get_coins():
|
|
"""Test that pycoingecko retrieves the major coins"""
|
|
coins = CoinGeckoAPI().get_coins()
|
|
bitcoin_list = [coin["id"] for coin in coins]
|
|
test_coins = ["bitcoin", "ethereum", "dogecoin"]
|
|
for test in test_coins:
|
|
assert test in bitcoin_list
|