mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-27 12:40:35 +00:00
[BugFix] Pre release fixes (#6478)
* fix: tests * fix: rebuild * fix: hub test
This commit is contained in:
@@ -9,31 +9,31 @@ from openbb_cli.models.settings import Settings
|
||||
|
||||
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
|
||||
|
||||
@@ -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."""
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
},
|
||||
|
||||
@@ -459,8 +459,9 @@ class Charting:
|
||||
)
|
||||
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")
|
||||
|
||||
@@ -46,7 +46,7 @@ def obbject():
|
||||
self.results = "mock_results"
|
||||
|
||||
self.provider = "mock_provider"
|
||||
self.extra = "mock_extra"
|
||||
self.extra = {}
|
||||
self.warnings = "mock_warnings"
|
||||
self.chart = MagicMock()
|
||||
|
||||
|
||||
2
openbb_platform/openbb/assets/reference.json
vendored
2
openbb_platform/openbb/assets/reference.json
vendored
@@ -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": [
|
||||
{
|
||||
|
||||
@@ -2211,9 +2211,9 @@ class ROUTER_economy(Container):
|
||||
--------
|
||||
>>> 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(
|
||||
|
||||
Reference in New Issue
Block a user