Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorWounds committed Oct 31, 2023
1 parent 968ad50 commit 0ce70af
Show file tree
Hide file tree
Showing 6 changed files with 57,014 additions and 6 deletions.
64 changes: 61 additions & 3 deletions openbb_platform/extensions/stocks/integration/test_stocks_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ def test_stocks_info(params, headers):

@pytest.mark.parametrize(
"params",
[({"sort": "desc", "limit": 10, "provider": "wsj"})],
[({"sort": "desc", "provider": "yfinance"})],
)
@pytest.mark.integration
def test_stocks_disc_gainers(params, headers):
Expand All @@ -974,7 +974,7 @@ def test_stocks_disc_gainers(params, headers):

@pytest.mark.parametrize(
"params",
[({"sort": "desc", "limit": 10, "provider": "wsj"})],
[({"sort": "desc", "provider": "yfinance"})],
)
@pytest.mark.integration
def test_stocks_disc_losers(params, headers):
Expand All @@ -989,7 +989,7 @@ def test_stocks_disc_losers(params, headers):

@pytest.mark.parametrize(
"params",
[({"sort": "desc", "limit": 10, "provider": "wsj"})],
[({"sort": "desc", "provider": "yfinance"})],
)
@pytest.mark.integration
def test_stocks_disc_active(params, headers):
Expand All @@ -1000,3 +1000,61 @@ def test_stocks_disc_active(params, headers):
result = requests.get(url, headers=headers, timeout=10)
assert isinstance(result, requests.Response)
assert result.status_code == 200


@pytest.mark.parametrize(
"params",
[
({"symbol": "AAPL", "provider": "sec"}),
({"limit": 24, "provider": "sec", "symbol": "AAPL", "skip_reports": 1}),
],
)
@pytest.mark.integration
def test_stocks_ftd(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/stocks/ftd?{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": "AAPL", "provider": "fmp"})],
)
@pytest.mark.integration
def test_stocks_price_performance(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/stocks/price_performance?{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": "AAPL",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
"limit": 300,
"provider": "intrinio",
}
)
],
)
@pytest.mark.integration
def test_stocks_calendar_ipo(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/stocks/calendar_ipo?{query_str}"
result = requests.get(url, headers=headers, timeout=10)
assert isinstance(result, requests.Response)
assert result.status_code == 200
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ def test_stocks_info(params, obb):

@pytest.mark.parametrize(
"params",
[({"sort": "desc", "limit": 10})],
[({"sort": "desc"})],
)
@pytest.mark.integration
def test_stocks_disc_gainers(params, obb):
Expand All @@ -923,7 +923,7 @@ def test_stocks_disc_gainers(params, obb):

@pytest.mark.parametrize(
"params",
[({"sort": "desc", "limit": 10})],
[({"sort": "desc"})],
)
@pytest.mark.integration
def test_stocks_disc_losers(params, obb):
Expand All @@ -937,7 +937,7 @@ def test_stocks_disc_losers(params, obb):

@pytest.mark.parametrize(
"params",
[({"sort": "desc", "limit": 10})],
[({"sort": "desc"})],
)
@pytest.mark.integration
def test_stocks_disc_active(params, obb):
Expand All @@ -947,3 +947,57 @@ def test_stocks_disc_active(params, obb):
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0


@pytest.mark.parametrize(
"params",
[
({"symbol": "AAPL"}),
({"limit": 24, "provider": "sec", "symbol": "AAPL", "skip_reports": 1}),
],
)
@pytest.mark.integration
def test_stocks_ftd(params, obb):
params = {p: v for p, v in params.items() if v}

result = obb.stocks.ftd(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0


@pytest.mark.parametrize(
"params",
[({"symbol": "AAPL"})],
)
@pytest.mark.integration
def test_stocks_price_performance(params, obb):
params = {p: v for p, v in params.items() if v}

result = obb.stocks.price_performance(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0


@pytest.mark.parametrize(
"params",
[
(
{
"symbol": "AAPL",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
"limit": 300,
}
)
],
)
@pytest.mark.integration
def test_stocks_calendar_ipo(params, obb):
params = {p: v for p, v in params.items() if v}

result = obb.stocks.calendar_ipo(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0
Loading

0 comments on commit 0ce70af

Please sign in to comment.