Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix] Pre release fixes #6478

Merged
merged 3 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 25 additions & 25 deletions cli/tests/test_models_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion openbb_platform/core/integration/test_obbject.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
30 changes: 17 additions & 13 deletions openbb_platform/core/tests/app/service/test_hub_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -317,26 +316,31 @@ def test_platform2hub():
[
# 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion openbb_platform/openbb/assets/reference.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down
4 changes: 2 additions & 2 deletions openbb_platform/openbb/package/economy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading