Create multi page layout (#147)

Created two pages (home and company), page reloads after company
selection in dropdown or clicking the home button.
This commit is contained in:
KM-R
2023-09-26 18:38:40 +02:00
committed by GitHub
parent 5fa7cd230a
commit 9566276047
13 changed files with 261 additions and 71 deletions

33
tests/ui/app_test.py Normal file
View File

@@ -0,0 +1,33 @@
"""Test for the main app dashboard."""
from collections.abc import Generator
import pytest
from sqlalchemy.orm import Session
from aki_prj23_transparenzregister.ui import app
from aki_prj23_transparenzregister.ui.session_handler import SessionHandler
@pytest.fixture(autouse=True)
def _set_session(full_db: Session) -> Generator[None, None, None]:
"""Sets a session for the dash application to be used."""
SessionHandler.session = full_db
yield
SessionHandler.session = None
def test_import() -> None:
"""Checks if an import of the dash app can be made."""
assert app is not None
def test_go_to_home() -> None:
"""Checks if the go_to_home callback yields a result."""
output = app.go_to_home(1)
assert output == "/"
def test_go_to_company_page() -> None:
"""Checks if the go_to_company_page callback yields a result."""
output = app.go_to_company_page(1)
assert output == "/Unternehmensdetails/1"

View File

@@ -0,0 +1,27 @@
"""Tests for the company page dashboard."""
from collections.abc import Generator
import pytest
from sqlalchemy.orm import Session
from aki_prj23_transparenzregister.ui.pages import company
from aki_prj23_transparenzregister.ui.session_handler import SessionHandler
@pytest.fixture(autouse=True)
def _set_session(full_db: Session) -> Generator[None, None, None]:
"""Sets a session for the dash application to be used."""
SessionHandler.session = full_db
yield
SessionHandler.session = None
def test_import() -> None:
"""Checks if an import of the company page can be made."""
assert company is not None
def test_layout() -> None:
"""Checks if the company page can be created."""
selected_company_id = "2"
company.layout(selected_company_id)

View File

@@ -1,7 +0,0 @@
"""Test the compy stats dash file."""
from aki_prj23_transparenzregister.ui import company_stats_dash
def test_company_stats_dash_import() -> None:
"""Since there is no single method to test the import is tested instead."""
assert company_stats_dash

View File

@@ -105,7 +105,7 @@ def test_create_tabs(full_db: Session) -> None:
selected_finance_df = finance_df.loc[
finance_df["company_id"] == selected_company_id
]
ui_elements.create_tabs(selected_finance_df)
ui_elements.create_tabs(selected_company_id, selected_finance_df)
def test_kennzahlen_layout(full_db: Session) -> None: