32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
|
|
import pytest
|
||
|
|
from agents.news import NewsAgent
|
||
|
|
|
||
|
|
def test_score_positive_news():
|
||
|
|
agent = NewsAgent()
|
||
|
|
articles = [
|
||
|
|
{"title": "Bitcoin surges 10%", "sentiment_votes": {"positive": 10, "negative": 1}},
|
||
|
|
{"title": "BTC adoption grows", "sentiment_votes": {"positive": 8, "negative": 2}},
|
||
|
|
{"title": "Bitcoin rally continues", "sentiment_votes": {"positive": 15, "negative": 0}},
|
||
|
|
]
|
||
|
|
score = agent.analyze(articles)
|
||
|
|
assert score >= 70
|
||
|
|
|
||
|
|
def test_score_negative_news():
|
||
|
|
agent = NewsAgent()
|
||
|
|
articles = [
|
||
|
|
{"title": "Bitcoin crashes hard", "sentiment_votes": {"positive": 1, "negative": 10}},
|
||
|
|
{"title": "Crypto market in fear", "sentiment_votes": {"positive": 0, "negative": 15}},
|
||
|
|
]
|
||
|
|
score = agent.analyze(articles)
|
||
|
|
assert score <= 35
|
||
|
|
|
||
|
|
def test_score_no_news_returns_50():
|
||
|
|
agent = NewsAgent()
|
||
|
|
assert agent.analyze([]) == 50
|
||
|
|
|
||
|
|
def test_score_mixed_news():
|
||
|
|
agent = NewsAgent()
|
||
|
|
articles = [{"title": "BTC up", "sentiment_votes": {"positive": 5, "negative": 5}}]
|
||
|
|
score = agent.analyze(articles)
|
||
|
|
assert 40 <= score <= 60
|