add debugtoolbar support

This commit is contained in:
2021-09-26 12:27:46 +03:00
parent 5a6d0e0000
commit d60c553ea2
8 changed files with 50 additions and 1 deletions

View File

@ -64,3 +64,20 @@ def application_with_auth(configuration: Configuration, user: User, spawner: Spa
application["validator"]._users[generated.username] = generated
return application
@pytest.fixture
def application_with_debug(configuration: Configuration, user: User, spawner: Spawn,
mocker: MockerFixture) -> web.Application:
"""
application fixture with debug enabled
:param configuration: configuration fixture
:param user: user descriptor fixture
:param spawner: spawner fixture
:param mocker: mocker object
:return: application test instance
"""
configuration.set_option("web", "debug", "yes")
mocker.patch.object(ahriman.core.auth.helpers, "_has_aiohttp_security", False)
mocker.patch("pathlib.Path.mkdir")
return setup_service("x86_64", configuration, spawner)

View File

@ -45,7 +45,7 @@ def test_run(application: web.Application, mocker: MockerFixture) -> None:
def test_run_with_auth(application_with_auth: web.Application, mocker: MockerFixture) -> None:
"""
must run application
must run application with enabled authorization
"""
port = 8080
application_with_auth["configuration"].set_option("web", "port", str(port))
@ -54,3 +54,16 @@ def test_run_with_auth(application_with_auth: web.Application, mocker: MockerFix
run_server(application_with_auth)
run_application_mock.assert_called_with(application_with_auth, host="127.0.0.1", port=port,
handle_signals=False, access_log=pytest.helpers.anyvar(int))
def test_run_with_debug(application_with_debug: web.Application, mocker: MockerFixture) -> None:
"""
must run application with enabled debug panel
"""
port = 8080
application_with_debug["configuration"].set_option("web", "port", str(port))
run_application_mock = mocker.patch("aiohttp.web.run_app")
run_server(application_with_debug)
run_application_mock.assert_called_with(application_with_debug, host="127.0.0.1", port=port,
handle_signals=False, access_log=pytest.helpers.anyvar(int))

View File

@ -62,6 +62,9 @@ region = eu-central-1
secret_key =
[web]
debug = no
debug_check_host = no
debug_allowed_hosts =
host = 127.0.0.1
static_path = ../web/templates/static
templates = ../web/templates