Files
OpenBB/openbb_platform/providers/sec/integration/test_sec_python.py
Danglewood dc4b26030f [V5] openbb-sec: Refactor for V5 (#7525)
* refactor openbb-sec for v5

* linting

* ty

* normalize compare_company_facts

* add workflows

* python 3.10 fix

* add more thorough url validation and tests

* ty check

* ty for python 3.10

* reconfigure with apps

* temp pyproject overrride

* pyproject

* pyproject

* pyproject

* codespell

* pyproject

* fix uk schema file links in schema_files

* test coverage

* test_cli

* port #7547 into this pr

* no hard coded prefix

* improve filing rendering capabilities

* fix xml text detection

* make codeql happy

* missed a file in the commit

* test coverage

* codespell

* fix flakey test

* some updates

* management_ownership --> management_profiles

* proxy statement markdown

* ruff

* fix test coverage

* more tests

* test coverage

* fix lint errors

* Add SEC adviser search, profile, and universe routes (#7559)

* Add SEC institutional data fetchers

* Add SEC filing index and Form D routes

* Add SEC investment adviser people data

* Expose SEC adviser and institutional routes

* fix(sec): address adviser review feedback

* refactor(sec): narrow adviser support to IAPD search

* feat(sec): add adviser firm and individual searches

* feat(sec): add adviser profile drill-down

* fix: repair pre-commit configuration

* feat(sec): add adviser universe route

* feat(sec): expose complete Form ADV data

---------

Co-authored-by: Danglewood <85772166+deeleeramone@users.noreply.github.com>

* fix test coverage

---------

Co-authored-by: deeleeramone <>
Co-authored-by: Theodore Aptekarev <aptekarev@gmail.com>
2026-09-24 08:47:49 -07:00

384 lines
9.4 KiB
Python

"""Test SEC extension."""
import pytest
from openbb_core.app.model.obbject import OBBject
@pytest.fixture(scope="session")
def obb(pytestconfig):
"""Fixture to setup obb."""
if pytestconfig.getoption("markexpr") != "not integration":
import openbb
return openbb.obb
@pytest.mark.parametrize(
"params",
[
({"symbol": "TSLA", "provider": "sec", "use_cache": True}),
({"symbol": "SQQQ", "provider": "sec", "use_cache": True}),
],
)
@pytest.mark.integration
def test_sec_cik_map(params, obb):
"""Test the SEC CIK map endpoint."""
result = obb.sec.cik_map(**params)
assert result
assert isinstance(result, OBBject)
assert hasattr(result.results, "cik")
assert isinstance(result.results.cik, str)
@pytest.mark.parametrize(
"params",
[
({"query": "berkshire hathaway", "provider": "sec", "use_cache": True}),
],
)
@pytest.mark.integration
def test_sec_institutions_search(params, obb):
"""Test the SEC institutions search endpoint."""
result = obb.sec.institutions_search(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@pytest.mark.parametrize(
"params",
[
({"provider": "sec"}),
(
{
"provider": "sec",
"taxonomy": "us-gaap",
"year": 2024,
"component": "soi",
}
),
],
)
@pytest.mark.integration
def test_sec_schema_files(params, obb):
"""Test the SEC schema files endpoint."""
result = obb.sec.schema_files(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@pytest.mark.parametrize(
"params",
[
({"query": "0000909832", "provider": "sec", "use_cache": True}),
({"query": "0001067983", "provider": "sec", "use_cache": True}),
],
)
@pytest.mark.integration
def test_sec_symbol_map(params, obb):
"""Test the SEC symbol map endpoint."""
result = obb.sec.symbol_map(**params)
assert result
assert isinstance(result, OBBject)
assert hasattr(result.results, "symbol")
assert isinstance(result.results.symbol, str)
@pytest.mark.parametrize(
"params",
[{"provider": "sec"}],
)
@pytest.mark.integration
def test_sec_rss_litigation(params, obb):
"""Test the SEC RSS litigation endpoint."""
result = obb.sec.rss_litigation(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@pytest.mark.parametrize(
"params",
[{"query": "oil", "use_cache": False, "provider": "sec"}],
)
@pytest.mark.integration
def test_sec_sic_search(params, obb):
"""Test the SEC SIC search endpoint."""
result = obb.sec.sic_search(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@pytest.mark.parametrize(
"params",
[
(
{
"url": "https://www.sec.gov/Archives/edgar/data/21344/000155278124000634/",
"provider": "sec",
"use_cache": True,
}
),
],
)
@pytest.mark.integration
def test_sec_filing_headers(params, obb):
"""Test the SEC Filing Headers endpoint."""
from openbb_sec.models.sec_filing import SecFilingData
result = obb.sec.filing_headers(**params)
assert result
assert isinstance(result, OBBject)
assert isinstance(result.results, SecFilingData)
assert hasattr(result.results, "cover_page")
@pytest.mark.parametrize(
"params",
[
(
{
"url": "https://www.sec.gov/Archives/edgar/data/1990353/000110465925015513/tm256977d7_ex99-1.htm",
"provider": "sec",
"use_cache": True,
}
),
],
)
@pytest.mark.integration
def test_sec_htm_file(params, obb):
"""Test the SEC HTM File endpoint."""
from openbb_sec.models.htm_file import SecHtmFileData
result = obb.sec.htm_file(**params)
assert result
assert isinstance(result, OBBject)
assert isinstance(result.results, SecHtmFileData)
assert hasattr(result.results, "content")
@pytest.mark.parametrize(
"params",
[
(
{
"symbol": "AAPL",
"calendar_year": 2023,
"provider": "sec",
"use_cache": True,
}
),
],
)
@pytest.mark.integration
def test_sec_disclosures(params, obb):
"""Test the SEC disclosures endpoint."""
result = obb.sec.disclosures(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@pytest.mark.parametrize(
"params",
[
(
{
"symbol": "AAPL",
"calendar_year": 2023,
"provider": "sec",
"use_cache": True,
}
),
],
)
@pytest.mark.integration
def test_sec_risk_factors(params, obb):
"""Test the SEC risk factors endpoint."""
result = obb.sec.risk_factors(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@pytest.mark.parametrize(
"params",
[
(
{
"symbol": "AAPL",
"calendar_year": 2023,
"provider": "sec",
"use_cache": True,
}
),
],
)
@pytest.mark.integration
def test_sec_company_overview(params, obb):
"""Test the SEC company overview endpoint."""
result = obb.sec.company_overview(**params)
assert result
assert isinstance(result, OBBject)
assert result.results.content
@pytest.mark.parametrize(
"params",
[
(
{
"symbol": "AAPL",
"calendar_year": 2023,
"statement_type": "balance",
"provider": "sec",
"use_cache": True,
}
),
],
)
@pytest.mark.integration
def test_sec_financial_statements(params, obb):
"""Test the SEC as-filed financial statements endpoint."""
result = obb.sec.financial_statements(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@pytest.mark.parametrize(
"params",
[
(
{
"symbol": "AAPL",
"calendar_year": 2023,
"provider": "sec",
"use_cache": True,
}
),
],
)
@pytest.mark.integration
def test_sec_segment_revenue(params, obb):
"""Test the SEC segment and geographic revenue endpoint."""
result = obb.sec.segment_revenue(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@pytest.mark.parametrize(
"params",
[
(
{
"symbol": "AAPL",
"calendar_year": 2023,
"provider": "sec",
"use_cache": True,
}
),
],
)
@pytest.mark.integration
def test_sec_legal_proceedings(params, obb):
"""Test the SEC legal proceedings endpoint."""
result = obb.sec.legal_proceedings(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@pytest.mark.parametrize(
"params",
[
({"query": "climate change", "form_type": "8-K", "provider": "sec"}),
],
)
@pytest.mark.integration
def test_sec_full_text_search(params, obb):
"""Test the SEC full-text search endpoint."""
result = obb.sec.full_text_search(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@pytest.mark.parametrize(
"params",
[
({"symbol": "XLK", "provider": "sec"}),
],
)
@pytest.mark.integration
def test_sec_nport_fund_metrics(params, obb):
"""Test the SEC NPORT fund metrics endpoint."""
result = obb.sec.nport_fund_metrics(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@pytest.mark.parametrize(
"params",
[
({"symbol": "CAT", "calendar_year": 2024, "provider": "sec"}),
],
)
@pytest.mark.integration
def test_sec_beneficial_ownership(params, obb):
"""Test the SEC beneficial ownership endpoint."""
result = obb.sec.beneficial_ownership(**params)
assert result
assert isinstance(result, OBBject)
assert result.results.content
@pytest.mark.parametrize(
"params",
[
({"symbol": "CAT", "calendar_year": 2024, "provider": "sec"}),
],
)
@pytest.mark.integration
def test_sec_management_profiles(params, obb):
"""Test the SEC management profiles endpoint."""
result = obb.sec.management_profiles(**params)
assert result
assert isinstance(result, OBBject)
assert result.results.content
@pytest.mark.parametrize(
"params",
[
({"symbol": "CAT", "calendar_year": 2024, "provider": "sec"}),
],
)
@pytest.mark.integration
def test_sec_executive_compensation(params, obb):
"""Test the SEC executive compensation endpoint."""
result = obb.sec.executive_compensation(**params)
assert result
assert isinstance(result, OBBject)
assert result.results.content
@pytest.mark.parametrize(
"params",
[
({"symbol": "CAT", "calendar_year": 2024, "provider": "sec"}),
],
)
@pytest.mark.integration
def test_sec_pay_versus_performance(params, obb):
"""Test the SEC pay versus performance endpoint."""
result = obb.sec.pay_versus_performance(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0