Files
OpenBB/openbb_platform/extensions/economy/integration/test_economy_python.py
Henrique Joaquim d2471a9c4f Hotfix/int tests python fixture (#5504)
* fix command runner tests that were generating logs

* use the import behind a fixture

* updating the generator
2023-10-02 14:43:27 +01:00

360 lines
8.3 KiB
Python

"""Test economy 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",
[
({"index": "dowjones"}),
],
)
@pytest.mark.integration
def test_economy_const(params):
result = obb.economy.const(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@pytest.mark.parametrize(
"params",
[
(
{
"countries": ["portugal", "spain"],
"units": "growth_same",
"frequency": "monthly",
"harmonized": True,
"start_date": "2023-01-01",
"end_date": "2023-06-06",
}
),
],
)
@pytest.mark.integration
def test_economy_cpi(params):
result = obb.economy.cpi(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@pytest.mark.parametrize(
"params",
[
(
{
"symbol": "DJI",
"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",
}
),
(
{
"interval": "1day",
"provider": "fmp",
"symbol": "^DJI",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
}
),
(
{
"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": "5m",
"period": "max",
"prepost": True,
"rounding": True,
"provider": "yfinance",
"symbol": "DJI",
"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",
}
),
],
)
@pytest.mark.integration
def test_economy_index(params):
result = obb.economy.index(**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_economy_european_index(params):
result = obb.economy.european_index(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@pytest.mark.parametrize(
"params",
[
({"symbol": "BUKBUS"}),
],
)
@pytest.mark.integration
def test_economy_european_index_constituents(params):
result = obb.economy.european_index_constituents(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@pytest.mark.parametrize(
"params",
[
({}),
({"europe": True, "provider": "cboe"}),
],
)
@pytest.mark.integration
def test_economy_available_indices(params):
result = obb.economy.available_indices(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@pytest.mark.parametrize(
"params",
[
({}),
],
)
@pytest.mark.integration
def test_economy_risk(params):
result = obb.economy.risk(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@pytest.mark.parametrize(
"params",
[
({"query": "DJ", "symbol": True}),
(
{
"europe": True,
"provider": "cboe",
"query": "AA",
"symbol": True,
}
),
],
)
@pytest.mark.integration
def test_economy_index_search(params):
result = obb.economy.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_economy_index_snapshots(params):
result = obb.economy.index_snapshots(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@pytest.mark.parametrize(
"params",
[
({"query": "grain"}),
],
)
@pytest.mark.integration
def test_economy_cot_search(params):
result = obb.economy.cot_search(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@pytest.mark.parametrize(
"params",
[
({}),
(
{
"code": "13874P",
"data_type": "FO",
"legacy_format": True,
"report_type": "ALL",
"measure": "CR",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
"transform": "diff",
"provider": "quandl",
}
),
],
)
@pytest.mark.integration
def test_economy_cot(params):
result = obb.economy.cot(**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",
}
),
],
)
@pytest.mark.integration
def test_economy_sp500_multiples(params):
result = obb.economy.sp500_multiples(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
assert len(result.results) > 0
@pytest.mark.parametrize(
"params",
[
(
{
"symbol": "AAPL",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
"limit": 100,
}
),
],
)
@pytest.mark.integration
def test_economy_fred_index(params):
result = obb.economy.fred_index(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0