From 6e3038b9e796024a7205d342f3438fee733f54b2 Mon Sep 17 00:00:00 2001 From: Henrique Joaquim Date: Wed, 29 Nov 2023 18:35:45 +0000 Subject: [PATCH] Fix tests (#5819) * fix equity tests - python * remove test for intrinio * remove index.fred and fix tests w/@hjoaquim,@IgorWounds * fix ultima company news model w/@hjoaquim,@IgorWounds * re-record intrinio insider trading w/@hjoaquim,@IgorWounds * adjust endpoint * adjust endpoint * adjust params * fix equity test w/@IgorWounds * re-record * remove ultima test * adding keys to the workflow * typo --------- Co-authored-by: Pratyush Shukla --- .../platform-api-integration-test.yml | 4 +- .../equity/integration/test_equity_api.py | 17 ++------- .../equity/integration/test_equity_python.py | 38 +++++++++++-------- .../integration/test_fixedincome_api.py | 2 +- .../integration/test_fixedincome_python.py | 2 +- .../index/integration/test_index_api.py | 25 ------------ .../index/integration/test_index_python.py | 22 ----------- .../index/openbb_index/index_router.py | 11 ------ .../news/integration/test_news_api.py | 7 ---- .../news/integration/test_news_python.py | 7 ---- ...test_intrinio_insider_trading_fetcher.yaml | 6 +-- .../openbb_ultima/models/company_news.py | 13 +++++-- 12 files changed, 42 insertions(+), 112 deletions(-) diff --git a/.github/workflows/platform-api-integration-test.yml b/.github/workflows/platform-api-integration-test.yml index 5fa38ebf2f2..1bc4ad96bb3 100644 --- a/.github/workflows/platform-api-integration-test.yml +++ b/.github/workflows/platform-api-integration-test.yml @@ -73,7 +73,9 @@ jobs: "intrinio_api_key": "${{ secrets.INTRINIO_API_KEY }}", "tradingeconomics_api_key": "${{ secrets.TRADINGECONOMICS_API_KEY }}", "quandl_api_key": "${{ secrets.QUANDL_API_KEY }}", - "biztoc_api_key": "${{ secrets.BIZTOC_API_KEY }}" + "biztoc_api_key": "${{ secrets.BIZTOC_API_KEY }}", + "nasdaq_api_key": "${{ secrets.NASDAQ_API_KEY }}", + "tiingo_token": "${{ secrets.TIINGO_TOKEN }}" } }' > ~/.openbb_platform/user_settings.json diff --git a/openbb_platform/extensions/equity/integration/test_equity_api.py b/openbb_platform/extensions/equity/integration/test_equity_api.py index ff328e373cc..1a1fb621f84 100644 --- a/openbb_platform/extensions/equity/integration/test_equity_api.py +++ b/openbb_platform/extensions/equity/integration/test_equity_api.py @@ -120,7 +120,7 @@ def test_equity_calendar_splits(params, headers): params = {p: v for p, v in params.items() if v} query_str = get_querystring(params, []) - url = f"http://0.0.0.0:8000/api/v1/equity/calendar/split?{query_str}" + url = f"http://0.0.0.0:8000/api/v1/equity/calendar/splits?{query_str}" result = requests.get(url, headers=headers, timeout=10) assert isinstance(result, requests.Response) assert result.status_code == 200 @@ -445,7 +445,7 @@ def test_equity_ownership_institutional(params, headers): query_str = get_querystring(params, []) url = f"http://0.0.0.0:8000/api/v1/equity/ownership/institutional?{query_str}" - result = requests.get(url, headers=headers, timeout=10) + result = requests.get(url, headers=headers, timeout=20) assert isinstance(result, requests.Response) assert result.status_code == 200 @@ -1273,17 +1273,6 @@ def test_equity_discovery_upcoming_release_days(params, headers): "provider": "fmp", } ), - ( - { - "provider": "intrinio", - "symbol": "AAPL", - "thea_enabled": None, - "start_date": "2023-11-06", - "end_date": "2023-11-07", - "limit": 50, - "form_type": "10-Q", - } - ), ], ) @pytest.mark.integration @@ -1310,7 +1299,7 @@ def test_equity_shorts_fails_to_deliver(params, headers): query_str = get_querystring(params, []) url = f"http://0.0.0.0:8000/api/v1/equity/shorts/fails_to_deliver?{query_str}" - result = requests.get(url, headers=headers, timeout=10) + result = requests.get(url, headers=headers, timeout=20) assert isinstance(result, requests.Response) assert result.status_code == 200 diff --git a/openbb_platform/extensions/equity/integration/test_equity_python.py b/openbb_platform/extensions/equity/integration/test_equity_python.py index 49662de4a3f..a684d4789aa 100644 --- a/openbb_platform/extensions/equity/integration/test_equity_python.py +++ b/openbb_platform/extensions/equity/integration/test_equity_python.py @@ -114,7 +114,7 @@ def test_equity_calendar_dividend(params, obb): ) @pytest.mark.integration def test_equity_calendar_splits(params, obb): - result = obb.equity.calendar.split(**params) + result = obb.equity.calendar.splits(**params) assert result assert isinstance(result, OBBject) assert len(result.results) > 0 @@ -477,7 +477,10 @@ def test_equity_fundamental_metrics(params, obb): result = obb.equity.fundamental.metrics(**params) assert result assert isinstance(result, OBBject) - assert len(result.results) > 0 + if isinstance(result.results, list): + assert len(result.results) > 0 + else: + assert result.results is not None @pytest.mark.parametrize( @@ -505,6 +508,7 @@ def test_equity_fundamental_overview(params, obb): result = obb.equity.fundamental.overview(**params) assert result assert isinstance(result, OBBject) + assert result.results is not None @pytest.mark.parametrize( @@ -532,6 +536,7 @@ def test_equity_estimates_price_target(params, obb): result = obb.equity.estimates.price_target(**params) assert result assert isinstance(result, OBBject) + assert result.results is not None @pytest.mark.parametrize( @@ -543,6 +548,7 @@ def test_equity_estimates_consensus(params, obb): result = obb.equity.estimates.consensus(**params) assert result assert isinstance(result, OBBject) + assert result.results is not None @pytest.mark.parametrize( @@ -673,6 +679,7 @@ def test_equity_compare_peers(params, obb): result = obb.equity.compare.peers(**params) assert result assert isinstance(result, OBBject) + assert result.results is not None @pytest.mark.parametrize( @@ -941,7 +948,10 @@ def test_equity_fundamental_latest_attributes(params, obb): result = obb.equity.fundamental.latest_attributes(**params) assert result assert isinstance(result, OBBject) - assert len(result.results) > 0 + if isinstance(result.results, list): + assert len(result.results) > 0 + else: + assert result.results is not None @pytest.mark.parametrize( @@ -1007,6 +1017,7 @@ def test_equity_price_quote(params, obb): result = obb.equity.price.quote(**params) assert result assert isinstance(result, OBBject) + assert result.results is not None @pytest.mark.parametrize( @@ -1021,7 +1032,10 @@ def test_equity_profile(params, obb): result = obb.equity.profile(**params) assert result assert isinstance(result, OBBject) - assert len(result.results) > 0 + if isinstance(result.results, list): + assert len(result.results) > 0 + else: + assert result.results is not None @pytest.mark.parametrize( @@ -1187,17 +1201,6 @@ def test_equity_discovery_upcoming_release_days(params, obb): "provider": "fmp", } ), - ( - { - "provider": "intrinio", - "symbol": "AAPL", - "thea_enabled": None, - "start_date": "2023-11-06", - "end_date": "2023-11-07", - "limit": 50, - "form_type": "10-Q", - } - ), ], ) @pytest.mark.integration @@ -1207,7 +1210,10 @@ def test_equity_discovery_filings(params, obb): result = obb.equity.discovery.filings(**params) assert result assert isinstance(result, OBBject) - assert len(result.results) > 0 + if isinstance(result.results, list): + assert len(result.results) > 0 + else: + assert result.results is not None @pytest.mark.parametrize( diff --git a/openbb_platform/extensions/fixedincome/integration/test_fixedincome_api.py b/openbb_platform/extensions/fixedincome/integration/test_fixedincome_api.py index 30151c1411b..09cb13bd961 100644 --- a/openbb_platform/extensions/fixedincome/integration/test_fixedincome_api.py +++ b/openbb_platform/extensions/fixedincome/integration/test_fixedincome_api.py @@ -351,7 +351,7 @@ def test_fixedincome_corporate_spot_rates(params, headers): @pytest.mark.parametrize( "params", - [({"date": "2023-01-01", "yield_curve": ["spot"]})], + [({"date": "2023-01-01", "yield_curve": "spot"})], ) @pytest.mark.integration def test_fixedincome_corporate_hqm(params, headers): diff --git a/openbb_platform/extensions/fixedincome/integration/test_fixedincome_python.py b/openbb_platform/extensions/fixedincome/integration/test_fixedincome_python.py index 98fba043f90..5609a6c04d9 100644 --- a/openbb_platform/extensions/fixedincome/integration/test_fixedincome_python.py +++ b/openbb_platform/extensions/fixedincome/integration/test_fixedincome_python.py @@ -320,7 +320,7 @@ def test_fixedincome_corporate_spot_rates(params, obb): @pytest.mark.parametrize( "params", - [({"date": "2023-01-01", "yield_curve": ["spot"]})], + [({"date": "2023-01-01", "yield_curve": "spot"})], ) @pytest.mark.integration def test_fixedincome_corporate_hqm(params, obb): diff --git a/openbb_platform/extensions/index/integration/test_index_api.py b/openbb_platform/extensions/index/integration/test_index_api.py index ed455197b06..e7b3b5767cd 100644 --- a/openbb_platform/extensions/index/integration/test_index_api.py +++ b/openbb_platform/extensions/index/integration/test_index_api.py @@ -278,28 +278,3 @@ def test_index_sp500_multiples(params, headers): result = requests.get(url, headers=headers, timeout=20) assert isinstance(result, requests.Response) assert result.status_code == 200 - - -@pytest.mark.parametrize( - "params", - [ - ( - { - "symbol": "$GDP", - "start_date": "2023-01-01", - "end_date": "2023-06-06", - "limit": 100, - "provider": "nasdaq", - } - ) - ], -) -@pytest.mark.integration -def test_index_fred(params, headers): - params = {p: v for p, v in params.items() if v} - - query_str = get_querystring(params, []) - url = f"http://0.0.0.0:8000/api/v1/index/fred?{query_str}" - result = requests.get(url, headers=headers, timeout=10) - assert isinstance(result, requests.Response) - assert result.status_code == 200 diff --git a/openbb_platform/extensions/index/integration/test_index_python.py b/openbb_platform/extensions/index/integration/test_index_python.py index 339a999ee10..cb23ce6749c 100644 --- a/openbb_platform/extensions/index/integration/test_index_python.py +++ b/openbb_platform/extensions/index/integration/test_index_python.py @@ -258,25 +258,3 @@ def test_index_sp500_multiples(params, obb): assert result assert isinstance(result, OBBject) assert len(result.results) > 0 - assert len(result.results) > 0 - - -@pytest.mark.parametrize( - "params", - [ - ( - { - "symbol": "$GDP", - "start_date": "2023-01-01", - "end_date": "2023-06-06", - "limit": 100, - } - ), - ], -) -@pytest.mark.integration -def test_index_fred(params, obb): - result = obb.index.fred(**params) - assert result - assert isinstance(result, OBBject) - assert len(result.results) > 0 diff --git a/openbb_platform/extensions/index/openbb_index/index_router.py b/openbb_platform/extensions/index/openbb_index/index_router.py index 83525549744..9f4d8df994a 100644 --- a/openbb_platform/extensions/index/openbb_index/index_router.py +++ b/openbb_platform/extensions/index/openbb_index/index_router.py @@ -37,17 +37,6 @@ async def european( return await OBBject.from_query(Query(**locals())) -@router.command(model="FredIndices") -async def fred( - cc: CommandContext, - provider_choices: ProviderChoices, - standard_params: StandardParams, - extra_params: ExtraParams, -) -> OBBject[BaseModel]: - """Historical Fred Indices. Close values for selected Fred indices.""" - return await OBBject.from_query(Query(**locals())) - - @router.command(model="IndexConstituents") async def constituents( cc: CommandContext, diff --git a/openbb_platform/extensions/news/integration/test_news_api.py b/openbb_platform/extensions/news/integration/test_news_api.py index d4f7e17466b..3aff0a40c0a 100644 --- a/openbb_platform/extensions/news/integration/test_news_api.py +++ b/openbb_platform/extensions/news/integration/test_news_api.py @@ -139,13 +139,6 @@ def test_news_world(params, headers): "source": "bloomberg.com", } ), - ( - { - "provider": "ultima", - "symbols": "AAPL,MSFT", - "limit": 20, - } - ), ], ) @pytest.mark.integration diff --git a/openbb_platform/extensions/news/integration/test_news_python.py b/openbb_platform/extensions/news/integration/test_news_python.py index 97484593c1d..9874f633b77 100644 --- a/openbb_platform/extensions/news/integration/test_news_python.py +++ b/openbb_platform/extensions/news/integration/test_news_python.py @@ -140,13 +140,6 @@ def test_news_world(params, obb): "source": "bloomberg.com", } ), - ( - { - "provider": "ultima", - "symbols": "AAPL,MSFT", - "limit": 20, - } - ), ], ) @pytest.mark.integration diff --git a/openbb_platform/providers/intrinio/tests/record/http/test_intrinio_fetchers/test_intrinio_insider_trading_fetcher.yaml b/openbb_platform/providers/intrinio/tests/record/http/test_intrinio_fetchers/test_intrinio_insider_trading_fetcher.yaml index 5d8dcadd5e6..08bbcc6d9cd 100644 --- a/openbb_platform/providers/intrinio/tests/record/http/test_intrinio_fetchers/test_intrinio_insider_trading_fetcher.yaml +++ b/openbb_platform/providers/intrinio/tests/record/http/test_intrinio_fetchers/test_intrinio_insider_trading_fetcher.yaml @@ -5,7 +5,7 @@ interactions: Accept: - '*/*' Accept-Encoding: - - gzip, deflate, br + - gzip, deflate Connection: - keep-alive method: GET @@ -13,7 +13,7 @@ interactions: response: body: string: !!binary | - H4sIALKaZmUAA+xd21fayh7+V7J4OS+Kc7/wFhWtrYILtLt777UXKxtizSoCJwlWT1f/9zPhVhSS + H4sIAGlVZ2UAA+xd21fayh7+V7J4OS+Kc7/wFhWtrYILtLt777UXKxtizSoCJwlWT1f/9zPhVhSS apxJEOalRXKZMPm+b363mflRiUNvEHndOBgOOjdBPxh8jSq1v39Upp87PS/2K7UKAgjvA7oPxRUU NYxqCFYBAH9V9uYnjsO+Ou82jkdR7eDg+/fv1cjvVr8O7w/csHsb3PvRgd/76oUH6o7eAUYASnyg bgGmHxFOPnNw8BD1TzChXwA5+H6zfzMM70gHMkEIkRARSCFm1Ye7vmo4iKKxH3bioPvND1Xbrnt5 @@ -74,7 +74,7 @@ interactions: Content-Type: - application/json Date: - - Wed, 29 Nov 2023 01:58:10 GMT + - Wed, 29 Nov 2023 15:14:49 GMT Transfer-Encoding: - chunked Vary: diff --git a/openbb_platform/providers/ultima/openbb_ultima/models/company_news.py b/openbb_platform/providers/ultima/openbb_ultima/models/company_news.py index 6377177bd9f..880be92796d 100644 --- a/openbb_platform/providers/ultima/openbb_ultima/models/company_news.py +++ b/openbb_platform/providers/ultima/openbb_ultima/models/company_news.py @@ -27,11 +27,15 @@ class UltimaCompanyNewsQueryParams(CompanyNewsQueryParams): class UltimaCompanyNewsData(CompanyNewsData): """Ultima Company News Data.""" - __alias_dict__ = {"date": "publishedDate", "text": "summary", "title": "headline"} + __alias_dict__ = { + "symbols": "ticker", + "date": "publishedDate", + "text": "summary", + "title": "headline", + } publisher: str = Field(description="Publisher of the news.") - ticker: str = Field(description="Ticker associated with the news.") - riskCategory: str = Field(description="Risk category of the news.") + risk_category: str = Field(description="Risk category of the news.") class UltimaCompanyNewsFetcher( @@ -80,12 +84,13 @@ class UltimaCompanyNewsFetcher( for key in ["8k_filings", "articles", "industry_summary"]: for item in ele[key]: # manual assignment required for Pydantic to work - item["ticker"] = ele["ticker"] + item["symbols"] = ele["ticker"] item["date"] = datetime.strptime( item["publishedDate"], "%Y-%m-%d %H:%M:%S" ) item["title"] = item["headline"] item["url"] = item["url"] item["publisher"] = item["publisher"] + item["risk_category"] = item["riskCategory"] results.append(UltimaCompanyNewsData.model_validate(item)) return results