mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-27 12:40:35 +00:00
[BugFix] - Fix most integration tests (#6082)
* Fix most integration tests * Lint
This commit is contained in:
@@ -98,7 +98,7 @@ def test_crypto_search(params, headers):
|
||||
"provider": "yfinance",
|
||||
"symbol": "BTCUSD",
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-06-06",
|
||||
"end_date": "2023-01-03",
|
||||
}
|
||||
),
|
||||
(
|
||||
|
||||
@@ -92,7 +92,7 @@ def test_crypto_search(params, obb):
|
||||
"provider": "yfinance",
|
||||
"symbol": "BTCUSD",
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-06-06",
|
||||
"end_date": "2023-01-04",
|
||||
}
|
||||
),
|
||||
(
|
||||
|
||||
@@ -96,6 +96,6 @@ def test_derivatives_futures_curve(params, headers):
|
||||
|
||||
query_str = get_querystring(params, [])
|
||||
url = f"http://0.0.0.0:8000/api/v1/derivatives/futures/curve?{query_str}"
|
||||
result = requests.get(url, headers=headers, timeout=30)
|
||||
result = requests.get(url, headers=headers, timeout=60)
|
||||
assert isinstance(result, requests.Response)
|
||||
assert result.status_code == 200
|
||||
|
||||
@@ -188,7 +188,7 @@ def autocorrelation(
|
||||
data: List[Data],
|
||||
y_column: str,
|
||||
x_columns: List[str],
|
||||
) -> OBBject[Dict]:
|
||||
) -> OBBject[Data]:
|
||||
"""Perform Durbin-Watson test for autocorrelation.
|
||||
|
||||
The Durbin-Watson test is a widely used method for detecting the presence of autocorrelation in the residuals
|
||||
|
||||
@@ -395,7 +395,7 @@ def test_economy_money_measures(params, headers):
|
||||
@parametrize(
|
||||
"params",
|
||||
[
|
||||
({"start_date": "2023-01-01", "end_date": "2023-06-06"}),
|
||||
({"start_date": "2023-01-01", "end_date": "2023-06-06", "provider": "oecd"}),
|
||||
(
|
||||
{
|
||||
"country": "united_states",
|
||||
@@ -424,7 +424,7 @@ def test_economy_unemployment(params, headers):
|
||||
@parametrize(
|
||||
"params",
|
||||
[
|
||||
({"start_date": "2023-01-01", "end_date": "2023-06-06"}),
|
||||
({"start_date": "2023-01-01", "end_date": "2023-06-06", "provider": "oecd"}),
|
||||
(
|
||||
{
|
||||
"country": "united_states",
|
||||
@@ -449,7 +449,7 @@ def test_economy_composite_leading_indicator(params, headers):
|
||||
@parametrize(
|
||||
"params",
|
||||
[
|
||||
({"start_date": "2023-01-01", "end_date": "2023-06-06"}),
|
||||
({"start_date": "2023-01-01", "end_date": "2023-06-06", "provider": "oecd"}),
|
||||
(
|
||||
{
|
||||
"country": "united_states",
|
||||
@@ -467,7 +467,7 @@ def test_economy_short_term_interest_rate(params, headers):
|
||||
|
||||
query_str = get_querystring(params, [])
|
||||
url = f"http://0.0.0.0:8000/api/v1/economy/short_term_interest_rate?{query_str}"
|
||||
result = requests.get(url, headers=headers, timeout=10)
|
||||
result = requests.get(url, headers=headers, timeout=30)
|
||||
assert isinstance(result, requests.Response)
|
||||
assert result.status_code == 200
|
||||
|
||||
@@ -475,7 +475,7 @@ def test_economy_short_term_interest_rate(params, headers):
|
||||
@parametrize(
|
||||
"params",
|
||||
[
|
||||
({"start_date": "2023-01-01", "end_date": "2023-06-06"}),
|
||||
({"start_date": "2023-01-01", "end_date": "2023-06-06", "provider": "oecd"}),
|
||||
(
|
||||
{
|
||||
"country": "united_states",
|
||||
|
||||
@@ -491,7 +491,7 @@ def test_economy_long_term_interest_rate(params, obb):
|
||||
def test_economy_fred_regional(params, obb):
|
||||
params = {p: v for p, v in params.items() if v}
|
||||
|
||||
result = obb.economy.long_term_interest_rate(**params)
|
||||
result = obb.economy.fred_regional(**params)
|
||||
assert result
|
||||
assert isinstance(result, OBBject)
|
||||
assert len(result.results) > 0
|
||||
|
||||
@@ -959,7 +959,7 @@ def test_equity_compare_groups(params, headers):
|
||||
"provider": "polygon",
|
||||
"symbol": "AAPL",
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-01-02",
|
||||
"end_date": "2023-01-04",
|
||||
"interval": "1m",
|
||||
}
|
||||
),
|
||||
@@ -1295,9 +1295,7 @@ def test_equity_price_quote(params, headers):
|
||||
@parametrize(
|
||||
"params",
|
||||
[
|
||||
({"symbol": "AAPL", "provider": "cboe"}),
|
||||
({"symbol": "MSFT", "provider": "intrinio"}),
|
||||
({"symbol": "AAPL,MSFT", "provider": "cboe"}),
|
||||
({"symbol": "AAPL,MSFT", "provider": "intrinio"}),
|
||||
({"symbol": "AAPL,MSFT", "provider": "finviz"}),
|
||||
({"symbol": "AAPL,MSFT", "provider": "yfinance"}),
|
||||
|
||||
@@ -1127,7 +1127,7 @@ def test_equity_fundamental_historical_attributes(params, obb):
|
||||
(
|
||||
{
|
||||
"provider": "intrinio",
|
||||
"symbol": ["AAPL", "MSFT"],
|
||||
"symbol": ["MSFT", "AAPL"],
|
||||
"tag": ["ceo", "ebitda"],
|
||||
}
|
||||
),
|
||||
|
||||
@@ -155,10 +155,10 @@ def test_index_price_historical(params, headers):
|
||||
{
|
||||
"symbol": "^DJI",
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-06-06",
|
||||
"end_date": "2023-03-03",
|
||||
"provider": "fmp",
|
||||
"sort": "desc",
|
||||
"interval": None,
|
||||
"interval": "1day",
|
||||
"limit": None,
|
||||
}
|
||||
),
|
||||
|
||||
@@ -38,7 +38,7 @@ def test_index_constituents(params, obb):
|
||||
[
|
||||
(
|
||||
{
|
||||
"interval": "1m",
|
||||
"interval": "1d",
|
||||
"provider": "cboe",
|
||||
"symbol": "AAVE100",
|
||||
"start_date": "2024-01-01",
|
||||
@@ -148,20 +148,20 @@ def test_index_price_historical(params, obb):
|
||||
{
|
||||
"symbol": "^DJI",
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-06-06",
|
||||
"end_date": "2023-03-03",
|
||||
"provider": "fmp",
|
||||
"sort": "desc",
|
||||
"interval": None,
|
||||
"interval": "1day",
|
||||
"limit": None,
|
||||
}
|
||||
),
|
||||
(
|
||||
{
|
||||
"interval": "1m",
|
||||
"interval": "1d",
|
||||
"provider": "cboe",
|
||||
"symbol": "AAVE100",
|
||||
"start_date": "2023-01-01",
|
||||
"end_date": "2023-06-06",
|
||||
"end_date": "2023-01-05",
|
||||
"use_cache": True,
|
||||
"limit": None,
|
||||
"sort": None,
|
||||
|
||||
@@ -153,7 +153,7 @@ def test_news_world(params, obb):
|
||||
(
|
||||
{
|
||||
"provider": "tiingo",
|
||||
"symbol": "AAPL,MSFT",
|
||||
"symbol": "AAPL",
|
||||
"limit": 20,
|
||||
"source": "bloomberg.com",
|
||||
"start_date": None,
|
||||
|
||||
@@ -10,6 +10,8 @@ from extensions.tests.utils.helpers import list_openbb_extensions
|
||||
cm = CommandMap()
|
||||
commands = list(cm.map.keys())
|
||||
|
||||
# ruff: noqa: SIM114
|
||||
|
||||
|
||||
def parametrize(argnames: str, argvalues: List[Dict], **kwargs):
|
||||
"""Custom parametrize decorator that filters test cases based on the environment."""
|
||||
@@ -21,7 +23,17 @@ def parametrize(argnames: str, argvalues: List[Dict], **kwargs):
|
||||
filtered_argvalues: List[Dict] = []
|
||||
extension_name = function.__name__.split("_")[1]
|
||||
function_name = "/" + "/".join(function.__name__.split("_")[1:])
|
||||
|
||||
# this handles edge cases where the function name has an underscore
|
||||
function_name_v2 = (
|
||||
function_name.rsplit("/", 1)[0] + "_" + function_name.rsplit("/", 1)[1]
|
||||
)
|
||||
function_name_v3 = (
|
||||
function_name.rsplit("/", 2)[0]
|
||||
+ "_"
|
||||
+ function_name.rsplit("/", 2)[1]
|
||||
+ "_"
|
||||
+ function_name.rsplit("/", 1)[1].replace("/", "_")
|
||||
)
|
||||
if extension_name in extensions:
|
||||
for args in argvalues:
|
||||
if "provider" in args and args["provider"] in providers:
|
||||
@@ -29,6 +41,12 @@ def parametrize(argnames: str, argvalues: List[Dict], **kwargs):
|
||||
elif "provider" not in args and function_name in commands:
|
||||
# Run the standard test case
|
||||
filtered_argvalues.append(args)
|
||||
elif "provider" not in args and function_name_v2 in commands:
|
||||
# Handle edge case
|
||||
filtered_argvalues.append(args)
|
||||
elif "provider" not in args and function_name_v3 in commands:
|
||||
# Handle edge case
|
||||
filtered_argvalues.append(args)
|
||||
return pytest.mark.parametrize(argnames, filtered_argvalues, **kwargs)(
|
||||
function
|
||||
)
|
||||
|
||||
@@ -26,7 +26,10 @@ class IntrinioHistoricalAttributesQueryParams(HistoricalAttributesQueryParams):
|
||||
"""
|
||||
|
||||
__alias_dict__ = {"sort": "sort_order", "limit": "page_size", "tag_type": "type"}
|
||||
__json_schema_extra__ = {"tag": ["multiple_items_allowed"]}
|
||||
__json_schema_extra__ = {
|
||||
"tag": ["multiple_items_allowed"],
|
||||
"symbol": ["multiple_items_allowed"],
|
||||
}
|
||||
|
||||
|
||||
class IntrinioHistoricalAttributesData(HistoricalAttributesData):
|
||||
|
||||
@@ -22,7 +22,10 @@ class IntrinioLatestAttributesQueryParams(LatestAttributesQueryParams):
|
||||
https://docs.intrinio.com/documentation/web_api/get_data_point_text_v2
|
||||
"""
|
||||
|
||||
__json_schema_extra__ = {"tag": ["multiple_items_allowed"]}
|
||||
__json_schema_extra__ = {
|
||||
"tag": ["multiple_items_allowed"],
|
||||
"symbol": ["multiple_items_allowed"],
|
||||
}
|
||||
|
||||
|
||||
class IntrinioLatestAttributesData(LatestAttributesData):
|
||||
|
||||
Reference in New Issue
Block a user