File size: 2,654 Bytes
a2afe2f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
"""Test Commodity extension."""
import pytest
from openbb_core.app.model.obbject import OBBject
# pylint: disable=redefined-outer-name
@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
@pytest.mark.parametrize(
"params",
[
(
{
"commodity": "all",
"start_date": None,
"end_date": None,
"frequency": None,
"transform": None,
"aggregation_method": None,
"provider": "fred",
}
),
],
)
@pytest.mark.integration
def test_commodity_price_spot(params, obb):
"""Test the commodity spot prices endpoint."""
params = {p: v for p, v in params.items() if v}
result = obb.commodity.price.spot(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@pytest.mark.parametrize(
"params",
[
(
{
"category": "balance_sheet",
"table": "stocks",
"start_date": None,
"end_date": None,
"provider": "eia",
"use_cache": True,
}
),
(
{
"category": "weekly_estimates",
"table": "crude_production",
"start_date": "2020-01-01",
"end_date": "2023-12-31",
"provider": "eia",
"use_cache": True,
}
),
],
)
@pytest.mark.integration
def test_commodity_petroleum_status_report(params, obb):
"""Test Commodity Petroleum Status Report endpoint."""
result = obb.commodity.petroleum_status_report(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
@pytest.mark.parametrize(
"params",
[
(
{
"table": "01",
"symbol": None,
"start_date": "2024-09-01",
"end_date": "2024-10-01",
"provider": "eia",
"frequency": "month",
}
),
],
)
@pytest.mark.integration
def test_commodity_short_term_energy_outlook(params, obb):
"""Test Commodity Short Term Energy Outlook endpoint."""
result = obb.commodity.short_term_energy_outlook(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
|