Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing tests #5560

Merged
merged 26 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
baa4e35
Passing tests
IgorWounds Oct 13, 2023
95dd94c
Merge branch 'feature/openbb-sdk-v4' into hotfix/integration-tests
IgorWounds Oct 13, 2023
66c39f5
fix options
deeleeramone Oct 13, 2023
eae07b6
Fix most tests and bugs
IgorWounds Oct 13, 2023
7ecc996
Merge pull request #5563 from OpenBB-finance/hotfix/fix-integration-t…
IgorWounds Oct 13, 2023
44603ee
fix forex missing params
deeleeramone Oct 13, 2023
d9042d1
make symbol upper in polygon fx pairs
deeleeramone Oct 13, 2023
09d7f7c
fix fixedincome integration tests (#5564)
hjoaquim Oct 13, 2023
ad70e3e
Fixing charting api integration tests (#5562)
hjoaquim Oct 13, 2023
cbe1ee3
fix stocks less five API fails
deeleeramone Oct 13, 2023
e907db0
fix the 5 failing stocks integration tests
deeleeramone Oct 13, 2023
d9ae61f
recapture fmp stock news unit test
deeleeramone Oct 13, 2023
a7aa841
fix fmp forex api test
deeleeramone Oct 13, 2023
430af1e
couple more forex integration fixes
deeleeramone Oct 13, 2023
770959f
changing the request to always use the legacy session. @jmaslek this …
hjoaquim Oct 14, 2023
78678fc
ruff
hjoaquim Oct 14, 2023
dbb0871
Merge branch 'feature/openbb-sdk-v4' into hotfix/integration-tests
hjoaquim Oct 16, 2023
0418974
fix ta
hjoaquim Oct 16, 2023
382e5ee
add missing param
hjoaquim Oct 16, 2023
187ff20
fix testers for the api
hjoaquim Oct 16, 2023
050f757
fix globalnews to use images instead of image
hjoaquim Oct 16, 2023
8351087
remove unncessary pandas import
hjoaquim Oct 16, 2023
73083af
econcal int tests
hjoaquim Oct 16, 2023
a41b897
update gitignore
hjoaquim Oct 16, 2023
4a5ed6a
fix get_querystring to support lists
hjoaquim Oct 16, 2023
8d036d2
add missing parameters
hjoaquim Oct 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ cache/
# lightning logs
lightning_logs/

# user script to install all extensions and providers
openbb_platform/platform/core/tests/app/model/charts/test_chart_settings.py
# testing artifacts
*/mocked_path

# CA certificates
*.pem

# Platform auto generated files
openbb_platform/openbb/package/*
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,13 @@ def test_chart_stocks_load(params, headers):
result = requests.get(url, headers=headers, timeout=10)
assert isinstance(result, requests.Response)
assert result.status_code == 200
assert result.json()["chart"]
assert list(result.json()["chart"].keys()) == ["content", "format"]

chart = result.json()["chart"]
fig = chart.pop("fig", {})

assert chart
assert not fig
assert list(chart.keys()) == ["content", "format"]


@pytest.mark.parametrize(
Expand All @@ -82,8 +87,12 @@ def test_chart_stocks_multiples(params, headers):
assert isinstance(result, requests.Response)
assert result.status_code == 200

assert result.json()["chart"]
assert list(result.json()["chart"].keys()) == ["content", "format"]
chart = result.json()["chart"]
fig = chart.pop("fig", {})

assert chart
assert not fig
assert list(chart.keys()) == ["content", "format"]


@pytest.mark.parametrize(
Expand All @@ -101,8 +110,12 @@ def test_chart_stocks_news(params, headers):
assert isinstance(result, requests.Response)
assert result.status_code == 200

assert result.json()["chart"]
assert list(result.json()["chart"].keys()) == ["content", "format"]
chart = result.json()["chart"]
fig = chart.pop("fig", {})

assert chart
assert not fig
assert list(chart.keys()) == ["content", "format"]


@pytest.mark.parametrize(
Expand Down Expand Up @@ -132,8 +145,12 @@ def test_chart_ta_adx(params, headers):
assert isinstance(result, requests.Response)
assert result.status_code == 200

assert result.json()["chart"]
assert list(result.json()["chart"].keys()) == ["content", "format"]
chart = result.json()["chart"]
fig = chart.pop("fig", {})

assert chart
assert not fig
assert list(chart.keys()) == ["content", "format"]


@pytest.mark.parametrize(
Expand All @@ -152,8 +169,12 @@ def test_chart_ta_aroon(params, headers):
assert isinstance(result, requests.Response)
assert result.status_code == 200

assert result.json()["chart"]
assert list(result.json()["chart"].keys()) == ["content", "format"]
chart = result.json()["chart"]
fig = chart.pop("fig", {})

assert chart
assert not fig
assert list(chart.keys()) == ["content", "format"]


@pytest.mark.parametrize(
Expand Down Expand Up @@ -183,8 +204,12 @@ def test_chart_ta_ema(params, headers):
assert isinstance(result, requests.Response)
assert result.status_code == 200

assert result.json()["chart"]
assert list(result.json()["chart"].keys()) == ["content", "format"]
chart = result.json()["chart"]
fig = chart.pop("fig", {})

assert chart
assert not fig
assert list(chart.keys()) == ["content", "format"]


@pytest.mark.parametrize(
Expand Down Expand Up @@ -214,8 +239,12 @@ def test_chart_ta_hma(params, headers):
assert isinstance(result, requests.Response)
assert result.status_code == 200

assert result.json()["chart"]
assert list(result.json()["chart"].keys()) == ["content", "format"]
chart = result.json()["chart"]
fig = chart.pop("fig", {})

assert chart
assert not fig
assert list(chart.keys()) == ["content", "format"]


@pytest.mark.parametrize(
Expand Down Expand Up @@ -246,8 +275,12 @@ def test_chart_ta_macd(params, headers):
assert isinstance(result, requests.Response)
assert result.status_code == 200

assert result.json()["chart"]
assert list(result.json()["chart"].keys()) == ["content", "format"]
chart = result.json()["chart"]
fig = chart.pop("fig", {})

assert chart
assert not fig
assert list(chart.keys()) == ["content", "format"]


@pytest.mark.parametrize(
Expand Down Expand Up @@ -278,8 +311,12 @@ def test_chart_ta_rsi(params, headers):
assert isinstance(result, requests.Response)
assert result.status_code == 200

assert result.json()["chart"]
assert list(result.json()["chart"].keys()) == ["content", "format"]
chart = result.json()["chart"]
fig = chart.pop("fig", {})

assert chart
assert not fig
assert list(chart.keys()) == ["content", "format"]


@pytest.mark.parametrize(
Expand Down Expand Up @@ -309,8 +346,12 @@ def test_chart_ta_sma(params, headers):
assert isinstance(result, requests.Response)
assert result.status_code == 200

assert result.json()["chart"]
assert list(result.json()["chart"].keys()) == ["content", "format"]
chart = result.json()["chart"]
fig = chart.pop("fig", {})

assert chart
assert not fig
assert list(chart.keys()) == ["content", "format"]


@pytest.mark.parametrize(
Expand Down Expand Up @@ -340,8 +381,12 @@ def test_chart_ta_wma(params, headers):
assert isinstance(result, requests.Response)
assert result.status_code == 200

assert result.json()["chart"]
assert list(result.json()["chart"].keys()) == ["content", "format"]
chart = result.json()["chart"]
fig = chart.pop("fig", {})

assert chart
assert not fig
assert list(chart.keys()) == ["content", "format"]


@pytest.mark.parametrize(
Expand Down Expand Up @@ -371,5 +416,9 @@ def test_chart_ta_zlma(params, headers):
assert isinstance(result, requests.Response)
assert result.status_code == 200

assert result.json()["chart"]
assert list(result.json()["chart"].keys()) == ["content", "format"]
chart = result.json()["chart"]
fig = chart.pop("fig", {})

assert chart
assert not fig
assert list(chart.keys()) == ["content", "format"]
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,9 @@ def to_html(self, *args, **kwargs) -> str:

return super().to_html(*args, **kwargs)

def to_plotly_json(self, ndarray: bool = False) -> Dict[str, Any]:
def to_plotly_json(
self, ndarray: bool = False, np_nan: bool = False
) -> Dict[str, Any]:
"""
Convert figure to a JSON representation as a Python dict

Expand All @@ -1231,9 +1233,13 @@ def to_plotly_json(self, ndarray: bool = False) -> Dict[str, Any]:
----------
ndarray : `bool`, optional
If the plotly json should contain np.ndarray, by default False

np_nan : `bool`, optional
If the plotly json should contain np.nan, by default False
"""

def remove_ndarrays(data):
"""Remove ndarrays from the plotly json."""
if isinstance(data, dict):
for key, val in data.items():
if isinstance(val, np.ndarray):
Expand All @@ -1249,9 +1255,28 @@ def remove_ndarrays(data):

return data

def remove_nan(data):
"""Remove nan from the plotly json."""
if isinstance(data, dict):
for key, val in data.items():
if isinstance(val, float) and np.isnan(val):
data[key] = None
elif isinstance(val, (dict, list)):
data[key] = remove_nan(val)
elif isinstance(data, list):
for i, val in enumerate(data):
if isinstance(val, float) and np.isnan(val):
data[i] = None
elif isinstance(val, (dict, list)):
data[i] = remove_nan(val)

return data

plotly_json = super().to_plotly_json()
if not ndarray:
plotly_json = remove_ndarrays(plotly_json)
if not np_nan:
plotly_json = remove_nan(plotly_json)

return plotly_json

Expand Down
13 changes: 10 additions & 3 deletions openbb_platform/extensions/crypto/integration/test_crypto_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ def headers():
@pytest.mark.parametrize(
"params",
[
({"symbol": "BTCUSD", "start_date": "2023-01-01", "end_date": "2023-06-06"}),
(
{
"symbol": "BTC-USD",
"start_date": "2023-01-01",
"end_date": "2023-01-06",
"provider": "polygon",
}
),
(
{
"interval": "1min",
Expand All @@ -31,7 +38,7 @@ def headers():
),
(
{
"interval": "1day",
"interval": "15min",
"provider": "fmp",
"symbol": "BTCUSD",
"start_date": "2023-01-01",
Expand Down Expand Up @@ -72,7 +79,7 @@ def headers():
"provider": "yfinance",
"symbol": "BTCUSD",
"start_date": "2023-01-01",
"end_date": "2023-01-02",
"end_date": "2023-01-08",
}
),
(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
@pytest.fixture(scope="session")
def obb(pytestconfig):
"""Fixture to setup obb."""

if pytestconfig.getoption("markexpr") != "not integration":
import openbb

Expand Down Expand Up @@ -36,11 +35,11 @@ def obb(pytestconfig):
),
(
{
"interval": "1day",
"interval": "15min",
"provider": "fmp",
"symbol": "BTCUSD",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
"end_date": "2023-01-03",
"timeseries": 1,
}
),
Expand Down Expand Up @@ -70,16 +69,6 @@ def obb(pytestconfig):
"end_date": "2023-01-02",
}
),
(
{
"interval": "5m",
"period": "max",
"provider": "yfinance",
"symbol": "BTCUSD",
"start_date": "2023-01-01",
"end_date": "2023-01-02",
}
),
(
{
"interval": "1d",
Expand Down
Loading
Loading