mirror of
https://github.com/OpenBB-finance/OpenBB.git
synced 2026-10-28 04:52:07 +00:00
* add commodity extension and add lbma fixing endpoint * dev_install.py * readme url * renovate the standard model * makes a query_params model for nasdaq data link * literal not optional * unused imports * missing test params * test cassette * DataLink query param description * test file import * actually fix import * from openbb_core.provider..... * ruff * another import statement * black * async router * move query_params * update version * version numbers * extension_map * satisfy pylint? * pylint * Update pyproject.toml * black * poetry lock * Update extension_map.json * Update __extensions__.py * Update module_map.json * clean descriptions --------- Co-authored-by: Pratyush Shukla <ps4534@nyu.edu>
56 lines
1.5 KiB
Python
56 lines
1.5 KiB
Python
"""Test Commodity API endpoints."""
|
|
|
|
import base64
|
|
|
|
import pytest
|
|
import requests
|
|
from openbb_core.env import Env
|
|
from openbb_core.provider.utils.helpers import get_querystring
|
|
|
|
# pylint: disable=redefined-outer-name
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def headers():
|
|
userpass = f"{Env().API_USERNAME}:{Env().API_PASSWORD}"
|
|
userpass_bytes = userpass.encode("ascii")
|
|
base64_bytes = base64.b64encode(userpass_bytes)
|
|
|
|
return {"Authorization": f"Basic {base64_bytes.decode('ascii')}"}
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"params",
|
|
[
|
|
(
|
|
{
|
|
"asset": "gold",
|
|
"start_date": None,
|
|
"end_date": None,
|
|
"collapse": None,
|
|
"transform": None,
|
|
"provider": "nasdaq",
|
|
}
|
|
),
|
|
(
|
|
{
|
|
"asset": "silver",
|
|
"start_date": "1990-01-01",
|
|
"end_date": "2023-01-01",
|
|
"collapse": "monthly",
|
|
"transform": "diff",
|
|
"provider": "nasdaq",
|
|
}
|
|
),
|
|
],
|
|
)
|
|
@pytest.mark.integration
|
|
def test_commodity_lbma_fixing(params, headers):
|
|
params = {p: v for p, v in params.items() if v}
|
|
|
|
query_str = get_querystring(params, [])
|
|
url = f"http://0.0.0.0:8000/api/v1/commodity/lbma_fixing?{query_str}"
|
|
result = requests.get(url, headers=headers, timeout=10)
|
|
assert isinstance(result, requests.Response)
|
|
assert result.status_code == 200
|