* Refactor project structure "api" * fix bug conversione delle valute fiat in stablecoin in BinanceWrapper * Refactor: WrapperHandler for managing API wrappers with retry logic; update related modules and tests * Refactor: Update ProductInfo and Price classes to include aggregation methods; remove standalone aggregation functions * fix docs
35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
import pytest
|
|
from app.api.news import GoogleNewsWrapper
|
|
|
|
|
|
@pytest.mark.news
|
|
@pytest.mark.api
|
|
class TestGoogleNews:
|
|
|
|
def test_gnews_api_initialization(self):
|
|
gnews_api = GoogleNewsWrapper()
|
|
assert gnews_api is not None
|
|
|
|
def test_gnews_api_get_latest_news(self):
|
|
gnews_api = GoogleNewsWrapper()
|
|
articles = gnews_api.get_latest_news(query="crypto", limit=2)
|
|
assert isinstance(articles, list)
|
|
assert len(articles) == 2
|
|
for article in articles:
|
|
assert article.source is not None or article.source != ""
|
|
assert article.time is not None or article.time != ""
|
|
assert article.title is not None or article.title != ""
|
|
assert article.description is not None or article.description != ""
|
|
|
|
def test_gnews_api_get_top_headlines(self):
|
|
news_api = GoogleNewsWrapper()
|
|
articles = news_api.get_top_headlines(limit=2)
|
|
assert isinstance(articles, list)
|
|
assert len(articles) == 2
|
|
for article in articles:
|
|
assert article.source is not None or article.source != ""
|
|
assert article.time is not None or article.time != ""
|
|
assert article.title is not None or article.title != ""
|
|
assert article.description is not None or article.description != ""
|
|
|