Refactor news API methods to use 'limit' parameter instead of 'total' for consistency across wrappers
This commit is contained in:
@@ -15,7 +15,7 @@ class TestCryptoPanicAPI:
|
||||
|
||||
def test_crypto_panic_api_get_latest_news(self):
|
||||
crypto = CryptoPanicWrapper()
|
||||
articles = crypto.get_latest_news(query="", total=2)
|
||||
articles = crypto.get_latest_news(query="", limit=2)
|
||||
assert isinstance(articles, list)
|
||||
assert len(articles) == 2
|
||||
for article in articles:
|
||||
|
||||
@@ -12,7 +12,7 @@ class TestDuckDuckGoNews:
|
||||
|
||||
def test_duckduckgo_get_latest_news(self):
|
||||
news = DuckDuckGoWrapper()
|
||||
articles = news.get_latest_news(query="crypto", total=2)
|
||||
articles = news.get_latest_news(query="crypto", limit=2)
|
||||
assert isinstance(articles, list)
|
||||
assert len(articles) == 2
|
||||
for article in articles:
|
||||
@@ -23,7 +23,7 @@ class TestDuckDuckGoNews:
|
||||
|
||||
def test_duckduckgo_get_top_headlines(self):
|
||||
news = DuckDuckGoWrapper()
|
||||
articles = news.get_top_headlines(total=2)
|
||||
articles = news.get_top_headlines(limit=2)
|
||||
assert isinstance(articles, list)
|
||||
assert len(articles) == 2
|
||||
for article in articles:
|
||||
|
||||
@@ -12,7 +12,7 @@ class TestGoogleNews:
|
||||
|
||||
def test_gnews_api_get_latest_news(self):
|
||||
gnews_api = GoogleNewsWrapper()
|
||||
articles = gnews_api.get_latest_news(query="crypto", total=2)
|
||||
articles = gnews_api.get_latest_news(query="crypto", limit=2)
|
||||
assert isinstance(articles, list)
|
||||
assert len(articles) == 2
|
||||
for article in articles:
|
||||
@@ -23,7 +23,7 @@ class TestGoogleNews:
|
||||
|
||||
def test_gnews_api_get_top_headlines(self):
|
||||
news_api = GoogleNewsWrapper()
|
||||
articles = news_api.get_top_headlines(total=2)
|
||||
articles = news_api.get_top_headlines(limit=2)
|
||||
assert isinstance(articles, list)
|
||||
assert len(articles) == 2
|
||||
for article in articles:
|
||||
|
||||
@@ -14,7 +14,7 @@ class TestNewsAPI:
|
||||
|
||||
def test_news_api_get_latest_news(self):
|
||||
news_api = NewsApiWrapper()
|
||||
articles = news_api.get_latest_news(query="crypto", total=2)
|
||||
articles = news_api.get_latest_news(query="crypto", limit=2)
|
||||
assert isinstance(articles, list)
|
||||
assert len(articles) > 0 # Ensure we got some articles (apparently it doesn't always return the requested number)
|
||||
for article in articles:
|
||||
@@ -26,7 +26,7 @@ class TestNewsAPI:
|
||||
|
||||
def test_news_api_get_top_headlines(self):
|
||||
news_api = NewsApiWrapper()
|
||||
articles = news_api.get_top_headlines(total=2)
|
||||
articles = news_api.get_top_headlines(limit=2)
|
||||
assert isinstance(articles, list)
|
||||
# assert len(articles) > 0 # apparently it doesn't always return SOME articles
|
||||
for article in articles:
|
||||
|
||||
@@ -13,7 +13,7 @@ class TestNewsAPITool:
|
||||
|
||||
def test_news_api_tool_get_top(self):
|
||||
tool = NewsAPIsTool()
|
||||
result = tool.wrapper_handler.try_call(lambda w: w.get_top_headlines(total=2))
|
||||
result = tool.wrapper_handler.try_call(lambda w: w.get_top_headlines(limit=2))
|
||||
assert isinstance(result, list)
|
||||
assert len(result) > 0
|
||||
for article in result:
|
||||
@@ -22,7 +22,7 @@ class TestNewsAPITool:
|
||||
|
||||
def test_news_api_tool_get_latest(self):
|
||||
tool = NewsAPIsTool()
|
||||
result = tool.wrapper_handler.try_call(lambda w: w.get_latest_news(query="crypto", total=2))
|
||||
result = tool.wrapper_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:
|
||||
@@ -31,7 +31,7 @@ class TestNewsAPITool:
|
||||
|
||||
def test_news_api_tool_get_top__all_results(self):
|
||||
tool = NewsAPIsTool()
|
||||
result = tool.wrapper_handler.try_call_all(lambda w: w.get_top_headlines(total=2))
|
||||
result = tool.wrapper_handler.try_call_all(lambda w: w.get_top_headlines(limit=2))
|
||||
assert isinstance(result, dict)
|
||||
assert len(result.keys()) > 0
|
||||
print("Results from providers:", result.keys())
|
||||
@@ -43,7 +43,7 @@ class TestNewsAPITool:
|
||||
|
||||
def test_news_api_tool_get_latest__all_results(self):
|
||||
tool = NewsAPIsTool()
|
||||
result = tool.wrapper_handler.try_call_all(lambda w: w.get_latest_news(query="crypto", total=2))
|
||||
result = tool.wrapper_handler.try_call_all(lambda w: w.get_latest_news(query="crypto", limit=2))
|
||||
assert isinstance(result, dict)
|
||||
assert len(result.keys()) > 0
|
||||
print("Results from providers:", result.keys())
|
||||
|
||||
32
tests/tools/test_socials_tool.py
Normal file
32
tests/tools/test_socials_tool.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import pytest
|
||||
from app.social import SocialAPIsTool
|
||||
|
||||
|
||||
@pytest.mark.tools
|
||||
@pytest.mark.social
|
||||
@pytest.mark.api
|
||||
class TestSocialAPIsTool:
|
||||
def test_social_api_tool(self):
|
||||
tool = SocialAPIsTool()
|
||||
assert tool is not None
|
||||
|
||||
def test_social_api_tool_get_top(self):
|
||||
tool = SocialAPIsTool()
|
||||
result = tool.wrapper_handler.try_call(lambda w: w.get_top_crypto_posts(limit=2))
|
||||
assert isinstance(result, list)
|
||||
assert len(result) > 0
|
||||
for post in result:
|
||||
assert post.title is not None
|
||||
assert post.time is not None
|
||||
|
||||
def test_social_api_tool_get_top__all_results(self):
|
||||
tool = SocialAPIsTool()
|
||||
result = tool.wrapper_handler.try_call_all(lambda w: w.get_top_crypto_posts(limit=2))
|
||||
assert isinstance(result, dict)
|
||||
assert len(result.keys()) > 0
|
||||
print("Results from providers:", result.keys())
|
||||
for provider, posts in result.items():
|
||||
for post in posts:
|
||||
print(provider, post.title)
|
||||
assert post.title is not None
|
||||
assert post.time is not None
|
||||
Reference in New Issue
Block a user