[Bug fix] - Run charting tests again (#6167)

* run tests again

* forgot these 2
This commit is contained in:
montezdesousa
2024-03-05 20:27:58 +00:00
committed by GitHub
parent 6efab3fd15
commit b768bc08d7
7 changed files with 40 additions and 33 deletions

View File

@@ -2,7 +2,7 @@ import pytest
from openbb_core.app.model.charts.chart import Chart, ChartFormat
def test_chart_default_values():
def test_charting_default_values():
# Arrange & Act
chart = Chart()
@@ -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
@@ -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()
@@ -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

View File

@@ -16,12 +16,14 @@ commands = list(cm.map.keys())
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 = (
@@ -34,7 +36,7 @@ def parametrize(argnames: str, argvalues: List[Dict], **kwargs):
+ "_"
+ 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)

View File

@@ -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
)

View File

@@ -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
)

View File

@@ -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.
@@ -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"]:
@@ -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

View File

@@ -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}
@@ -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}
@@ -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())
@@ -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())
@@ -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())
@@ -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())
@@ -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())
@@ -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())
@@ -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())
@@ -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())
@@ -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())

View File

@@ -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
@@ -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}
@@ -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}
@@ -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}
@@ -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}
@@ -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}
@@ -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}
@@ -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}
@@ -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}
@@ -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}
@@ -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}