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:
@ -4,6 +4,7 @@ import pandas as pd
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from aki_prj23_transparenzregister.ui import data_elements
|
||||
from aki_prj23_transparenzregister.utils.enum_types import SentimentLabel
|
||||
|
||||
|
||||
def test_import() -> None:
|
||||
@ -86,3 +87,27 @@ def test_get_finance_data(full_db: Session) -> None:
|
||||
}
|
||||
)
|
||||
pd.testing.assert_frame_equal(finance_df, test_data)
|
||||
|
||||
|
||||
def test_get_news_of_one_company0(news_db: Session) -> None:
|
||||
"""Tests what happens if no sentiment can be found."""
|
||||
selected_company_id = 100
|
||||
assert data_elements.get_news_of_one_company(selected_company_id, news_db).empty
|
||||
|
||||
|
||||
def test_get_news_of_one_company1(news_db: Session) -> None:
|
||||
"""Tests if the sentiments can be collected for a company specified."""
|
||||
selected_company_id = 2
|
||||
sentiment_df = data_elements.get_news_of_one_company(selected_company_id, news_db)
|
||||
assert sentiment_df is not None
|
||||
assert sentiment_df.to_dict(orient="records") == [
|
||||
{
|
||||
"overall_sentiment_certainty": 0.95,
|
||||
"overall_sentiment_label": SentimentLabel.POSITIVE,
|
||||
"source_domain": "example-news.com",
|
||||
"source_url": "http://example-news.com/ai-revolution",
|
||||
"times_named": 2,
|
||||
"timestamp": pd.Timestamp("2023-11-01 15:30:00"),
|
||||
"title": "AI Revolution in Tech",
|
||||
},
|
||||
]
|
||||
|
Reference in New Issue
Block a user