From 84625f07446b626066cc97daa82f66cf454149fc Mon Sep 17 00:00:00 2001 From: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com> Date: Mon, 25 Sep 2023 18:17:50 +0200 Subject: [PATCH] Updated tests --- .../crypto/integration/test_crypto_python.py | 54 +++++++++++++++--- .../integration/test_economy_python.py | 28 +++++----- .../forex/integration/test_forex_python.py | 56 ++++++++++++++++--- .../integration/test_futures_python.py | 8 +-- .../news/integration/test_news_python.py | 40 ++++++------- .../stocks/integration/test_stocks_python.py | 38 ++++++------- .../tests/utils/integration_test_generator.py | 6 +- 7 files changed, 156 insertions(+), 74 deletions(-) diff --git a/openbb_sdk/extensions/crypto/integration/test_crypto_python.py b/openbb_sdk/extensions/crypto/integration/test_crypto_python.py index e4388f557c0..617719b3a9a 100644 --- a/openbb_sdk/extensions/crypto/integration/test_crypto_python.py +++ b/openbb_sdk/extensions/crypto/integration/test_crypto_python.py @@ -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), } ), ], diff --git a/openbb_sdk/extensions/economy/integration/test_economy_python.py b/openbb_sdk/extensions/economy/integration/test_economy_python.py index b185727cb32..4aa25573226 100644 --- a/openbb_sdk/extensions/economy/integration/test_economy_python.py +++ b/openbb_sdk/extensions/economy/integration/test_economy_python.py @@ -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 diff --git a/openbb_sdk/extensions/forex/integration/test_forex_python.py b/openbb_sdk/extensions/forex/integration/test_forex_python.py index f44622df433..a11c882bc97 100644 --- a/openbb_sdk/extensions/forex/integration/test_forex_python.py +++ b/openbb_sdk/extensions/forex/integration/test_forex_python.py @@ -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), } ), ], diff --git a/openbb_sdk/extensions/futures/integration/test_futures_python.py b/openbb_sdk/extensions/futures/integration/test_futures_python.py index 1a14431fe13..be1167ba943 100644 --- a/openbb_sdk/extensions/futures/integration/test_futures_python.py +++ b/openbb_sdk/extensions/futures/integration/test_futures_python.py @@ -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", } ), ], diff --git a/openbb_sdk/extensions/news/integration/test_news_python.py b/openbb_sdk/extensions/news/integration/test_news_python.py index 7eddffaf83c..97b8a815a06 100644 --- a/openbb_sdk/extensions/news/integration/test_news_python.py +++ b/openbb_sdk/extensions/news/integration/test_news_python.py @@ -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", diff --git a/openbb_sdk/extensions/stocks/integration/test_stocks_python.py b/openbb_sdk/extensions/stocks/integration/test_stocks_python.py index 6f7d57ea7ba..665e8572f6a 100644 --- a/openbb_sdk/extensions/stocks/integration/test_stocks_python.py +++ b/openbb_sdk/extensions/stocks/integration/test_stocks_python.py @@ -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): diff --git a/openbb_sdk/extensions/tests/utils/integration_test_generator.py b/openbb_sdk/extensions/tests/utils/integration_test_generator.py index 81ca7f44585..11d867e11d8 100644 --- a/openbb_sdk/extensions/tests/utils/integration_test_generator.py +++ b/openbb_sdk/extensions/tests/utils/integration_test_generator.py @@ -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)