Files
OpenBB/openbb_platform/extensions/news/integration/test_news_python.py
Henrique Joaquim 4400cd9a8f Merge provider and core into core (#5774)
* small changes - moving provider inside the core

* uptade readme

* lint

* remove old provider readme

* leftovers

* refactor website examples

* ruff

* fix nox

* relock

* fix fails_to_deliver headers

* fix for tests that have renamed endpoints

* fix discovery

* removed test for renamed endpoint

* fix broken syntax - test_search_financial_attributes

* fix cash/income/balance

* fix derivatives tests

* fix etf tests

* fix news tests

* fix regulators

* black

* wrong test param

* sort equity gainers/losers by percent

* platform markdown generation import

* Hotfix/fix int tests core merge (#5779)

* removing tests on old endpoint

* removing visualization on old endpoint

* fixing equity tests

* fixing examples

* fix news tests

* fix index test

* example

* add comments

* example

---------

Co-authored-by: Diogo Sousa <montezdesousa@gmail.com>

---------

Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com>
Co-authored-by: Diogo Sousa <montezdesousa@gmail.com>
Co-authored-by: Danglewood <85772166+deeleeramone@users.noreply.github.com>
Co-authored-by: Pratyush Shukla <ps4534@nyu.edu>
2023-11-22 13:48:01 +00:00

153 lines
3.7 KiB
Python

"""Test news 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",
[
(
{
"display": "full",
"date": "2023-01-01",
"start_date": "2023-01-01",
"end_date": "2023-06-06",
"updated_since": 900000,
"published_since": 900000,
"sort": "created",
"order": "desc",
"isin": "US0378331005",
"cusip": "037833100",
"channels": "General",
"topics": "car",
"authors": "Benzinga Insights",
"content_types": "Car",
"provider": "benzinga",
"limit": 20,
}
),
(
{
"provider": "fmp",
"limit": 20,
}
),
(
{
"provider": "intrinio",
"limit": 20,
}
),
(
{
"provider": "biztoc",
"filter": "tag",
"tag": "federalreserve",
"source": "bloomberg",
"term": "MSFT",
}
),
(
{
"provider": "tiingo",
"limit": 30,
"source": "bloomberg.com",
}
),
],
)
@pytest.mark.integration
def test_news_world(params, obb):
result = obb.news.world(**params)
assert result
assert isinstance(result, OBBject)
@pytest.mark.parametrize(
"params",
[
(
{
"display": "full",
"date": None,
"start_date": "2023-01-01",
"end_date": "2023-06-06",
"updated_since": None,
"published_since": None,
"sort": "created",
"order": "desc",
"isin": None,
"cusip": None,
"channels": "General",
"topics": "earnings",
"authors": None,
"content_types": "headline",
"provider": "benzinga",
"symbols": "AAPL,MSFT",
"limit": 20,
}
),
(
{
"published_utc": "2023-01-10",
"order": "desc",
"provider": "polygon",
"symbols": "AAPL",
"limit": 20,
}
),
(
{
"provider": "fmp",
"symbols": "AAPL",
"limit": 20,
"page": 1,
}
),
(
{
"provider": "yfinance",
"symbols": "AAPL",
"limit": 20,
}
),
(
{
"provider": "intrinio",
"symbols": "AAPL",
"limit": 20,
}
),
(
{
"provider": "tiingo",
"symbols": "AAPL,MSFT",
"limit": 20,
"source": "bloomberg.com",
}
),
],
)
@pytest.mark.integration
def test_news_company(params, obb):
params = {p: v for p, v in params.items() if v}
result = obb.news.company(**params)
assert result
assert isinstance(result, OBBject)
assert len(result.results) > 0