From 48e7d8ccb59a42d668b1a09b55934e2e00f13c83 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Tue, 5 Mar 2024 18:00:01 +0000 Subject: [PATCH 1/2] run tests again --- .../core/tests/app/model/charts/test_chart.py | 8 +++---- openbb_platform/extensions/tests/conftest.py | 8 ++++--- .../extensions/tests/utils/helpers.py | 9 ++++++-- .../charting/integration/test_charting_api.py | 22 +++++++++---------- .../integration/test_charting_python.py | 22 +++++++++---------- 5 files changed, 38 insertions(+), 31 deletions(-) diff --git a/openbb_platform/core/tests/app/model/charts/test_chart.py b/openbb_platform/core/tests/app/model/charts/test_chart.py index 3225be2ffaeb..0278a3625b94 100644 --- a/openbb_platform/core/tests/app/model/charts/test_chart.py +++ b/openbb_platform/core/tests/app/model/charts/test_chart.py @@ -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() @@ -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 diff --git a/openbb_platform/extensions/tests/conftest.py b/openbb_platform/extensions/tests/conftest.py index 45f1b8495725..bf9c9b65b10f 100644 --- a/openbb_platform/extensions/tests/conftest.py +++ b/openbb_platform/extensions/tests/conftest.py @@ -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 = ( @@ -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) diff --git a/openbb_platform/extensions/tests/utils/helpers.py b/openbb_platform/extensions/tests/utils/helpers.py index bff32072dbac..264bdb4958d5 100644 --- a/openbb_platform/extensions/tests/utils/helpers.py +++ b/openbb_platform/extensions/tests/utils/helpers.py @@ -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 diff --git a/openbb_platform/obbject_extensions/charting/integration/test_charting_api.py b/openbb_platform/obbject_extensions/charting/integration/test_charting_api.py index 15ea8decc1c5..d5df11fdc631 100644 --- a/openbb_platform/obbject_extensions/charting/integration/test_charting_api.py +++ b/openbb_platform/obbject_extensions/charting/integration/test_charting_api.py @@ -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()) diff --git a/openbb_platform/obbject_extensions/charting/integration/test_charting_python.py b/openbb_platform/obbject_extensions/charting/integration/test_charting_python.py index 90bc88151b29..68d4e6a18b2a 100644 --- a/openbb_platform/obbject_extensions/charting/integration/test_charting_python.py +++ b/openbb_platform/obbject_extensions/charting/integration/test_charting_python.py @@ -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} From 2bc731d47751b033d605f03c9693a2e267f962c7 Mon Sep 17 00:00:00 2001 From: Diogo Sousa Date: Tue, 5 Mar 2024 18:11:41 +0000 Subject: [PATCH 2/2] forgot these 2 --- openbb_platform/extensions/tests/test_integration_tests_api.py | 2 +- .../extensions/tests/test_integration_tests_python.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openbb_platform/extensions/tests/test_integration_tests_api.py b/openbb_platform/extensions/tests/test_integration_tests_api.py index 70f3d0823ad0..222791133872 100644 --- a/openbb_platform/extensions/tests/test_integration_tests_api.py +++ b/openbb_platform/extensions/tests/test_integration_tests_api.py @@ -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 ) diff --git a/openbb_platform/extensions/tests/test_integration_tests_python.py b/openbb_platform/extensions/tests/test_integration_tests_python.py index 8940db9821e6..abed14fa3013 100644 --- a/openbb_platform/extensions/tests/test_integration_tests_python.py +++ b/openbb_platform/extensions/tests/test_integration_tests_python.py @@ -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 )