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

[Bugfix] - Test parametrize skips charting tests #6264

Merged
merged 25 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
8 changes: 6 additions & 2 deletions openbb_platform/extensions/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Custom pytest configuration for the extensions."""

from typing import Any, Dict, List
from typing import Dict, List

import pytest
from openbb_core.app.router import CommandMap
Expand All @@ -13,7 +13,7 @@
# ruff: noqa: SIM114


def parametrize(argnames: str, argvalues: List[Dict[str, Any]], **kwargs):
def parametrize(argnames: str, argvalues: List, **kwargs):
"""Custom parametrize decorator that filters test cases based on the environment."""

routers, providers, obbject_ext = list_openbb_extensions()
Expand Down Expand Up @@ -49,6 +49,10 @@ def decorator(function):
elif "provider" not in args and function_name_v3 in commands:
# Handle edge case
filtered_argvalues.append(args)
elif extension_name in obbject_ext:
filtered_argvalues.append(args)

# If filtered_argvalues is empty, pytest will skip the test!
return pytest.mark.parametrize(argnames, filtered_argvalues, **kwargs)(
function
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,29 +75,6 @@ def test_charting_equity_price_historical(params, headers):
assert list(chart.keys()) == ["content", "format"]


@parametrize(
"params",
[({"symbol": "AAPL", "limit": 100, "chart": True})],
)
@pytest.mark.integration
def test_charting_equity_fundamental_multiples(params, headers):
"""Test chart equity multiples."""
params = {p: v for p, v in params.items() if v}

query_str = get_querystring(params, [])
url = f"http://0.0.0.0:8000/api/v1/equity/fundamental/multiples?{query_str}"
result = requests.get(url, headers=headers, timeout=10)
assert isinstance(result, requests.Response)
assert result.status_code == 200

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

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


@parametrize(
"params",
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,12 +385,9 @@ def z_score_standardization(data: pd.Series) -> pd.Series:
+ " Override this error by setting `allow_unsafe = True`."
)

y1_units = y_units[0]

y1_units = y_units[0] if y_units else None
y1title = y1_units

y2title = y_units[1] if len(y_units) > 1 else None

xtitle = ""

# If the request was transformed, the y-axis will be shared under these conditions.
Expand Down
Loading