Files
OpenBB/openbb_platform/extensions/futures/integration/test_futures_api.py
Igor Radovanovic a5d2e833c4 Passing tests (#5560)
* Passing tests

* fix options

* Fix most tests and bugs

* fix forex missing params

* make symbol upper in polygon fx pairs

* fix fixedincome integration tests (#5564)

* Fixing charting api integration tests (#5562)

* fixing charting api integration tests

* black

* fix stocks less five API fails

* fix the 5 failing stocks integration tests

* recapture fmp stock news unit test

* fix fmp forex api test

* couple more forex integration fixes

* changing the request to always use the legacy session. @jmaslek this is was broken for 3.8 and 3.9; with this change apparently all versions work - lemme know if you see any issue with this change

* ruff

* fix ta

* add missing param

* fix testers for the api

* fix globalnews to use images instead of image

* remove unncessary pandas import

* econcal int tests

* update gitignore

* fix get_querystring to support lists

* add missing parameters

---------

Co-authored-by: Danglewood <85772166+deeleeramone@users.noreply.github.com>
Co-authored-by: Henrique Joaquim <h.joaquim@campus.fct.unl.pt>
2023-10-16 12:57:27 +02:00

73 lines
2.0 KiB
Python

import base64
import pytest
import requests
from openbb_core.env import Env
from openbb_provider.utils.helpers import get_querystring
@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",
[
(
{
"symbol": "ES",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
"expiration": "2024-06",
"provider": "yfinance",
}
),
(
{
"interval": "1d",
"period": "max",
"prepost": True,
"adjust": True,
"back_adjust": True,
"provider": "yfinance",
"symbol": "ES",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
"expiration": "2024-06",
}
),
],
)
@pytest.mark.integration
def test_futures_load(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/futures/load?{query_str}"
result = requests.get(url, headers=headers, timeout=10)
assert isinstance(result, requests.Response)
assert result.status_code == 200
@pytest.mark.parametrize(
"params",
[
({"provider": "cboe", "symbol": "VXM", "date": "2023-01-25"}),
({"provider": "yfinance", "symbol": "ES", "date": "2023-08-01"}),
],
)
@pytest.mark.integration
def test_futures_curve(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/futures/curve?{query_str}"
result = requests.get(url, headers=headers, timeout=10)
assert isinstance(result, requests.Response)
assert result.status_code == 200