mirror of
https://github.com/fhswf/aki_prj23_transparenzregister.git
synced 2025-06-22 07:03:56 +02:00
Visualize company sentiment (#422)
Updates the tab and widget "Stimmung"
This commit is contained in:
32
tests/ui/sentiment_elements_test.py
Normal file
32
tests/ui/sentiment_elements_test.py
Normal file
@ -0,0 +1,32 @@
|
||||
"""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, n)
|
||||
|
||||
|
||||
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)
|
Reference in New Issue
Block a user