Skip to content

Commit a5985d0

Browse files
committed
Correct sentiment test cases and align with updated VADER output format
1 parent fb9a7cf commit a5985d0

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

tests/test_sentiment.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
# tests/test_sentiment.py
2+
23
from src.components.sentiment_component import SentimentComponent
34

45
def test_vader_or_fallback():
5-
comp = SentimentComponent(use_transformers=False)
6-
r = comp.analyze_statement("I love this product, it's great!")
7-
assert r.label in ("positive","neutral","negative")
6+
comp = SentimentComponent()
7+
8+
# Positive sentence
9+
r1 = comp.analyze_statement("I love this product, it's great!")
10+
11+
assert isinstance(r1, dict), "SentimentComponent must return a dict"
12+
assert r1["label"] in ("positive", "neutral", "negative"), "Invalid sentiment label"
13+
assert isinstance(r1["confidence"], float), "Confidence should be a float"
14+
15+
# Negative sentence
816
r2 = comp.analyze_statement("This is terrible and awful")
9-
assert r2.label in ("negative","neutral","positive")
17+
18+
assert isinstance(r2, dict)
19+
assert r2["label"] in ("positive", "neutral", "negative")
20+
assert isinstance(r2["confidence"], float)

0 commit comments

Comments
 (0)