mirror of
https://github.com/fhswf/aki_prj23_transparenzregister.git
synced 2025-04-25 20:32:34 +02:00
Created two pages (home and company), page reloads after company selection in dropdown or clicking the home button.
119 lines
4.8 KiB
Python
119 lines
4.8 KiB
Python
"""Tests for ui elements."""
|
|
|
|
import pandas as pd
|
|
from sqlalchemy.orm import Session
|
|
|
|
from aki_prj23_transparenzregister.ui import ui_elements
|
|
|
|
|
|
def test_import() -> None:
|
|
"""Checks if an import co ui_elements can be made."""
|
|
assert ui_elements is not None
|
|
|
|
|
|
def test_get_company_data(full_db: Session) -> None:
|
|
"""Checks if data from the company and district court tables can be accessed."""
|
|
company_df = ui_elements.get_company_data(full_db)
|
|
|
|
test_data = pd.DataFrame(
|
|
{
|
|
"company_id": {0: 1, 1: 2, 2: 3},
|
|
"company_hr": {0: "HRB 123", 1: "HRB 123", 2: "HRB 12"},
|
|
"company_court_id": {0: 2, 1: 1, 2: 2},
|
|
"company_name": {
|
|
0: "Some Company GmbH",
|
|
1: "Other Company GmbH",
|
|
2: "Third Company GmbH",
|
|
},
|
|
"company_street": {0: "Sesamstr.", 1: "Sesamstr.", 2: None},
|
|
"company_zip_code": {0: "12345", 1: "12345", 2: None},
|
|
"company_city": {0: "TV City", 1: "TV City", 2: None},
|
|
"company_last_update": {
|
|
0: "2023-01-01",
|
|
1: "2023-01-01",
|
|
2: "2023-01-01",
|
|
},
|
|
"company_sector": {0: None, 1: None, 2: None},
|
|
"district_court_name": {
|
|
0: "Amtsgericht Dortmund",
|
|
1: "Amtsgericht Bochum",
|
|
2: "Amtsgericht Dortmund",
|
|
},
|
|
}
|
|
)
|
|
test_data = test_data.set_index("company_id")
|
|
pd.testing.assert_frame_equal(company_df, test_data)
|
|
|
|
|
|
def test_get_finance_data(full_db: Session) -> None:
|
|
"""Checks if data from the company and finance tables can be accessed."""
|
|
finance_df = ui_elements.get_finance_data(full_db)
|
|
test_data = pd.DataFrame(
|
|
{
|
|
"annual_finance_statement_id": {0: 1, 1: 2},
|
|
"annual_finance_statement_company_id": {0: 1, 1: 1},
|
|
"annual_finance_statement_date": {0: "2023-01-01", 1: "2022-01-01"},
|
|
"annual_finance_statement_total_volume": {0: 1000.0, 1: 1100.0},
|
|
"annual_finance_statement_ebit": {0: 1000.0, 1: 1100.0},
|
|
"annual_finance_statement_ebitda": {0: 1000.0, 1: 1100.0},
|
|
"annual_finance_statement_ebit_margin": {0: 1000.0, 1: 1100.0},
|
|
"annual_finance_statement_total_balance": {0: 1000.0, 1: 1100.0},
|
|
"annual_finance_statement_equity": {0: 1000.0, 1: 1100.0},
|
|
"annual_finance_statement_debt": {0: 1000.0, 1: 1100.0},
|
|
"annual_finance_statement_return_on_equity": {0: 1000.0, 1: 1100.0},
|
|
"annual_finance_statement_capital_turnover_rate": {0: 1000.0, 1: 1100.0},
|
|
"annual_finance_statement_current_liabilities": {0: 1000.0, 1: 1100.0},
|
|
"annual_finance_statement_dividends": {0: None, 1: None},
|
|
"annual_finance_statement_net_income": {0: None, 1: None},
|
|
"annual_finance_statement_assets": {0: 1000.0, 1: 1100.0},
|
|
"annual_finance_statement_long_term_debt": {0: 1000.0, 1: 1100.0},
|
|
"annual_finance_statement_short_term_debt": {0: 1000.0, 1: 1100.0},
|
|
"annual_finance_statement_revenue": {0: 1000.0, 1: 1100.0},
|
|
"annual_finance_statement_cash_flow": {0: 1000.0, 1: 1100.0},
|
|
"annual_finance_statement_current_assets": {0: 1000.0, 1: 1100.0},
|
|
"company_name": {0: "Some Company GmbH", 1: "Some Company GmbH"},
|
|
"company_id": {0: 1, 1: 1},
|
|
}
|
|
)
|
|
pd.testing.assert_frame_equal(finance_df, test_data)
|
|
|
|
|
|
def test_create_header() -> None:
|
|
"""Checks if the header can be created."""
|
|
options = {1: "a", 2: "b"}
|
|
ui_elements.create_header(options)
|
|
|
|
|
|
def test_create_company_header() -> None:
|
|
"""Checks if the company header can be created."""
|
|
selected_company = "Test GmbH"
|
|
ui_elements.create_company_header(selected_company)
|
|
|
|
|
|
def test_create_company_stats(full_db: Session) -> None:
|
|
"""Checks if the company widgets can be created."""
|
|
company_df = ui_elements.get_company_data(full_db)
|
|
value_chosen = 1
|
|
selected_company_stats = company_df.loc[value_chosen]
|
|
ui_elements.create_company_stats(selected_company_stats)
|
|
|
|
|
|
def test_create_tabs(full_db: Session) -> None:
|
|
"""Checks if the tabs of the company page can be created."""
|
|
selected_company_id = 1
|
|
finance_df = ui_elements.get_finance_data(full_db)
|
|
selected_finance_df = finance_df.loc[
|
|
finance_df["company_id"] == selected_company_id
|
|
]
|
|
ui_elements.create_tabs(selected_company_id, selected_finance_df)
|
|
|
|
|
|
def test_kennzahlen_layout(full_db: Session) -> None:
|
|
"""Checks if the financial metric layout of the company page can be created."""
|
|
selected_company_id = 1
|
|
finance_df = ui_elements.get_finance_data(full_db)
|
|
selected_finance_df = finance_df.loc[
|
|
finance_df["company_id"] == selected_company_id
|
|
]
|
|
ui_elements.kennzahlen_layout(selected_finance_df)
|