Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BugFix] Fix Tests & Related Bugs #6657

Merged
merged 8 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ def test_equity_ownership_institutional(params, headers):
[
(
{
"symbol": "",
"symbol": None,
"start_date": "2023-01-01",
"end_date": "2023-06-06",
"limit": 100,
Expand Down Expand Up @@ -1131,8 +1131,8 @@ def test_equity_compare_groups(params, headers):
"adjustment": "splits_only",
"provider": "yfinance",
"symbol": "AAPL",
"start_date": "2023-06-01",
deeleeramone marked this conversation as resolved.
Show resolved Hide resolved
"end_date": "2023-06-03",
"start_date": None,
"end_date": None,
"interval": "1h",
}
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ def test_equity_ownership_institutional(params, obb):
[
(
{
"symbol": "",
"symbol": None,
"start_date": "2023-01-01",
"end_date": "2023-06-06",
"limit": 100,
Expand Down Expand Up @@ -1078,8 +1078,8 @@ def test_equity_compare_groups(params, obb):
"adjustment": "splits_and_dividends",
"provider": "yfinance",
"symbol": "AAPL",
"start_date": "2023-06-01",
deeleeramone marked this conversation as resolved.
Show resolved Hide resolved
"end_date": "2023-06-03",
"start_date": None,
"end_date": None,
"interval": "1h",
}
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def test_regulators_cftc_cot_search(params, headers):
[
(
{
"id": "13874P",
"id": "045601",
"data_type": "FO",
"legacy_format": True,
"report_type": "ALL",
Expand All @@ -174,7 +174,7 @@ def test_regulators_cftc_cot_search(params, headers):
),
(
{
"id": "13874P",
"id": "045601",
"report_type": "legacy",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def test_regulators_cftc_cot_search(params, obb):
[
(
{
"id": "13874P",
"id": "045601",
"data_type": "FO",
"legacy_format": True,
"report_type": "ALL",
Expand All @@ -159,7 +159,7 @@ def test_regulators_cftc_cot_search(params, obb):
),
(
{
"id": "13874P",
"id": "045601",
"report_type": "legacy",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,32 @@ def toggle_chart_style(self):
external=True
).to_plotly_json()

@staticmethod
def _convert_to_string(x):
"""Sanitize the data for the table."""
# pylint: disable=import-outside-toplevel
from numpy import isnan

if isinstance(x, (float, int)) and not isnan(x):
return x
if isinstance(x, dict):
return ", ".join([str(v) for v in x.values()])
if isinstance(x, list):
if all(isinstance(i, dict) for i in x):
return ", ".join(
str(", ".join([str(v) for v in i.values()])) for i in x
)
return ", ".join([str(i) for i in x])

return (
str(x)
.replace("[", "")
.replace("]", "")
.replace("'{", "")
.replace("}'", "")
.replace("nan", "")
)

def table(
self,
data: Optional[Union["DataFrame", "Series"]] = None,
Expand All @@ -569,6 +595,8 @@ def table(
data_as_df.reset_index(inplace=True, drop=True)
else:
data_as_df.reset_index(inplace=True)
for col in data_as_df.columns:
data_as_df[col] = data_as_df[col].apply(self._convert_to_string)
if self._backend.isatty:
try:
self._backend.send_table(
Expand Down
2 changes: 1 addition & 1 deletion openbb_platform/providers/bls/tests/test_bls_fetchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from datetime import date

import pytest
from openbb_bls.models.series import BlsSeriesFetcher
from openbb_bls.models.search import BlsSearchFetcher
from openbb_bls.models.series import BlsSeriesFetcher
from openbb_core.app.service.user_service import UserService

test_credentials = UserService().default_user_settings.credentials.model_dump(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ interactions:
Content-Type:
- application/json;charset=utf-8
Date:
- Tue, 27 Aug 2024 06:28:40 GMT
Etag:
- '"aG90ZWwuNTEzMDVfM18yODJtVzlSN0o5WVlrTFhDbnYyakxHb3Z1NTJCcHc---gzipn8hfNknVynA7XV4li5cBTkJ7u_Q--gzip--gzip"'
- Thu, 05 Sep 2024 18:51:48 GMT
Etag: null
Last-Modified:
- Fri, 23 Aug 2024 19:30:46 GMT
- Fri, 30 Aug 2024 19:30:46 GMT
Server:
- nginx
Strict-Transport-Security:
Expand All @@ -61,15 +60,13 @@ interactions:
X-SODA2-Fields:
- '["id","market_and_exchange_names","report_date_as_yyyy_mm_dd","yyyy_report_week_ww","contract_market_name","cftc_contract_market_code","cftc_market_code","cftc_region_code","cftc_commodity_code","commodity_name","open_interest_all","noncomm_positions_long_all","noncomm_positions_short_all","noncomm_postions_spread_all","comm_positions_long_all","comm_positions_short_all","tot_rept_positions_long_all","tot_rept_positions_short","nonrept_positions_long_all","nonrept_positions_short_all","open_interest_old","noncomm_positions_long_old","noncomm_positions_short_old","noncomm_positions_spread","comm_positions_long_old","comm_positions_short_old","tot_rept_positions_long_old","tot_rept_positions_short_1","nonrept_positions_long_old","nonrept_positions_short_old","open_interest_other","noncomm_positions_long_other","noncomm_positions_short_other","noncomm_positions_spread_1","comm_positions_long_other","comm_positions_short_other","tot_rept_positions_long_other","tot_rept_positions_short_2","nonrept_positions_long_other","nonrept_positions_short_other","change_in_open_interest_all","change_in_noncomm_long_all","change_in_noncomm_short_all","change_in_noncomm_spead_all","change_in_comm_long_all","change_in_comm_short_all","change_in_tot_rept_long_all","change_in_tot_rept_short","change_in_nonrept_long_all","change_in_nonrept_short_all","pct_of_open_interest_all","pct_of_oi_noncomm_long_all","pct_of_oi_noncomm_short_all","pct_of_oi_noncomm_spread","pct_of_oi_comm_long_all","pct_of_oi_comm_short_all","pct_of_oi_tot_rept_long_all","pct_of_oi_tot_rept_short","pct_of_oi_nonrept_long_all","pct_of_oi_nonrept_short_all","pct_of_open_interest_old","pct_of_oi_noncomm_long_old","pct_of_oi_noncomm_short_old","pct_of_oi_noncomm_spread_1","pct_of_oi_comm_long_old","pct_of_oi_comm_short_old","pct_of_oi_tot_rept_long_old","pct_of_oi_tot_rept_short_1","pct_of_oi_nonrept_long_old","pct_of_oi_nonrept_short_old","pct_of_open_interest_other","pct_of_oi_noncomm_long_other","pct_of_oi_noncomm_short_other","pct_of_oi_noncomm_spread_2","pct_of_oi_comm_long_other","pct_of_oi_comm_short_other","pct_of_oi_tot_rept_long_other","pct_of_oi_tot_rept_short_2","pct_of_oi_nonrept_long_other","pct_of_oi_nonrept_short_other","traders_tot_all","traders_noncomm_long_all","traders_noncomm_short_all","traders_noncomm_spread_all","traders_comm_long_all","traders_comm_short_all","traders_tot_rept_long_all","traders_tot_rept_short_all","traders_tot_old","traders_noncomm_long_old","traders_noncomm_short_old","traders_noncomm_spead_old","traders_comm_long_old","traders_comm_short_old","traders_tot_rept_long_old","traders_tot_rept_short_old","traders_tot_other","traders_noncomm_long_other","traders_noncomm_short_other","traders_noncomm_spread_other","traders_comm_long_other","traders_comm_short_other","traders_tot_rept_long_other","traders_tot_rept_short_other","conc_gross_le_4_tdr_long","conc_gross_le_4_tdr_short","conc_gross_le_8_tdr_long","conc_gross_le_8_tdr_short","conc_net_le_4_tdr_long_all","conc_net_le_4_tdr_short_all","conc_net_le_8_tdr_long_all","conc_net_le_8_tdr_short_all","conc_gross_le_4_tdr_long_1","conc_gross_le_4_tdr_short_1","conc_gross_le_8_tdr_long_1","conc_gross_le_8_tdr_short_1","conc_net_le_4_tdr_long_old","conc_net_le_4_tdr_short_old","conc_net_le_8_tdr_long_old","conc_net_le_8_tdr_short_old","conc_gross_le_4_tdr_long_2","conc_gross_le_4_tdr_short_2","conc_gross_le_8_tdr_long_2","conc_gross_le_8_tdr_short_2","conc_net_le_4_tdr_long_other","conc_net_le_4_tdr_short_other","conc_net_le_8_tdr_long_other","conc_net_le_8_tdr_short_other","contract_units","commodity","commodity_subgroup_name","commodity_group_name","futonly_or_combined"]'
X-SODA2-Secondary-Last-Modified:
- Fri, 23 Aug 2024 19:30:46 GMT
- Fri, 30 Aug 2024 19:30:46 GMT
X-SODA2-Truth-Last-Modified:
- Fri, 23 Aug 2024 19:30:46 GMT
- Fri, 30 Aug 2024 19:30:46 GMT
X-SODA2-Types:
- '["text","text","floating_timestamp","text","text","text","text","text","text","text","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","text","text","text","text","text"]'
X-Socrata-Region:
- aws-us-east-1-fedramp-prod
X-Socrata-RequestId:
- 0abb185a1eec56a4fa1748718eb9ef7d
X-Socrata-Region: null
X-Socrata-RequestId: null
status:
code: 200
message: OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ interactions:
Content-Type:
- application/json;charset=utf-8
Date:
- Tue, 27 Aug 2024 06:27:59 GMT
Etag:
- '"aG90ZWwuNTEzMDVfM18yODJtVzlSN0o5WVlrTFhDbnYyakxHb3Z1NTJCcHc---gzipn8hfNknVynA7XV4li5cBTkJ7u_Q--gzip--gzip"'
- Thu, 05 Sep 2024 18:48:26 GMT
Etag: null
Last-Modified:
- Fri, 23 Aug 2024 19:30:46 GMT
- Fri, 30 Aug 2024 19:30:46 GMT
Server:
- nginx
Strict-Transport-Security:
Expand All @@ -61,15 +60,13 @@ interactions:
X-SODA2-Fields:
- '["id","market_and_exchange_names","report_date_as_yyyy_mm_dd","yyyy_report_week_ww","contract_market_name","cftc_contract_market_code","cftc_market_code","cftc_region_code","cftc_commodity_code","commodity_name","open_interest_all","noncomm_positions_long_all","noncomm_positions_short_all","noncomm_postions_spread_all","comm_positions_long_all","comm_positions_short_all","tot_rept_positions_long_all","tot_rept_positions_short","nonrept_positions_long_all","nonrept_positions_short_all","open_interest_old","noncomm_positions_long_old","noncomm_positions_short_old","noncomm_positions_spread","comm_positions_long_old","comm_positions_short_old","tot_rept_positions_long_old","tot_rept_positions_short_1","nonrept_positions_long_old","nonrept_positions_short_old","open_interest_other","noncomm_positions_long_other","noncomm_positions_short_other","noncomm_positions_spread_1","comm_positions_long_other","comm_positions_short_other","tot_rept_positions_long_other","tot_rept_positions_short_2","nonrept_positions_long_other","nonrept_positions_short_other","change_in_open_interest_all","change_in_noncomm_long_all","change_in_noncomm_short_all","change_in_noncomm_spead_all","change_in_comm_long_all","change_in_comm_short_all","change_in_tot_rept_long_all","change_in_tot_rept_short","change_in_nonrept_long_all","change_in_nonrept_short_all","pct_of_open_interest_all","pct_of_oi_noncomm_long_all","pct_of_oi_noncomm_short_all","pct_of_oi_noncomm_spread","pct_of_oi_comm_long_all","pct_of_oi_comm_short_all","pct_of_oi_tot_rept_long_all","pct_of_oi_tot_rept_short","pct_of_oi_nonrept_long_all","pct_of_oi_nonrept_short_all","pct_of_open_interest_old","pct_of_oi_noncomm_long_old","pct_of_oi_noncomm_short_old","pct_of_oi_noncomm_spread_1","pct_of_oi_comm_long_old","pct_of_oi_comm_short_old","pct_of_oi_tot_rept_long_old","pct_of_oi_tot_rept_short_1","pct_of_oi_nonrept_long_old","pct_of_oi_nonrept_short_old","pct_of_open_interest_other","pct_of_oi_noncomm_long_other","pct_of_oi_noncomm_short_other","pct_of_oi_noncomm_spread_2","pct_of_oi_comm_long_other","pct_of_oi_comm_short_other","pct_of_oi_tot_rept_long_other","pct_of_oi_tot_rept_short_2","pct_of_oi_nonrept_long_other","pct_of_oi_nonrept_short_other","traders_tot_all","traders_noncomm_long_all","traders_noncomm_short_all","traders_noncomm_spread_all","traders_comm_long_all","traders_comm_short_all","traders_tot_rept_long_all","traders_tot_rept_short_all","traders_tot_old","traders_noncomm_long_old","traders_noncomm_short_old","traders_noncomm_spead_old","traders_comm_long_old","traders_comm_short_old","traders_tot_rept_long_old","traders_tot_rept_short_old","traders_tot_other","traders_noncomm_long_other","traders_noncomm_short_other","traders_noncomm_spread_other","traders_comm_long_other","traders_comm_short_other","traders_tot_rept_long_other","traders_tot_rept_short_other","conc_gross_le_4_tdr_long","conc_gross_le_4_tdr_short","conc_gross_le_8_tdr_long","conc_gross_le_8_tdr_short","conc_net_le_4_tdr_long_all","conc_net_le_4_tdr_short_all","conc_net_le_8_tdr_long_all","conc_net_le_8_tdr_short_all","conc_gross_le_4_tdr_long_1","conc_gross_le_4_tdr_short_1","conc_gross_le_8_tdr_long_1","conc_gross_le_8_tdr_short_1","conc_net_le_4_tdr_long_old","conc_net_le_4_tdr_short_old","conc_net_le_8_tdr_long_old","conc_net_le_8_tdr_short_old","conc_gross_le_4_tdr_long_2","conc_gross_le_4_tdr_short_2","conc_gross_le_8_tdr_long_2","conc_gross_le_8_tdr_short_2","conc_net_le_4_tdr_long_other","conc_net_le_4_tdr_short_other","conc_net_le_8_tdr_long_other","conc_net_le_8_tdr_short_other","contract_units","commodity","commodity_subgroup_name","commodity_group_name","futonly_or_combined"]'
X-SODA2-Secondary-Last-Modified:
- Fri, 23 Aug 2024 19:30:46 GMT
- Fri, 30 Aug 2024 19:30:46 GMT
X-SODA2-Truth-Last-Modified:
- Fri, 23 Aug 2024 19:30:46 GMT
- Fri, 30 Aug 2024 19:30:46 GMT
X-SODA2-Types:
- '["text","text","floating_timestamp","text","text","text","text","text","text","text","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","number","text","text","text","text","text"]'
X-Socrata-Region:
- aws-us-east-1-fedramp-prod
X-Socrata-RequestId:
- 4223a5a28d93ad5780819953fa087052
X-Socrata-Region: null
X-Socrata-RequestId: null
status:
code: 200
message: OK
Expand Down
15 changes: 15 additions & 0 deletions openbb_platform/providers/cftc/tests/test_cftc_fetchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@
)


def scrub_string(key):
"""Scrub a string from the response."""

def before_record_response(response):
response["headers"][key] = response["headers"].update({key: "MOCK_VALUE"})
return response

return before_record_response


@pytest.fixture(scope="module")
def vcr_config():
"""VCR configuration."""
Expand All @@ -23,6 +33,11 @@ def vcr_config():
("$order", "MOCK_ORDER"),
("$where", "MOCK_WHERE"),
],
"before_record_response": [
scrub_string("Etag"),
scrub_string("X-Socrata-RequestId"),
scrub_string("X-Socrata-Region"),
],
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
"""Intrinio IPO Calendar Model."""

# pylint: disable=unused-argument

from typing import Any, Dict, List, Literal, Optional

from openbb_core.provider.abstract.fetcher import Fetcher
from openbb_core.provider.standard_models.calendar_ipo import (
CalendarIpoData,
CalendarIpoQueryParams,
)
from openbb_core.provider.utils.errors import EmptyDataError
from openbb_core.provider.utils.helpers import get_querystring
from openbb_intrinio.utils.helpers import get_data_one
from openbb_intrinio.utils.references import IntrinioCompany, IntrinioSecurity
Expand Down Expand Up @@ -185,4 +188,6 @@ def transform_data(
query: IntrinioCalendarIpoQueryParams, data: List[Dict], **kwargs: Any
) -> List[IntrinioCalendarIpoData]:
"""Return the transformed data."""
if not data:
raise EmptyDataError("The request was returned empty.")
return [IntrinioCalendarIpoData.model_validate(d) for d in data]
Loading
Loading