Files
OpenBB/openbb_platform/extensions/index/integration/test_index_python.py
Henrique Joaquim 6e3038b9e7 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 <ps4534@nyu.edu>
2023-11-29 18:35:45 +00:00

261 lines
6.3 KiB
Python

"""Test economy extension."""
import pytest
from openbb_core.app.model.obbject import OBBject
@pytest.fixture(scope="session")
def obb(pytestconfig): # pylint: disable=inconsistent-return-statements
"""Fixture to setup obb."""
if pytestconfig.getoption("markexpr") != "not integration":
import openbb # pylint: disable=import-outside-toplevel
return openbb.obb
# pylint: disable=redefined-outer-name
@pytest.mark.parametrize(
"params",
[
({"index": "dowjones"}),
],
)
@pytest.mark.integration
def test_index_constituents(params, obb):
result = obb.index.constituents(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@pytest.mark.parametrize(
"params",
[
(
{
"symbol": "AAVE100",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
}
),
(
{
"interval": "1m",
"provider": "cboe",
"symbol": "AAVE100",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
}
),
(
{
"interval": "1d",
"provider": "cboe",
"symbol": "AAVE100",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
}
),
(
{
"interval": "1min",
"provider": "fmp",
"symbol": "^DJI",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
"timeseries": 1,
}
),
(
{
"interval": "1day",
"provider": "fmp",
"symbol": "^DJI",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
"timeseries": 1,
}
),
(
{
"timespan": "minute",
"sort": "desc",
"limit": 49999,
"adjusted": True,
"multiplier": 1,
"provider": "polygon",
"symbol": "NDX",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
}
),
(
{
"timespan": "day",
"sort": "desc",
"limit": 49999,
"adjusted": True,
"multiplier": 1,
"provider": "polygon",
"symbol": "NDX",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
}
),
(
{
"interval": "1d",
"period": "max",
"prepost": True,
"rounding": True,
"provider": "yfinance",
"symbol": "DJI",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
}
),
(
{
"provider": "intrinio",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
"symbol": "$DJI",
"tag": "level",
"sort": "desc",
"limit": 100,
"type": None,
}
),
],
)
@pytest.mark.integration
def test_index_market(params, obb):
result = obb.index.market(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@pytest.mark.parametrize(
"params",
[
(
{
"symbol": "BUKBUS",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
}
),
(
{
"interval": "1m",
"provider": "cboe",
"symbol": "BUKBUS",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
}
),
(
{
"interval": "1d",
"provider": "cboe",
"symbol": "BUKBUS",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
}
),
],
)
@pytest.mark.integration
def test_index_european(params, obb):
result = obb.index.european(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@pytest.mark.parametrize(
"params",
[
({"symbol": "BUKBUS"}),
],
)
@pytest.mark.integration
def test_index_european_constituents(params, obb):
result = obb.index.european_constituents(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@pytest.mark.parametrize(
"params",
[
({}),
({"europe": True, "provider": "cboe"}),
({"provider": "fmp"}),
({"provider": "yfinance"}),
],
)
@pytest.mark.integration
def test_index_available(params, obb):
result = obb.index.available(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@pytest.mark.parametrize(
"params",
[
({"query": "D", "is_symbol": True}),
({"europe": True, "provider": "cboe", "query": "A", "is_symbol": False}),
],
)
@pytest.mark.integration
def test_index_search(params, obb):
result = obb.index.search(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@pytest.mark.parametrize(
"params",
[
({"region": "US"}),
],
)
@pytest.mark.integration
def test_index_snapshots(params, obb):
result = obb.index.snapshots(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@pytest.mark.parametrize(
"params",
[
(
{
"series_name": "PE Ratio by Month",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
"collapse": "monthly",
"transform": "diff",
"provider": "nasdaq",
}
),
],
)
@pytest.mark.integration
def test_index_sp500_multiples(params, obb):
result = obb.index.sp500_multiples(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0