mirror of
https://github.com/fhswf/aki_prj23_transparenzregister.git
synced 2025-04-22 05:02:53 +02:00
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
"""Tests for sentiment ui elements."""
|
|
|
|
from sqlalchemy.orm import Session
|
|
|
|
from aki_prj23_transparenzregister.ui import data_elements, sentiment_elements
|
|
|
|
|
|
def test_sentiment_layout(news_db: Session) -> None:
|
|
"""Checks if the sentiment tab layout of the company page can be created."""
|
|
selected_company_id = 1
|
|
sentiment_elements.sentiment_layout(selected_company_id, news_db)
|
|
|
|
|
|
def test_sentiment_trend_figure(news_db: Session) -> None:
|
|
"""Checks if the sentiment trend graph can be created."""
|
|
n = 10
|
|
company_id = 1
|
|
articles = data_elements.get_news_of_one_company(company_id, news_db)
|
|
|
|
articles["overall_sentiment_label"] = articles["overall_sentiment_label"].apply(
|
|
lambda _: _.value
|
|
)
|
|
|
|
articles = articles.sort_values(by=["timestamp"], ascending=True)
|
|
articles["rolling_mean"] = articles["overall_sentiment_label"].rolling(n).mean()
|
|
sentiment_elements.sentiment_trend_figure(articles)
|
|
|
|
|
|
def test_sentiment_gauge_figure() -> None:
|
|
"""Checks if the sentiment gauge graph can be created."""
|
|
sentiment_score = 0.2
|
|
sentiment_elements.sentiment_gauge_figure(sentiment_score)
|