diff --git a/openbb_platform/platform/core/openbb_core/app/charting_service.py b/openbb_platform/platform/core/openbb_core/app/charting_service.py index c7fc8d75e66..13a8d80999e 100644 --- a/openbb_platform/platform/core/openbb_core/app/charting_service.py +++ b/openbb_platform/platform/core/openbb_core/app/charting_service.py @@ -187,22 +187,21 @@ class ChartingService(metaclass=SingletonMeta): """ Given an extension name, it returns the implemented charting functions from its router. """ + implemented_functions = [] try: - module = cls._get_extension_router(extension_name) + if module := cls._get_extension_router(extension_name): + module_name = module.__name__ + + for name, obj in getmembers(module, isfunction): + if ( + obj.__module__ == module_name + and not name.startswith("_") + and "NotImplementedError" not in getsource(obj) + ): + implemented_functions.append(name) except ChartingServiceError: - return [] - - implemented_functions = [] - module_name = module.__name__ - - for name, obj in getmembers(module, isfunction): - if ( - obj.__module__ == module_name - and not name.startswith("_") - and "NotImplementedError" not in getsource(obj) - ): - implemented_functions.append(name) + pass return implemented_functions diff --git a/openbb_platform/platform/core/tests/app/test_charting_service.py b/openbb_platform/platform/core/tests/app/test_charting_service.py index 0f054cd5b97..3b1354a756f 100644 --- a/openbb_platform/platform/core/tests/app/test_charting_service.py +++ b/openbb_platform/platform/core/tests/app/test_charting_service.py @@ -272,17 +272,18 @@ def test_get_implemented_charting_functions( @pytest.mark.parametrize( - "charting_extension_installed, expected_result", - [(True, ...), (False, ChartingServiceError)], + "charting_extension_installed", + [(True), (False)], ) @patch("openbb_core.app.charting_service.ChartingService._handle_backend") @patch("openbb_core.app.charting_service.import_module") +@patch("openbb_core.app.charting_service.ChartingService._get_chart_format") def test_to_chart( + mock_get_chart_format, mock_import_module, mock_handle_backend, charting_service, charting_extension_installed, - expected_result, ): charting_service._charting_extension_installed = charting_extension_installed @@ -294,8 +295,9 @@ def test_to_chart( return ("mock_fig", {"content": "mock_content"}) mock_import_module.return_value = MockBackendModule() + mock_get_chart_format.return_value = "plotly" - if expected_result != ChartingServiceError: + if charting_extension_installed: result = charting_service.to_chart() assert isinstance(result, Chart)