"""Tests the addition of an authentication framework.""" from _pytest.monkeypatch import MonkeyPatch from dash import Dash from pytest_mock import MockerFixture from aki_prj23_transparenzregister.ui import protection def test_no_auth(monkeypatch: MonkeyPatch, mocker: MockerFixture) -> None: """Tests if no authentication is added.""" monkeypatch.setenv("PYTHON_DASH_LOGIN_USERNAME", "") monkeypatch.setenv("PYTHON_DASH_LOGIN_PW", "") basic_auth_mocker = mocker.spy(protection.dash_auth, "BasicAuth") protection.add_auth(Dash()) basic_auth_mocker.assert_not_called() def test_add_auth(monkeypatch: MonkeyPatch, mocker: MockerFixture) -> None: """Tests if an authentication is added.""" monkeypatch.setenv("PYTHON_DASH_LOGIN_USERNAME", "some-login") monkeypatch.setenv("PYTHON_DASH_LOGIN_PW", "some-pw") basic_auth_mocker = mocker.spy(protection.dash_auth, "BasicAuth") protection.add_auth(Dash()) basic_auth_mocker.assert_called_once()