summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Radovanovic <74266147+IgorWounds@users.noreply.github.com>2024-05-07 16:57:12 +0200
committerGitHub <noreply@github.com>2024-05-07 14:57:12 +0000
commite12aac157eb69573641aadcd93b1f244dd7dd6fe (patch)
treecaddc7e5a21a8e66c6ec3162bb15f8ef52968ae8
parent101990dffa40f45625aee3b3f7eb3d83381bf7e1 (diff)
[BugFix] - Fix tests for release (#6372)
* Fix user service * fix module import * proper Chart(...) mock * Fix SEC rss * improve test on to_chart() method * Fix form 13F example filing * remove broken example * Add lxml dep to SEC * fix default * fix: treasury_prices default date, last business day´ * fix: linting * fix: rebuild * ^ --------- Co-authored-by: hjoaquim <h.joaquim@campus.fct.unl.pt> Co-authored-by: Diogo Sousa <montezdesousa@gmail.com>
-rw-r--r--.pre-commit-config.yaml2
-rw-r--r--openbb_platform/core/openbb_core/app/model/preferences.py2
-rw-r--r--openbb_platform/core/openbb_core/provider/standard_models/treasury_prices.py2
-rw-r--r--openbb_platform/core/tests/app/service/test_user_service.py3
-rw-r--r--openbb_platform/extensions/technical/openbb_technical/technical_router.py5
-rw-r--r--openbb_platform/obbject_extensions/charting/tests/test_charting.py32
-rw-r--r--openbb_platform/openbb/assets/reference.json334
-rw-r--r--openbb_platform/openbb/package/__init__.py1
-rw-r--r--openbb_platform/openbb/package/derivatives_options.py4
-rw-r--r--openbb_platform/openbb/package/economy.py8
-rw-r--r--openbb_platform/openbb/package/equity_fundamental.py20
-rw-r--r--openbb_platform/openbb/package/equity_ownership.py2
-rw-r--r--openbb_platform/openbb/package/equity_price.py6
-rw-r--r--openbb_platform/openbb/package/etf.py12
-rw-r--r--openbb_platform/openbb/package/news.py89
-rw-r--r--openbb_platform/openbb/package/regulators_sec.py489
-rw-r--r--openbb_platform/providers/government_us/openbb_government_us/models/treasury_prices.py20
-rw-r--r--openbb_platform/providers/polygon/openbb_polygon/models/currency_pairs.py7
-rw-r--r--openbb_platform/providers/sec/openbb_sec/models/form_13FHR.py1
-rw-r--r--openbb_platform/providers/sec/openbb_sec/models/rss_litigation.py2
-rw-r--r--openbb_platform/providers/sec/pyproject.toml1
-rw-r--r--openbb_platform/providers/tmx/openbb_tmx/models/treasury_prices.py19
22 files changed, 460 insertions, 601 deletions
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index e16417a185e..5f507829eed 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -28,7 +28,7 @@ repos:
types: [python]
files: '^openbb_platform/.*\.py$'
exclude: 'tests/.*\.py|openbb_platform/test_.*\.py'
- args: ["--config=pyproject.toml"]
+ args: ["--config=ruff.toml"]
- repo: https://github.com/codespell-project/codespell
rev: v2.2.5
hooks:
diff --git a/openbb_platform/core/openbb_core/app/model/preferences.py b/openbb_platform/core/openbb_core/app/model/preferences.py
index 19c2d7f745d..44d44efd0d9 100644
--- a/openbb_platform/core/openbb_core/app/model/preferences.py
+++ b/openbb_platform/core/openbb_core/app/model/preferences.py
@@ -27,7 +27,7 @@ class Preferences(BaseModel):
)
plot_pywry_height: PositiveInt = 762
plot_pywry_width: PositiveInt = 1400
- request_timeout: PositiveInt = 15
+ request_timeout: PositiveInt = 60
show_warnings: bool = True
table_style: Literal["dark", "light"] = "dark"
user_styles_directory: str = str(Path.home() / "OpenBBUserData" / "styles" / "user")
diff --git a/openbb_platform/core/openbb_core/provider/standard_models/treasury_prices.py b/openbb_platform/core/openbb_core/provider/standard_models/treasury_prices.py
index 5f42f7d4de4..c803987b92a 100644
--- a/openbb_platform/core/openbb_core/provider/standard_models/treasury_prices.py
+++ b/openbb_platform/core/openbb_core/provider/standard_models/treasury_prices.py
@@ -15,7 +15,7 @@ class TreasuryPricesQueryParams(QueryParams):
date: Optional[dateType] = Field(
description=QUERY_DESCRIPTIONS.get("date", "")
- + " No date will return the current posted data.",
+ + " Defaults to the last business day.",
default=None,
)
diff --git a/openbb_platform/core/tests/app/service/test_user_service.py b/openbb_platform/core/tests/app/service/test_user_service.py
index aefe199382f..e65f0a56aca 100644
--- a/openbb_platform/core/tests/app/service/test_user_service.py
+++ b/openbb_platform/core/tests/app/service/test_user_service.py
@@ -57,7 +57,8 @@ def test_update_default():
# Update the default settings
updated_settings = UserService.update_default(other_settings)
- assert updated_settings.defaults.model_dump() == defaults_test.model_dump()
+ assert "test" in updated_settings.defaults.model_dump()["routes"]
+ assert updated_settings.defaults.model_dump()["routes"]["test"] == {"test": "test"}
def test_merge_dicts():
diff --git a/openbb_platform/extensions/technical/openbb_technical/technical_router.py b/openbb_platform/extensions/technical/openbb_technical/technical_router.py
index 47aa24d2700..3dbf2e3df84 100644
--- a/openbb_platform/extensions/technical/openbb_technical/technical_router.py
+++ b/openbb_platform/extensions/technical/openbb_technical/technical_router.py
@@ -57,11 +57,6 @@ router = Router(prefix="", description="Technical Analysis tools.")
+ " long_period=365, short_period=30, window=30, trading_periods=365)",
],
),
- APIEx(
- description="Note that the mock data displayed here is insufficient."
- + " It must contain multiple symbols, with the benchmark, and be daily data at least 1 year in length.",
- parameters={"benchmark": "SPY", "data": APIEx.mock_data("timeseries")},
- ),
],
)
async def relative_rotation(
diff --git a/openbb_platform/obbject_extensions/charting/tests/test_charting.py b/openbb_platform/obbject_extensions/charting/tests/test_charting.py
index 3f270c53a25..498b046fdb0 100644
--- a/openbb_platform/obbject_extensions/charting/tests/test_charting.py
+++ b/openbb_platform/obbject_extensions/charting/tests/test_charting.py
@@ -48,6 +48,7 @@ def obbject():
self.provider = "mock_provider"
self.extra = "mock_extra"
self.warnings = "mock_warnings"
+ self.chart = MagicMock()
def to_dataframe(self):
"""Mock to_dataframe."""
@@ -108,8 +109,8 @@ def test_functions(mock_get_charting_functions):
mock_get_charting_functions.assert_called_once()
-@patch("openbb_charting.core.backend.get_backend")
-@patch("openbb_charting.core.backend.create_backend")
+@patch("openbb_charting.get_backend")
+@patch("openbb_charting.create_backend")
def test_handle_backend(mock_create_backend, mock_get_backend, obbject):
"""Test _handle_backend method."""
# Act -> _handle backend is called in the constructor
@@ -136,7 +137,8 @@ def test_get_chart_function(mock_charting_router):
@patch("openbb_charting.Charting._get_chart_function")
-def test_show(mock_get_chart_function, obbject):
+@patch("openbb_charting.Chart")
+def test_show(_, mock_get_chart_function, obbject):
"""Test show method."""
# Arrange
mock_function = MagicMock()
@@ -151,28 +153,24 @@ def test_show(mock_get_chart_function, obbject):
# Assert
mock_get_chart_function.assert_called_once()
mock_function.assert_called_once()
- mock_fig.show.assert_called_once()
-@patch("openbb_charting.to_chart")
-def test_to_chart(mock_to_chart, obbject):
+@patch("openbb_charting.Charting._prepare_data_as_df")
+@patch("openbb_charting.Charting._get_chart_function")
+@patch("openbb_charting.Chart")
+def test_to_chart(_, mock_get_chart_function, mock_prepare_data_as_df, obbject):
"""Test to_chart method."""
# Arrange
+ mock_prepare_data_as_df.return_value = (mock_dataframe, True)
+ mock_function = MagicMock()
+ mock_get_chart_function.return_value = mock_function
mock_fig = MagicMock()
- mock_to_chart.return_value = (mock_fig, {"content": "mock_content"})
+ mock_function.return_value = (mock_fig, {"content": "mock_content"})
obj = Charting(obbject)
# Act
obj.to_chart()
# Assert
- assert obj._obbject.chart.fig == mock_fig
- mock_to_chart.assert_called_once_with(
- mock_dataframe,
- indicators=None,
- symbol="",
- candles=True,
- volume=True,
- prepost=False,
- volume_ticks_x=7,
- )
+ mock_get_chart_function.assert_called_once()
+ mock_function.assert_called_once()
diff --git a/openbb_platform/openbb/assets/reference.json b/openbb_platform/openbb/assets/reference.json
index 3d8781d622c..94947e5c4eb 100644
--- a/openbb_platform/openbb/assets/reference.json
+++ b/openbb_platform/openbb/assets/reference.json
@@ -629,7 +629,7 @@
"name": "sort",
"type": "Literal['ticker', 'name', 'market', 'locale', 'currency_symbol', 'currency_name', 'base_currency_symbol', 'base_currency_name', 'last_updated_utc', 'delisted_utc']",
"description": "Sort field used for ordering.",
- "default": "",
+ "default": null,
"optional": true
},
{
@@ -2681,7 +2681,7 @@
},
{
"name": "filter_variable",
- "type": "Literal[None, 'frequency', 'units', 'seasonal_adjustment']",
+ "type": "Literal['frequency', 'units', 'seasonal_adjustment']",
"description": "Filter by an attribute.",
"default": null,
"optional": true
@@ -2941,21 +2941,21 @@
"fred": [
{
"name": "frequency",
- "type": "Literal[None, 'a', 'q', 'm', 'w', 'd', 'wef', 'weth', 'wew', 'wetu', 'wem', 'wesu', 'wesa', 'bwew', 'bwem']",
+ "type": "Literal['a', 'q', 'm', 'w', 'd', 'wef', 'weth', 'wew', 'wetu', 'wem', 'wesu', 'wesa', 'bwew', 'bwem']",
"description": "Frequency aggregation to convert high frequency data to lower frequency. None = No change a = Annual q = Quarterly m = Monthly w = Weekly d = Daily wef = Weekly, Ending Friday weth = Weekly, Ending Thursday wew = Weekly, Ending Wednesday wetu = Weekly, Ending Tuesday wem = Weekly, Ending Monday wesu = Weekly, Ending Sunday wesa = Weekly, Ending Saturday bwew = Biweekly, Ending Wednesday bwem = Biweekly, Ending Monday",
"default": null,
"optional": true
},
{
"name": "aggregation_method",
- "type": "Literal[None, 'avg', 'sum', 'eop']",
+ "type": "Literal['avg', 'sum', 'eop']",
"description": "A key that indicates the aggregation method used for frequency aggregation. This parameter has no affect if the frequency parameter is not set. avg = Average sum = Sum eop = End of Period",
"default": "eop",
"optional": true
},
{
"name": "transform",
- "type": "Literal[None, 'chg', 'ch1', 'pch', 'pc1', 'pca', 'cch', 'cca', 'log']",
+ "type": "Literal['chg', 'ch1', 'pch', 'pc1', 'pca', 'cch', 'cca', 'log']",
"description": "Transformation type None = No transformation chg = Change ch1 = Change from Year Ago pch = Percent Change pc1 = Percent Change from Year Ago pca = Compounded Annual Rate of Change cch = Continuously Compounded Rate of Change cca = Continuously Compounded Annual Rate of Change log = Natural Log",
"default": null,
"optional": true
@@ -10092,14 +10092,14 @@
},
{
"name": "order",
- "type": "Literal[None, 'asc', 'desc']",
+ "type": "Literal['asc', 'desc']",
"description": "Order of the financial statement.",
"default": null,
"optional": true
},
{
"name": "sort",
- "type": "Literal[None, 'filing_date', 'period_of_report_date']",
+ "type": "Literal['filing_date', 'period_of_report_date']",
"description": "Sort of the financial statement.",
"default": null,
"optional": true
@@ -16024,7 +16024,7 @@
"sec": [
{
"name": "cik",
- "type": "Union[str, int]",
+ "type": "Union[int, str]",
"description": "Lookup filings by Central Index Key (CIK) instead of by symbol.",
"default": null,
"optional": true
@@ -16174,7 +16174,7 @@
},
{
"name": "act",
- "type": "Union[str, int]",
+ "type": "Union[int, str]",
"description": "The SEC Act number.",
"default": null,
"optional": true
@@ -16202,42 +16202,42 @@
},
{
"name": "accession_number",
- "type": "Union[str, int]",
+ "type": "Union[int, str]",
"description": "The accession number.",
"default": null,
"optional": true
},
{
"name": "file_number",
- "type": "Union[str, int]",
+ "type": "Union[int, str]",
"description": "The file number.",
"default": null,
"optional": true
},
{
"name": "film_number",
- "type": "Union[str, int]",
+ "type": "Union[int, str]",
"description": "The film number.",
"default": null,
"optional": true
},
{
"name": "is_inline_xbrl",
- "type": "Union[str, int]",
+ "type": "Union[int, str]",
"description": "Whether the filing is an inline XBRL filing.",
"default": null,
"optional": true
},
{
"name": "is_xbrl",
- "type": "Union[str, int]",
+ "type": "Union[int, str]",
"description": "Whether the filing is an XBRL filing.",
"default": null,
"optional": true
},
{
"name": "size",
- "type": "Union[str, int]",
+ "type": "Union[int, str]",
"description": "The size of the filing.",
"default": null,
"optional": true
@@ -23630,7 +23630,7 @@
},
{
"name": "rate_tenor_unit_rec",
- "type": "Union[str, int]",
+ "type": "Union[int, str]",
"description": "The rate tenor unit for receivable portion of the swap.",
"default": null,
"optional": true
@@ -23644,7 +23644,7 @@
},
{
"name": "reset_date_unit_rec",
- "type": "Union[str, int]",
+ "type": "Union[int, str]",
"description": "The reset date unit for receivable portion of the swap.",
"default": null,
"optional": true
@@ -23693,7 +23693,7 @@
},
{
"name": "rate_tenor_unit_pmnt",
- "type": "Union[str, int]",
+ "type": "Union[int, str]",
"description": "The rate tenor unit for payment portion of the swap.",
"default": null,
"optional": true
@@ -23707,7 +23707,7 @@
},
{
"name": "reset_date_unit_pmnt",
- "type": "Union[str, int]",
+ "type": "Union[int, str]",
"description": "The reset date unit for payment portion of the swap.",
"default": null,
"optional": true
@@ -26788,7 +26788,71 @@
}
],
"fmp": [],
- "intrinio": [],
+ "intrinio": [
+ {
+ "name": "source",
+ "type": "Literal['yahoo', 'moody', 'moody_us_news', 'moody_us_press_releases']",
+ "description": "The source of the news article.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "sentiment",
+ "type": "Literal['positive', 'neutral', 'negative']",
+ "description": "Return news only from this source.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "language",
+ "type": "str",
+ "description": "Filter by language. Unsupported for yahoo source.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "topic",
+ "type": "str",
+ "description": "Filter by topic. Unsupported for yahoo source.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "word_count_greater_than",
+ "type": "int",
+ "description": "News stories will have a word count greater than this value. Unsupported for yahoo source.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "word_count_less_than",
+ "type": "int",
+ "description": "News stories will have a word count less than this value. Unsupported for yahoo source.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "is_spam",
+ "type": "bool",
+ "description": "Filter whether it is marked as spam or not. Unsupported for yahoo source.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "business_relevance_greater_than",
+ "type": "float",
+ "description": "News stories will have a business relevance score more than this value. Unsupported for yahoo source.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "business_relevance_less_than",
+ "type": "float",
+ "description": "News stories will have a business relevance score less than this value. Unsupported for yahoo source.",
+ "default": null,
+ "optional": true
+ }
+ ],
"tiingo": [
{
"name": "offset",
@@ -26935,6 +26999,76 @@
],
"intrinio": [
{
+ "name": "source",
+ "type": "str",
+ "description": "The source of the news article.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "summary",
+ "type": "str",
+ "description": "The summary of the news article.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "topics",
+ "type": "str",
+ "description": "The topics related to the news article.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "word_count",
+ "type": "int",
+ "description": "The word count of the news article.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "business_relevance",
+ "type": "float",
+ "description": "How strongly correlated the news article is to the business",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "sentiment",
+ "type": "str",
+ "description": "The sentiment of the news article - i.e, negative, positive.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "sentiment_confidence",
+ "type": "float",
+ "description": "The confidence score of the sentiment rating.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "language",
+ "type": "str",
+ "description": "The language of the news article.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "spam",
+ "type": "bool",
+ "description": "Whether the news article is spam.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "copyright",
+ "type": "str",
+ "description": "The copyright notice of the news article.",
+ "default": null,
+ "optional": true
+ },
+ {
"name": "id",
"type": "str",
"description": "Article ID.",
@@ -26943,10 +27077,17 @@
},
{
"name": "company",
- "type": "Dict[str, Any]",
- "description": "Company details related to the news article.",
- "default": "",
- "optional": false
+ "type": "IntrinioCompany",
+ "description": "The Intrinio Company object. Contains details company reference data.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "security",
+ "type": "IntrinioSecurity",
+ "description": "The Intrinio Security object. Contains the security details related to the news article.",
+ "default": null,
+ "optional": true
}
],
"tiingo": [
@@ -27129,7 +27270,71 @@
"optional": true
}
],
- "intrinio": [],
+ "intrinio": [
+ {
+ "name": "source",
+ "type": "Literal['yahoo', 'moody', 'moody_us_news', 'moody_us_press_releases']",
+ "description": "The source of the news article.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "sentiment",
+ "type": "Literal['positive', 'neutral', 'negative']",
+ "description": "Return news only from this source.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "language",
+ "type": "str",
+ "description": "Filter by language. Unsupported for yahoo source.",
+ "default": null,
+ "optional": true
+ },
+ {
+ "name": "to