* Prompt messi in una cartella apposta * Aggiorna importazioni demo per riflettere la nuova struttura delle cartelle API * Aggiunto configurazione dell'applicazione * Spostato ChatManager in app.interface * Update README.md * Aggiornato config per app & api * Rinominato il modulo NewsAPI * fix main infinite loop * API base --> core * pattern singleton per AppConfig. * Estratto i tools nella loro cartella --> api/tools * fix main KeyboardInterrupt * update tests * Docker & libs * fix copilot suggestions
50 lines
1.8 KiB
Python
50 lines
1.8 KiB
Python
import pytest
|
|
from app.api.tools import NewsAPIsTool
|
|
|
|
|
|
@pytest.mark.tools
|
|
@pytest.mark.news
|
|
@pytest.mark.api
|
|
class TestNewsAPITool:
|
|
def test_news_api_tool(self):
|
|
tool = NewsAPIsTool()
|
|
assert tool is not None
|
|
|
|
def test_news_api_tool_get_top(self):
|
|
tool = NewsAPIsTool()
|
|
result = tool.handler.try_call(lambda w: w.get_top_headlines(limit=2))
|
|
assert isinstance(result, list)
|
|
assert len(result) > 0
|
|
for article in result:
|
|
assert article.title is not None
|
|
assert article.source is not None
|
|
|
|
def test_news_api_tool_get_latest(self):
|
|
tool = NewsAPIsTool()
|
|
result = tool.handler.try_call(lambda w: w.get_latest_news(query="crypto", limit=2))
|
|
assert isinstance(result, list)
|
|
assert len(result) > 0
|
|
for article in result:
|
|
assert article.title is not None
|
|
assert article.source is not None
|
|
|
|
def test_news_api_tool_get_top__all_results(self):
|
|
tool = NewsAPIsTool()
|
|
result = tool.handler.try_call_all(lambda w: w.get_top_headlines(limit=2))
|
|
assert isinstance(result, dict)
|
|
assert len(result.keys()) > 0
|
|
for _provider, articles in result.items():
|
|
for article in articles:
|
|
assert article.title is not None
|
|
assert article.source is not None
|
|
|
|
def test_news_api_tool_get_latest__all_results(self):
|
|
tool = NewsAPIsTool()
|
|
result = tool.handler.try_call_all(lambda w: w.get_latest_news(query="crypto", limit=2))
|
|
assert isinstance(result, dict)
|
|
assert len(result.keys()) > 0
|
|
for _provider, articles in result.items():
|
|
for article in articles:
|
|
assert article.title is not None
|
|
assert article.source is not None
|