diff --git a/cli/tests/test_models_settings.py b/cli/tests/test_models_settings.py index 532d6bc0118a..f9f2a936cd1c 100644 --- a/cli/tests/test_models_settings.py +++ b/cli/tests/test_models_settings.py @@ -9,31 +9,31 @@ def test_default_values(): """Test the default values of the settings model.""" - settings = Settings() - assert settings.TEST_MODE is False - assert settings.DEBUG_MODE is False - assert settings.DEV_BACKEND is False - assert settings.FILE_OVERWRITE is False - assert settings.SHOW_VERSION is True - assert settings.USE_INTERACTIVE_DF is True - assert settings.USE_CLEAR_AFTER_CMD is False - assert settings.USE_DATETIME is True - assert settings.USE_PROMPT_TOOLKIT is True - assert settings.ENABLE_EXIT_AUTO_HELP is True - assert settings.REMEMBER_CONTEXTS is True - assert settings.ENABLE_RICH_PANEL is True - assert settings.TOOLBAR_HINT is True - assert settings.SHOW_MSG_OBBJECT_REGISTRY is False - assert settings.TIMEZONE == "America/New_York" - assert settings.FLAIR == ":openbb" - assert settings.PREVIOUS_USE is False - assert settings.N_TO_KEEP_OBBJECT_REGISTRY == 10 - assert settings.N_TO_DISPLAY_OBBJECT_REGISTRY == 5 - assert settings.RICH_STYLE == "dark" - assert settings.ALLOWED_NUMBER_OF_ROWS == 20 - assert settings.ALLOWED_NUMBER_OF_COLUMNS == 5 - assert settings.HUB_URL == "https://my.openbb.co" - assert settings.BASE_URL == "https://payments.openbb.co" + fields = Settings.model_fields + assert fields["TEST_MODE"].default is False + assert fields["DEBUG_MODE"].default is False + assert fields["DEV_BACKEND"].default is False + assert fields["FILE_OVERWRITE"].default is False + assert fields["SHOW_VERSION"].default is True + assert fields["USE_INTERACTIVE_DF"].default is True + assert fields["USE_CLEAR_AFTER_CMD"].default is False + assert fields["USE_DATETIME"].default is True + assert fields["USE_PROMPT_TOOLKIT"].default is True + assert fields["ENABLE_EXIT_AUTO_HELP"].default is True + assert fields["REMEMBER_CONTEXTS"].default is True + assert fields["ENABLE_RICH_PANEL"].default is True + assert fields["TOOLBAR_HINT"].default is True + assert fields["SHOW_MSG_OBBJECT_REGISTRY"].default is False + assert fields["TIMEZONE"].default == "America/New_York" + assert fields["FLAIR"].default == ":openbb" + assert fields["PREVIOUS_USE"].default is False + assert fields["N_TO_KEEP_OBBJECT_REGISTRY"].default == 10 + assert fields["N_TO_DISPLAY_OBBJECT_REGISTRY"].default == 5 + assert fields["RICH_STYLE"].default == "dark" + assert fields["ALLOWED_NUMBER_OF_ROWS"].default == 20 + assert fields["ALLOWED_NUMBER_OF_COLUMNS"].default == 5 + assert fields["HUB_URL"].default == "https://my.openbb.co" + assert fields["BASE_URL"].default == "https://payments.openbb.co" # Test __repr__ output diff --git a/openbb_platform/core/integration/test_obbject.py b/openbb_platform/core/integration/test_obbject.py index 4a2d1ad339f3..aaa1a940ffcb 100644 --- a/openbb_platform/core/integration/test_obbject.py +++ b/openbb_platform/core/integration/test_obbject.py @@ -41,7 +41,10 @@ def test_to_dataframe(obb): assert isinstance(stocks_df, pd.DataFrame) -@pytest.mark.skipif("polars" not in sys.modules, reason="polars not installed") +@pytest.mark.skipif( + "polars" not in sys.modules or "polars-lts-cpu" not in sys.modules, + reason="polars not installed", +) @pytest.mark.integration def test_to_polars(obb): """Test obbject to polars.""" diff --git a/openbb_platform/core/tests/app/service/test_hub_service.py b/openbb_platform/core/tests/app/service/test_hub_service.py index 37cab472d228..9c087f19520f 100644 --- a/openbb_platform/core/tests/app/service/test_hub_service.py +++ b/openbb_platform/core/tests/app/service/test_hub_service.py @@ -81,9 +81,8 @@ def test_v3tov4_map(): for provider in providers: if provider in v3_keys: keys = v3_keys[provider] - if not isinstance(keys, list): - keys = [keys] - for k in keys: + keys_list = keys if isinstance(keys, list) else [keys] + for k in keys_list: assert k in HubService.V3TOV4 @@ -313,30 +312,35 @@ def test_platform2hub(): @pytest.mark.parametrize( - "token, message", + "offset, message", [ # valid ( - encode( - {"some": "payload", "exp": int(time()) + 100}, - "secret", - algorithm="HS256", - ), + 100, None, ), # expired ( - encode( - {"some": "payload", "exp": int(time())}, "secret", algorithm="HS256" - ), + 0, "Platform personal access token expired.", ), # invalid - ("invalid_token", "Failed to decode Platform token."), + (None, "Failed to decode Platform token."), ], ) -def test__check_token_expiration(token, message): +def test__check_token_expiration(offset, message): """Test check token expiration function.""" + + token = ( + encode( + {"some": "payload", "exp": int(time()) + offset}, + "secret", + algorithm="HS256", + ) + if offset is not None + else "invalid_token" + ) + if message: with pytest.raises(OpenBBError, match=message): HubService._check_token_expiration(token) diff --git a/openbb_platform/extensions/economy/integration/test_economy_python.py b/openbb_platform/extensions/economy/integration/test_economy_python.py index 0ab1441af5bb..eae984cd3e14 100644 --- a/openbb_platform/extensions/economy/integration/test_economy_python.py +++ b/openbb_platform/extensions/economy/integration/test_economy_python.py @@ -531,8 +531,8 @@ def test_economy_long_term_interest_rate(params, obb): "units": None, "region_type": None, "season": None, - "aggregation_method": None, - "transform": None, + "aggregation_method": "avg", + "transform": "lin", "provider": "fred", "limit": None, } diff --git a/openbb_platform/extensions/economy/openbb_economy/economy_router.py b/openbb_platform/extensions/economy/openbb_economy/economy_router.py index 57b3cd55c972..4640defa77f2 100644 --- a/openbb_platform/extensions/economy/openbb_economy/economy_router.py +++ b/openbb_platform/extensions/economy/openbb_economy/economy_router.py @@ -178,13 +178,13 @@ async def money_measures( examples=[ APIEx(parameters={"provider": "oecd"}), APIEx( - parameters={"country": "all", "frequency": "quarterly", "provider": "oecd"} + parameters={"country": "all", "frequency": "quarter", "provider": "oecd"} ), APIEx( description="Demographics for the statistics are selected with the `age` parameter.", parameters={ "country": "all", - "frequency": "quarterly", + "frequency": "quarter", "age": "25-54", "provider": "oecd", }, diff --git a/openbb_platform/obbject_extensions/charting/openbb_charting/__init__.py b/openbb_platform/obbject_extensions/charting/openbb_charting/__init__.py index 884b370df426..7560b6fb3691 100644 --- a/openbb_platform/obbject_extensions/charting/openbb_charting/__init__.py +++ b/openbb_platform/obbject_extensions/charting/openbb_charting/__init__.py @@ -459,8 +459,9 @@ def to_chart( ) kwargs["provider"] = self._obbject.provider # pylint: disable=protected-access kwargs["extra"] = self._obbject.extra # pylint: disable=protected-access - kwargs["extra_params"] = kwargs["extra"]["metadata"].arguments.get( - "extra_params" + metadata = kwargs["extra"].get("metadata") + kwargs["extra_params"] = ( + metadata.arguments.get("extra_params") if metadata else None ) if "kwargs" in kwargs: _kwargs = kwargs.pop("kwargs") diff --git a/openbb_platform/obbject_extensions/charting/tests/test_charting.py b/openbb_platform/obbject_extensions/charting/tests/test_charting.py index 498b046fdb09..5849386987f3 100644 --- a/openbb_platform/obbject_extensions/charting/tests/test_charting.py +++ b/openbb_platform/obbject_extensions/charting/tests/test_charting.py @@ -46,7 +46,7 @@ def __init__(self): self.results = "mock_results" self.provider = "mock_provider" - self.extra = "mock_extra" + self.extra = {} self.warnings = "mock_warnings" self.chart = MagicMock() diff --git a/openbb_platform/openbb/assets/reference.json b/openbb_platform/openbb/assets/reference.json index afb50083b181..7347c827e925 100644 --- a/openbb_platform/openbb/assets/reference.json +++ b/openbb_platform/openbb/assets/reference.json @@ -4176,7 +4176,7 @@ "message": null }, "description": "Get global unemployment data.", - "examples": "\nExamples\n--------\n\n```python\nfrom openbb import obb\nobb.economy.unemployment(provider='oecd')\nobb.economy.unemployment(country='all', frequency='quarterly', provider='oecd')\n# Demographics for the statistics are selected with the `age` parameter.\nobb.economy.unemployment(country='all', frequency='quarterly', age=25-54, provider='oecd')\n```\n\n", + "examples": "\nExamples\n--------\n\n```python\nfrom openbb import obb\nobb.economy.unemployment(provider='oecd')\nobb.economy.unemployment(country='all', frequency='quarter', provider='oecd')\n# Demographics for the statistics are selected with the `age` parameter.\nobb.economy.unemployment(country='all', frequency='quarter', age=25-54, provider='oecd')\n```\n\n", "parameters": { "standard": [ { diff --git a/openbb_platform/openbb/package/economy.py b/openbb_platform/openbb/package/economy.py index 7051e8987191..1601627f3071 100644 --- a/openbb_platform/openbb/package/economy.py +++ b/openbb_platform/openbb/package/economy.py @@ -2211,9 +2211,9 @@ def unemployment( -------- >>> from openbb import obb >>> obb.economy.unemployment(provider='oecd') - >>> obb.economy.unemployment(country='all', frequency='quarterly', provider='oecd') + >>> obb.economy.unemployment(country='all', frequency='quarter', provider='oecd') >>> # Demographics for the statistics are selected with the `age` parameter. - >>> obb.economy.unemployment(country='all', frequency='quarterly', age='25-54', provider='oecd') + >>> obb.economy.unemployment(country='all', frequency='quarter', age='25-54', provider='oecd') """ # noqa: E501 return self._run(