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

[Bug fix] - Run charting tests again #6167

Merged
merged 2 commits into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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: 4 additions & 4 deletions openbb_platform/core/tests/app/model/charts/test_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from openbb_core.app.model.charts.chart import Chart, ChartFormat


def test_chart_default_values():
def test_charting_default_values():
# Arrange & Act
chart = Chart()

Expand All @@ -11,7 +11,7 @@ def test_chart_default_values():
assert chart.format == ChartFormat.plotly


def test_chart_custom_values():
def test_charting_custom_values():
# Arrange
content = {"data": [1, 2, 3]}
chart_format = ChartFormat.plotly
Expand All @@ -24,7 +24,7 @@ def test_chart_custom_values():
assert chart.format == chart_format


def test_chart_assignment_validation():
def test_charting_assignment_validation():
# Arrange
chart = Chart()

Expand All @@ -33,7 +33,7 @@ def test_chart_assignment_validation():
chart.invalid_field = "Invalid Value"


def test_chart_config_validation():
def test_charting_config_validation():
# Arrange
content = {"data": [1, 2, 3]}
chart_format = ChartFormat.plotly
Expand Down
8 changes: 5 additions & 3 deletions openbb_platform/extensions/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
def parametrize(argnames: str, argvalues: List[Dict], **kwargs):
"""Custom parametrize decorator that filters test cases based on the environment."""

extensions, providers = list_openbb_extensions()
routers, providers, obbject_ext = list_openbb_extensions()

def decorator(function):
"""Patch the pytest.mark.parametrize decorator."""
filtered_argvalues: List[Dict] = []
extension_name = function.__name__.split("_")[1]
name = function.__name__.split("_")[1]
# This is a patch to handle the charting extension name
extension_name = "openbb_" + name if name == "charting" else name
function_name = "/" + "/".join(function.__name__.split("_")[1:])
# this handles edge cases where the function name has an underscore
function_name_v2 = (
Expand All @@ -34,7 +36,7 @@ def decorator(function):
+ "_"
+ function_name.rsplit("/", 1)[1].replace("/", "_")
)
if extension_name in extensions:
if extension_name in routers | obbject_ext:
for args in argvalues:
if "provider" in args and args["provider"] in providers:
filtered_argvalues.append(args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_charting_extension_function_coverage() -> None:
"""Test if all charting extension functions are covered by integration tests."""
functions = Charting.functions()

test_names = [f"test_chart_{func}" for func in functions]
test_names = [f"test_charting_{func}" for func in functions]
integration_tests_modules = get_integration_tests(
test_type="api", filter_charting_ext=False
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_charting_extension_function_coverage() -> None:
"""Test if all charting extension functions are covered by integration tests."""
functions = Charting.functions()

test_names = [f"test_chart_{func}" for func in functions]
test_names = [f"test_charting_{func}" for func in functions]
integration_tests_modules = get_integration_tests(
test_type="python", filter_charting_ext=False
)
Expand Down
9 changes: 7 additions & 2 deletions openbb_platform/extensions/tests/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def check_docstring_examples() -> List[str]:
return errors


def list_openbb_extensions() -> Tuple[Set[str], Set[str]]:
def list_openbb_extensions() -> Tuple[Set[str], Set[str], Set[str]]:
"""
Lists installed openbb extensions and providers.

Expand All @@ -81,10 +81,12 @@ def list_openbb_extensions() -> Tuple[Set[str], Set[str]]:
Tuple[Set[str], Set[str]]
First element: set of installed core extensions.
Second element: set of installed provider extensions.
Third element: set of installed obbject extensions.
"""

core_extensions = set()
provider_extensions = set()
obbject_extensions = set()
entry_points_dict = entry_points()

for entry_point in entry_points_dict["openbb_core_extension"]:
Expand All @@ -93,4 +95,7 @@ def list_openbb_extensions() -> Tuple[Set[str], Set[str]]:
for entry_point in entry_points_dict["openbb_provider_extension"]:
provider_extensions.add(f"{entry_point.name}")

return core_extensions, provider_extensions
for entry_point in entry_points_dict["openbb_obbject_extension"]:
obbject_extensions.add(f"{entry_point.name}")

return core_extensions, provider_extensions, obbject_extensions
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def get_equity_data():
],
)
@pytest.mark.integration
def test_chart_equity_price_historical(params, headers):
def test_charting_equity_price_historical(params, headers):
"""Test chart equity load."""
params = {p: v for p, v in params.items() if v}

Expand All @@ -80,7 +80,7 @@ def test_chart_equity_price_historical(params, headers):
[({"symbol": "AAPL", "limit": 100, "chart": True})],
)
@pytest.mark.integration
def test_chart_equity_fundamental_multiples(params, headers):
def test_charting_equity_fundamental_multiples(params, headers):
"""Test chart equity multiples."""
params = {p: v for p, v in params.items() if v}

Expand Down Expand Up @@ -114,7 +114,7 @@ def test_chart_equity_fundamental_multiples(params, headers):
],
)
@pytest.mark.integration
def test_chart_technical_adx(params, headers):
def test_charting_technical_adx(params, headers):
"""Test chart ta adx."""
params = {p: v for p, v in params.items() if v}
body = json.dumps(get_equity_data())
Expand All @@ -138,7 +138,7 @@ def test_chart_technical_adx(params, headers):
[({"data": "", "index": "date", "length": "30", "scalar": "110", "chart": True})],
)
@pytest.mark.integration
def test_chart_technical_aroon(params, headers):
def test_charting_technical_aroon(params, headers):
"""Test chart ta aroon."""
params = {p: v for p, v in params.items() if v}
body = json.dumps(get_equity_data())
Expand Down Expand Up @@ -173,7 +173,7 @@ def test_chart_technical_aroon(params, headers):
],
)
@pytest.mark.integration
def test_chart_technical_ema(params, headers):
def test_charting_technical_ema(params, headers):
"""Test chart ta ema."""
params = {p: v for p, v in params.items() if v}
body = json.dumps(get_equity_data())
Expand Down Expand Up @@ -208,7 +208,7 @@ def test_chart_technical_ema(params, headers):
],
)
@pytest.mark.integration
def test_chart_technical_hma(params, headers):
def test_charting_technical_hma(params, headers):
"""Test chart ta hma."""
params = {p: v for p, v in params.items() if v}
body = json.dumps(get_equity_data())
Expand Down Expand Up @@ -244,7 +244,7 @@ def test_chart_technical_hma(params, headers):
],
)
@pytest.mark.integration
def test_chart_technical_macd(params, headers):
def test_charting_technical_macd(params, headers):
"""Test chart ta macd."""
params = {p: v for p, v in params.items() if v}
body = json.dumps(get_equity_data())
Expand Down Expand Up @@ -280,7 +280,7 @@ def test_chart_technical_macd(params, headers):
],
)
@pytest.mark.integration
def test_chart_technical_rsi(params, headers):
def test_charting_technical_rsi(params, headers):
"""Test chart ta rsi."""
params = {p: v for p, v in params.items() if v}
body = json.dumps(get_equity_data())
Expand Down Expand Up @@ -315,7 +315,7 @@ def test_chart_technical_rsi(params, headers):
],
)
@pytest.mark.integration
def test_chart_technical_sma(params, headers):
def test_charting_technical_sma(params, headers):
"""Test chart ta sma."""
params = {p: v for p, v in params.items() if v}
body = json.dumps(get_equity_data())
Expand Down Expand Up @@ -350,7 +350,7 @@ def test_chart_technical_sma(params, headers):
],
)
@pytest.mark.integration
def test_chart_technical_wma(params, headers):
def test_charting_technical_wma(params, headers):
"""Test chart ta wma."""
params = {p: v for p, v in params.items() if v}
body = json.dumps(get_equity_data())
Expand Down Expand Up @@ -385,7 +385,7 @@ def test_chart_technical_wma(params, headers):
],
)
@pytest.mark.integration
def test_chart_technical_zlma(params, headers):
def test_charting_technical_zlma(params, headers):
"""Test chart ta zlma."""
params = {p: v for p, v in params.items() if v}
body = json.dumps(get_equity_data())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def get_equity_data():
],
)
@pytest.mark.integration
def test_chart_equity_price_historical(params, obb):
def test_charting_equity_price_historical(params, obb):
"""Test chart equity price historical."""
result = obb.equity.price.historical(**params)
assert result
Expand All @@ -67,7 +67,7 @@ def test_chart_equity_price_historical(params, obb):
],
)
@pytest.mark.integration
def test_chart_equity_fundamental_multiples(params, obb):
def test_charting_equity_fundamental_multiples(params, obb):
"""Test chart equity multiples."""
params = {p: v for p, v in params.items() if v}

Expand Down Expand Up @@ -95,7 +95,7 @@ def test_chart_equity_fundamental_multiples(params, obb):
],
)
@pytest.mark.integration
def test_chart_technical_adx(params, obb):
def test_charting_technical_adx(params, obb):
"""Test chart ta adx."""
params = {p: v for p, v in params.items() if v}

Expand Down Expand Up @@ -124,7 +124,7 @@ def test_chart_technical_adx(params, obb):
],
)
@pytest.mark.integration
def test_chart_technical_aroon(params, obb):
def test_charting_technical_aroon(params, obb):
"""Test chart ta aroon."""
params = {p: v for p, v in params.items() if v}

Expand Down Expand Up @@ -154,7 +154,7 @@ def test_chart_technical_aroon(params, obb):
],
)
@pytest.mark.integration
def test_chart_technical_ema(params, obb):
def test_charting_technical_ema(params, obb):
"""Test chart ta ema."""
params = {p: v for p, v in params.items() if v}

Expand Down Expand Up @@ -184,7 +184,7 @@ def test_chart_technical_ema(params, obb):
],
)
@pytest.mark.integration
def test_chart_technical_hma(params, obb):
def test_charting_technical_hma(params, obb):
"""Test chart ta hma."""
params = {p: v for p, v in params.items() if v}

Expand Down Expand Up @@ -215,7 +215,7 @@ def test_chart_technical_hma(params, obb):
],
)
@pytest.mark.integration
def test_chart_technical_macd(params, obb):
def test_charting_technical_macd(params, obb):
"""Test chart ta macd."""
params = {p: v for p, v in params.items() if v}

Expand Down Expand Up @@ -246,7 +246,7 @@ def test_chart_technical_macd(params, obb):
],
)
@pytest.mark.integration
def test_chart_technical_rsi(params, obb):
def test_charting_technical_rsi(params, obb):
"""Test chart ta rsi."""
params = {p: v for p, v in params.items() if v}

Expand Down Expand Up @@ -276,7 +276,7 @@ def test_chart_technical_rsi(params, obb):
],
)
@pytest.mark.integration
def test_chart_technical_sma(params, obb):
def test_charting_technical_sma(params, obb):
"""Test chart ta sma."""
params = {p: v for p, v in params.items() if v}

Expand Down Expand Up @@ -306,7 +306,7 @@ def test_chart_technical_sma(params, obb):
],
)
@pytest.mark.integration
def test_chart_technical_wma(params, obb):
def test_charting_technical_wma(params, obb):
"""Test chart ta wma."""
params = {p: v for p, v in params.items() if v}

Expand Down Expand Up @@ -336,7 +336,7 @@ def test_chart_technical_wma(params, obb):
],
)
@pytest.mark.integration
def test_chart_technical_zlma(params, obb):
def test_charting_technical_zlma(params, obb):
"""Test chart ta zlma."""
params = {p: v for p, v in params.items() if v}

Expand Down
Loading