[BugFix] Fix Some Tests (#6736)

* fix test_auto_build

* yfinance integration test params

* treasury auctions param

* remove bad characters from sec litigation rss before parsing

* actually commit it
This commit is contained in:
Danglewood
2024-10-03 15:47:24 -07:00
committed by GitHub
parent b9de848bc3
commit b2209b7e98
6 changed files with 18 additions and 13 deletions

View File

@@ -158,8 +158,8 @@ def test_etf_search(params, headers):
"adjustment": "splits_and_dividends",
"provider": "yfinance",
"symbol": "SPY",
"start_date": "2023-06-01",
"end_date": "2023-06-03",
"start_date": None,
"end_date": None,
"interval": "1h",
}
),

View File

@@ -153,8 +153,8 @@ def test_etf_search(params, obb):
"adjustment": "splits_and_dividends",
"provider": "yfinance",
"symbol": "SPY",
"start_date": "2023-06-01",
"end_date": "2023-06-03",
"start_date": None,
"end_date": None,
"interval": "1h",
}
),

View File

@@ -572,7 +572,7 @@ def test_fixedincome_government_eu_yield_curve(params, headers):
"cusip": None,
"page_size": None,
"page_num": None,
"security_type": "Bond",
"security_type": "bond",
"provider": "government_us",
}
),

View File

@@ -529,7 +529,7 @@ def test_fixedincome_government_eu_yield_curve(params, obb):
"cusip": None,
"page_size": None,
"page_num": None,
"security_type": "Bond",
"security_type": "bond",
"provider": "government_us",
}
),

View File

@@ -52,9 +52,10 @@ class SecRssLitigationFetcher(
) -> List[Dict]:
"""Return the raw data from the SEC endpoint."""
# pylint: disable=import-outside-toplevel
import xmltodict # noqa
from openbb_core.provider.utils.helpers import make_request # noqa
from pandas import DataFrame, to_datetime # noqa
import re # noqa
import xmltodict
from openbb_core.provider.utils.helpers import make_request
from pandas import DataFrame, to_datetime
results: List = []
url = "https://www.sec.gov/enforcement-litigation/litigation-releases/rss"
@@ -63,7 +64,13 @@ class SecRssLitigationFetcher(
if r.status_code != 200:
raise OpenBBError(f"Status code {r.status_code} returned.")
data = xmltodict.parse(r.content)
def clean_xml(xml_content):
"""Clean the XML content before parsing."""
xml_content = re.sub(r"&(?!amp;|lt;|gt;|quot;|apos;)", "&", xml_content)
return xml_content
cleaned_content = clean_xml(r.text)
data = xmltodict.parse(cleaned_content)
cols = ["title", "link", "summary", "date", "id"]
feed = DataFrame.from_records(data["rss"]["channel"]["item"])[
["title", "link", "description", "pubDate", "dc:creator"]

View File

@@ -12,9 +12,7 @@ import pytest
@pytest.fixture(autouse=True)
def setup_mocks():
"""Set up mocks for the test."""
with patch(
"openbb_core.app.static.package_builder.PackageBuilder.auto_build"
) as mock_auto_build:
with patch("openbb._PackageBuilder.auto_build") as mock_auto_build:
mock_auto_build.return_value = None
yield mock_auto_build