Moved the AI tests into the AI folder. (#315)

This commit is contained in:
2023-11-03 13:45:24 +01:00
committed by GitHub
parent 9d04e46f55
commit ad36c68993
4 changed files with 0 additions and 0 deletions

View File

@ -0,0 +1,78 @@
"""Tests for checking Sentiment Services."""
from aki_prj23_transparenzregister.ai.sentiment_service import (
SentimentAnalysisService,
)
def test_sentiment_service_with_spacy_pos() -> None:
"""Mock testing spaCy Sentiment Service with positive sentiment."""
# Init SentimentAnalysisService with spaCy
sentiment_service = SentimentAnalysisService(use_spacy=True)
# run the test
text = "Dies ist ein großartiger Test. Ich liebe es!"
sentiment, score = sentiment_service.sentiment_spacy(text)
assert sentiment == "positive"
assert score > 0
def test_sentiment_service_with_spacy_neg() -> None:
"""Mock testing spaCy Sentiment Service with negative sentiment."""
# Init SentimentAnalysisService with spaCy
sentiment_service = SentimentAnalysisService(use_spacy=True)
# run the test
text = "Dies ist ein wirklich schrecklicher Test. Ich hasse ihn!"
sentiment, score = sentiment_service.sentiment_spacy(text)
assert sentiment == "negative"
assert score > 0
def test_sentiment_service_with_spacy_neut() -> None:
"""Mock testing spaCy Sentiment Service with neutral sentiment."""
# Init SentimentAnalysisService with spaCy
sentiment_service = SentimentAnalysisService(use_spacy=True)
# run the test
text = "Dies ist ein Test."
sentiment, score = sentiment_service.sentiment_spacy(text)
assert sentiment == "neutral"
assert score >= 0
def test_sentiment_service_with_transformer_pos() -> None:
"""Mock testing Transformer Sentiment Service with positive Sentiment."""
# Init SentimentAnalysisService with Transformer
sentiment_service = SentimentAnalysisService(use_transformer=True)
# run the test
text = "Dies ist ein großartiger Test. Ich liebe es!"
sentiment, score = sentiment_service.sentiment_transformer(text)
assert sentiment == "positive"
assert score > 0
def test_sentiment_service_with_transformer_neg() -> None:
"""Mock testing Transformer Sentiment Service with negative Sentiment."""
# Init SentimentAnalysisService with Transformer
sentiment_service = SentimentAnalysisService(use_transformer=True)
# run the test
text = "Dies ist ein wirklich schrecklicher Test. Ich hasse ihn!"
sentiment, score = sentiment_service.sentiment_transformer(text)
assert sentiment == "negative"
assert score > 0
def test_sentiment_service_with_transformer_neut() -> None:
"""Mock testing Transformer Sentiment Service with neutral Sentiment."""
# Init SentimentAnalysisService with Transformer
sentiment_service = SentimentAnalysisService(use_transformer=True)
# run the test
text = "Das ist ein Text, ohne besondere Stimmung."
sentiment, score = sentiment_service.sentiment_transformer(text)
assert sentiment == "neutral"
assert score >= 0