Updated tests

This commit is contained in:
Igor Radovanovic
2023-09-25 18:17:50 +02:00
parent 148771cbf2
commit 84625f0744
7 changed files with 156 additions and 74 deletions

View File

@@ -1,4 +1,6 @@
"""Test crypto extension."""
import datetime
import pytest
from openbb import obb
from openbb_core.app.model.obbject import OBBject
@@ -7,14 +9,42 @@ from openbb_core.app.model.obbject import OBBject
@pytest.mark.parametrize(
"params",
[
({"symbol": "AAPL", "start_date": "2023-01-01", "end_date": "2023-06-06"}),
(
{
"symbol": "AAPL",
"start_date": datetime.date(2023, 1, 1),
"end_date": datetime.date(2023, 6, 6),
}
),
(
{
"interval": "1min",
"provider": "fmp",
"symbol": "AAPL",
"start_date": datetime.date(2023, 1, 1),
"end_date": datetime.date(2023, 6, 6),
}
),
(
{
"interval": "1day",
"provider": "fmp",
"symbol": "AAPL",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
"start_date": datetime.date(2023, 1, 1),
"end_date": datetime.date(2023, 6, 6),
}
),
(
{
"multiplier": 1,
"timespan": "minute",
"sort": "desc",
"limit": 49999,
"adjusted": True,
"provider": "polygon",
"symbol": "AAPL",
"start_date": datetime.date(2023, 1, 1),
"end_date": datetime.date(2023, 6, 6),
}
),
(
@@ -26,8 +56,18 @@ from openbb_core.app.model.obbject import OBBject
"adjusted": True,
"provider": "polygon",
"symbol": "AAPL",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
"start_date": datetime.date(2023, 1, 1),
"end_date": datetime.date(2023, 6, 6),
}
),
(
{
"interval": "5m",
"period": "max",
"provider": "yfinance",
"symbol": "AAPL",
"start_date": datetime.date(2023, 1, 1),
"end_date": datetime.date(2023, 6, 6),
}
),
(
@@ -36,8 +76,8 @@ from openbb_core.app.model.obbject import OBBject
"period": "max",
"provider": "yfinance",
"symbol": "AAPL",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
"start_date": datetime.date(2023, 1, 1),
"end_date": datetime.date(2023, 6, 6),
}
),
],

View File

@@ -98,12 +98,12 @@ def test_economy_index(params):
@pytest.mark.parametrize(
"params",
[
({"symbol": "AAPL", "start_date": "2023-01-01", "end_date": "2023-06-06"}),
({"symbol": "BUKBUS", "start_date": "2023-01-01", "end_date": "2023-06-06"}),
(
{
"interval": "1d",
"provider": "cboe",
"symbol": "AAPL",
"symbol": "BUKBUS",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
}
@@ -111,7 +111,7 @@ def test_economy_index(params):
],
)
def test_economy_european_index(params):
result = obb.economy.european.index(params)
result = obb.economy.european_index(params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@@ -120,11 +120,11 @@ def test_economy_european_index(params):
@pytest.mark.parametrize(
"params",
[
({"symbol": "AAPL"}),
({"symbol": "BUKBUS"}),
],
)
def test_economy_european_index_constituents(params):
result = obb.economy.european.index_constituents(params)
result = obb.economy.european_index_constituents(params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@@ -138,7 +138,7 @@ def test_economy_european_index_constituents(params):
],
)
def test_economy_available_indices(params):
result = obb.economy.available.indices(params)
result = obb.economy.available_indices(params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@@ -160,19 +160,19 @@ def test_economy_risk(params):
@pytest.mark.parametrize(
"params",
[
({"query": "TEST_STRING", "symbol": "AAPL"}),
({"query": "DJ", "symbol": True}),
(
{
"europe": True,
"provider": "cboe",
"query": "TEST_STRING",
"symbol": "AAPL",
"query": "DJ",
"symbol": True,
}
),
],
)
def test_economy_index_search(params):
result = obb.economy.index.search(params)
result = obb.economy.index_search(params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@@ -185,7 +185,7 @@ def test_economy_index_search(params):
],
)
def test_economy_index_snapshots(params):
result = obb.economy.index.snapshots(params)
result = obb.economy.index_snapshots(params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@@ -194,11 +194,11 @@ def test_economy_index_snapshots(params):
@pytest.mark.parametrize(
"params",
[
({"query": "TEST_STRING"}),
({"query": "grain"}),
],
)
def test_economy_cot_search(params):
result = obb.economy.cot.search(params)
result = obb.economy.cot_search(params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@@ -245,7 +245,7 @@ def test_economy_cot(params):
],
)
def test_economy_sp500_multiples(params):
result = obb.economy.sp500.multiples(params)
result = obb.economy.sp500_multiples(params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0

View File

@@ -1,4 +1,6 @@
"""Test forex extension."""
import datetime
import pytest
from openbb import obb
from openbb_core.app.model.obbject import OBBject
@@ -12,7 +14,7 @@ from openbb_core.app.model.obbject import OBBject
{
"symbol": "AAPL",
"date": datetime.date(2023, 9, 25),
"search": "TEST_STRING",
"search": "USD",
"active": True,
"order": "asc",
"sort": "ticker",
@@ -32,14 +34,42 @@ def test_forex_pairs(params):
@pytest.mark.parametrize(
"params",
[
({"symbol": "AAPL", "start_date": "2023-01-01", "end_date": "2023-06-06"}),
(
{
"symbol": "AAPL",
"start_date": datetime.date(2023, 1, 1),
"end_date": datetime.date(2023, 6, 6),
}
),
(
{
"interval": "1min",
"provider": "fmp",
"symbol": "AAPL",
"start_date": datetime.date(2023, 1, 1),
"end_date": datetime.date(2023, 6, 6),
}
),
(
{
"interval": "1day",
"provider": "fmp",
"symbol": "AAPL",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
"start_date": datetime.date(2023, 1, 1),
"end_date": datetime.date(2023, 6, 6),
}
),
(
{
"multiplier": 1,
"timespan": "min",
"sort": "desc",
"limit": 49999,
"adjusted": True,
"provider": "polygon",
"symbol": "AAPL",
"start_date": datetime.date(2023, 1, 1),
"end_date": datetime.date(2023, 6, 6),
}
),
(
@@ -51,8 +81,18 @@ def test_forex_pairs(params):
"adjusted": True,
"provider": "polygon",
"symbol": "AAPL",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
"start_date": datetime.date(2023, 1, 1),
"end_date": datetime.date(2023, 6, 6),
}
),
(
{
"interval": "5m",
"period": "max",
"provider": "yfinance",
"symbol": "AAPL",
"start_date": datetime.date(2023, 1, 1),
"end_date": datetime.date(2023, 6, 6),
}
),
(
@@ -61,8 +101,8 @@ def test_forex_pairs(params):
"period": "max",
"provider": "yfinance",
"symbol": "AAPL",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
"start_date": datetime.date(2023, 1, 1),
"end_date": datetime.date(2023, 6, 6),
}
),
],

View File

@@ -9,10 +9,10 @@ from openbb_core.app.model.obbject import OBBject
[
(
{
"symbol": "AAPL",
"symbol": "ES",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
"expiration": "TEST_STRING",
"expiration": "2024-06",
}
),
(
@@ -23,10 +23,10 @@ from openbb_core.app.model.obbject import OBBject
"adjust": True,
"back_adjust": True,
"provider": "yfinance",
"symbol": "AAPL",
"symbol": "ES",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
"expiration": "TEST_STRING",
"expiration": "2024-06",
}
),
],

View File

@@ -1,4 +1,6 @@
"""Test news extension."""
import datetime
import pytest
from openbb import obb
from openbb_core.app.model.obbject import OBBject
@@ -11,19 +13,19 @@ from openbb_core.app.model.obbject import OBBject
(
{
"display": "full",
"date": "2023-01-01",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
"date": datetime.date(2023, 1, 1),
"start_date": datetime.date(2023, 1, 1),
"end_date": datetime.date(2023, 6, 6),
"updated_since": 1,
"published_since": 1,
"sort": "created",
"order": "desc",
"isin": "TEST_STRING",
"cusip": "TEST_STRING",
"channels": "TEST_STRING",
"topics": "TEST_STRING",
"authors": "TEST_STRING",
"content_types": "TEST_STRING",
"isin": "US0378331005",
"cusip": "037833100",
"channels": "General",
"topics": "Elon Musk",
"authors": "Benzinga Insights",
"content_types": "Car",
"provider": "benzinga",
"limit": 20,
}
@@ -44,19 +46,19 @@ def test_news_globalnews(params):
(
{
"display": "full",
"date": "2023-01-01",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
"date": datetime.date(2023, 1, 1),
"start_date": datetime.date(2023, 1, 1),
"end_date": datetime.date(2023, 6, 6),
"updated_since": 1,
"published_since": 1,
"sort": "created",
"order": "desc",
"isin": "TEST_STRING",
"cusip": "TEST_STRING",
"channels": "TEST_STRING",
"topics": "TEST_STRING",
"authors": "TEST_STRING",
"content_types": "TEST_STRING",
"isin": "US0378331005",
"cusip": "037833100",
"channels": "General",
"topics": "Elon Musk",
"authors": "Benzinga Insights",
"content_types": "Car",
"provider": "benzinga",
"symbols": "AAPL,MSFT",
"limit": 20,
@@ -64,7 +66,7 @@ def test_news_globalnews(params):
),
(
{
"published_utc": "TEST_STRING",
"content_types": datetime.date(2023, 1, 1),
"order": "desc",
"provider": "polygon",
"symbols": "AAPL,MSFT",

View File

@@ -20,9 +20,9 @@ from openbb_core.app.model.obbject import OBBject
),
(
{
"company_name": "TEST_STRING",
"company_name_search": "TEST_STRING",
"sic": "TEST_STRING",
"company_name": "Apple Inc",
"company_name_search": "AAPL",
"sic": "35719904",
"include_sources": True,
"order": "asc",
"sort": "filing_date",
@@ -83,9 +83,9 @@ def test_stocks_fa_cal(params):
),
(
{
"company_name": "TEST_STRING",
"company_name_search": "TEST_STRING",
"sic": "TEST_STRING",
"company_name": "Apple Inc",
"company_name_search": "AAPL",
"sic": "35719904",
"include_sources": True,
"order": "asc",
"sort": "filing_date",
@@ -211,9 +211,9 @@ def test_stocks_fa_est(params):
),
(
{
"company_name": "TEST_STRING",
"company_name_search": "TEST_STRING",
"sic": "TEST_STRING",
"company_name": "Apple Inc",
"company_name_search": "AAPL",
"sic": "35719904",
"include_sources": True,
"order": "asc",
"sort": "filing_date",
@@ -486,7 +486,7 @@ def test_stocks_options_chains(params):
"interval": "60min",
"adjusted": True,
"extended_hours": True,
"month": "TEST_STRING",
"month": "2023-03",
"outputsize": "full",
"provider": "alpha_vantage",
"symbol": "AAPL",
@@ -579,12 +579,12 @@ def test_stocks_load(params):
"published_since": 1,
"sort": "created",
"order": "desc",
"isin": "TEST_STRING",
"cusip": "TEST_STRING",
"channels": "TEST_STRING",
"topics": "TEST_STRING",
"authors": "TEST_STRING",
"content_types": "TEST_STRING",
"isin": "US0378331005",
"cusip": "037833100",
"channels": "General",
"topics": "AAPL",
"authors": "Benzinga Insights",
"content_types": "headline",
"provider": "benzinga",
"symbols": "AAPL,MSFT",
"limit": 20,
@@ -592,10 +592,10 @@ def test_stocks_load(params):
),
(
{
"published_utc": "TEST_STRING",
"published_utc": "2023-01-01",
"order": "desc",
"provider": "polygon",
"symbols": "AAPL,MSFT",
"symbols": "AAPL",
"limit": 20,
}
),
@@ -624,7 +624,7 @@ def test_stocks_multiples(params):
@pytest.mark.parametrize(
"params",
[
({"query": "TEST_STRING", "ticker": True}),
({"query": "AAPL", "ticker": True}),
],
)
def test_stocks_search(params):

View File

@@ -17,7 +17,7 @@ def find_extensions():
return extensions
def create_integration_test_files(extensions: List[PosixPath]):
def create_integration_test_files(extensions: List[PosixPath]) -> None:
"""Create integration test files for the python interface."""
for extension in extensions:
extension_name = extension.name
@@ -98,7 +98,7 @@ def get_test_params(
def add_test_commands_to_file( # pylint: disable=W0102
extensions: List[PosixPath],
commands_model: Dict[str, str] = cm.commands_model,
):
) -> None:
"""Add test commands to file."""
provider_interface = ProviderInterface()
provider_interface_map = provider_interface.map
@@ -161,7 +161,7 @@ def test_{test_name}(params):
)
def write_integration_test():
def write_integration_test() -> None:
"""Write integration test."""
extensions = find_extensions()
create_integration_test_files(extensions)