port part of settings to database (#54)

This commit is contained in:
2022-03-31 01:48:06 +03:00
committed by GitHub
parent fb02e676af
commit 28cc38aaa5
117 changed files with 2768 additions and 1044 deletions

View File

@ -1,41 +0,0 @@
import pytest
from aiohttp.test_utils import TestClient
from pytest_mock import MockerFixture
from ahriman.models.user_access import UserAccess
from ahriman.web.views.service.reload_auth import ReloadAuthView
async def test_get_permission() -> None:
"""
must return correct permission for the request
"""
for method in ("POST",):
request = pytest.helpers.request("", "", method)
assert await ReloadAuthView.get_permission(request) == UserAccess.Write
async def test_post(client_with_auth: TestClient, mocker: MockerFixture) -> None:
"""
must call post request correctly
"""
mocker.patch("aiohttp_security.check_permission", return_value=True)
reload_mock = mocker.patch("ahriman.core.configuration.Configuration.reload")
load_mock = mocker.patch("ahriman.core.auth.auth.Auth.load")
response = await client_with_auth.post("/service-api/v1/reload-auth")
assert response.ok
reload_mock.assert_called_once_with()
load_mock.assert_called_once_with(client_with_auth.app["configuration"])
async def test_post_no_auth(client: TestClient, mocker: MockerFixture) -> None:
"""
must call return 500 if no authorization module loaded
"""
reload_mock = mocker.patch("ahriman.core.configuration.Configuration.reload")
response = await client.post("/service-api/v1/reload-auth")
assert response.status == 500
reload_mock.assert_called_once_with()