mirror of
https://github.com/fhswf/aki_prj23_transparenzregister.git
synced 2025-06-22 07:43:55 +02:00
Added links (#406)
Added links into the plot. When clicking on the plot on the main page a redirect is implemente the the matching detailpage.
This commit is contained in:
@ -1,8 +1,10 @@
|
||||
"""Test for the Home Page."""
|
||||
import datetime
|
||||
from collections.abc import Generator
|
||||
from typing import Any
|
||||
from unittest.mock import patch
|
||||
|
||||
import dash
|
||||
import pandas as pd
|
||||
import pytest
|
||||
from sqlalchemy.orm import Session
|
||||
@ -205,3 +207,33 @@ def _set_session(full_db: Session) -> Generator[None, None, None]:
|
||||
def test_layout() -> None:
|
||||
"""Checks if layout can be executed."""
|
||||
home.layout()
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("_set_session")
|
||||
@pytest.mark.parametrize("empty", ["", None, {}])
|
||||
def test_redirect_empty(empty: Any) -> None:
|
||||
"""Tests the redirection on clicking on the plot with an empty argument."""
|
||||
assert home.redirect(empty) == dash.no_update # type: ignore
|
||||
|
||||
|
||||
def test_redirect_content_without_db() -> None:
|
||||
"""Tests the error when no SQL session is defined."""
|
||||
with pytest.raises(ValueError, match="No SQL session defined."):
|
||||
assert home.redirect({"empty": ""})
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("_set_session")
|
||||
@pytest.mark.parametrize(
|
||||
("click_on", "redirect_to"),
|
||||
[
|
||||
(
|
||||
{"text": "Some Company GmbH"},
|
||||
"/unternehmensdetails/1",
|
||||
),
|
||||
({"text": "Max Mustermann"}, "/personendetails/1"),
|
||||
({"text": "I do not exist"}, dash.no_update),
|
||||
],
|
||||
)
|
||||
def test_redirect(click_on: dict, redirect_to: Any) -> None:
|
||||
"""Tests the redirection when clicking on a plot."""
|
||||
assert home.redirect({"points": [click_on]}) == redirect_to
|
||||
|
Reference in New Issue
Block a user