forked from OpenBB-finance/OpenBB
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up the newly created ETF extension (OpenBB-finance#5611)
* Add ETF to dev_install bundle * Add integration tests for openbb-etf * Patch integration test generator scripts to produce lintable code * Add py.typed markers for extensions
- Loading branch information
Showing
20 changed files
with
119 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
51 changes: 51 additions & 0 deletions
51
openbb_platform/extensions/etf/integration/test_etf_api.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
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')}"} | ||
|
||
|
||
# pylint: disable=redefined-outer-name | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"params", | ||
[({})], | ||
) | ||
@pytest.mark.integration | ||
def test_etf_search(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/etf/search?{query_str}" | ||
result = requests.get(url, headers=headers, timeout=10) | ||
assert isinstance(result, requests.Response) | ||
assert result.status_code == 200 | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"params", | ||
[ | ||
({"symbol": "IOO", "start_date": "2023-01-01", "end_date": "2023-06-06"}), | ||
({"symbol": "MISL", "start_date": "2023-01-01", "end_date": "2023-06-06"}), | ||
], | ||
) | ||
@pytest.mark.integration | ||
def test_etf_historical(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/etf/historical?{query_str}" | ||
result = requests.get(url, headers=headers, timeout=10) | ||
assert isinstance(result, requests.Response) | ||
assert result.status_code == 200 |
49 changes: 49 additions & 0 deletions
49
openbb_platform/extensions/etf/integration/test_etf_python.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
"""Test etf 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", | ||
[ | ||
({}), | ||
], | ||
) | ||
@pytest.mark.integration | ||
def test_etf_search(params, obb): | ||
params = {p: v for p, v in params.items() if v} | ||
|
||
result = obb.etf.search(**params) | ||
assert result | ||
assert isinstance(result, OBBject) | ||
assert len(result.results) > 0 | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"params", | ||
[ | ||
({"symbol": "IOO", "start_date": "2023-01-01", "end_date": "2023-06-06"}), | ||
({"symbol": "MISL", "start_date": "2023-01-01", "end_date": "2023-06-06"}), | ||
], | ||
) | ||
@pytest.mark.integration | ||
def test_etf_historical(params, obb): | ||
params = {p: v for p, v in params.items() if v} | ||
|
||
result = obb.etf.historical(**params) | ||
assert result | ||
assert isinstance(result, OBBject) | ||
assert len(result.results) > 0 |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.