mirror of
https://github.com/fhswf/aki_prj23_transparenzregister.git
synced 2025-06-22 07:03:56 +02:00
Add a cli interface to choose a configuration (#163)
- [x] add a cli to the webserver to take env variables into account - [x] add a cli to the data processing that takes enviromental variable as a valid source into account - [x] rework the cli for the reset sql command - [x] rework the cli for the copying of sql data from one db to another
This commit is contained in:
@ -1,7 +1,11 @@
|
||||
"""Test for the main app dashboard."""
|
||||
import sys
|
||||
from collections.abc import Generator
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
from _pytest.monkeypatch import MonkeyPatch
|
||||
from pytest_mock import MockerFixture
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from aki_prj23_transparenzregister.ui import app
|
||||
@ -31,3 +35,27 @@ 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"
|
||||
|
||||
|
||||
def test_main_of_app(monkeypatch: MonkeyPatch) -> None:
|
||||
monkeypatch.setattr(sys, "argv", [sys.argv[0]])
|
||||
with pytest.raises(SystemExit):
|
||||
app.main()
|
||||
|
||||
|
||||
def test_main_of_app_help(monkeypatch: MonkeyPatch) -> None:
|
||||
monkeypatch.setattr(sys, "argv", [sys.argv[0], "-h"])
|
||||
with pytest.raises(SystemExit):
|
||||
app.main()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("upper", [True, False])
|
||||
def test_main_of_app_env(
|
||||
monkeypatch: MonkeyPatch, upper: bool, mocker: MockerFixture
|
||||
) -> None:
|
||||
MagicMock()
|
||||
monkeypatch.setattr(sys, "argv", [sys.argv[0], "ENV" if upper else "env"])
|
||||
mocked = mocker.patch("aki_prj23_transparenzregister.ui.app.Dash.run")
|
||||
mocked.return_value = None
|
||||
app.main()
|
||||
mocked.assert_called_once()
|
||||
|
Reference in New Issue
Block a user