mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-07-30 06:09:56 +00:00
add ability to reload authentication module
This commit is contained in:
@ -61,6 +61,13 @@ def test_get_self(client: Client) -> None:
|
||||
assert client.get_self().status == BuildStatusEnum.Unknown
|
||||
|
||||
|
||||
def test_reload_auth(client: Client) -> None:
|
||||
"""
|
||||
must process auth reload without errors
|
||||
"""
|
||||
client.reload_auth()
|
||||
|
||||
|
||||
def test_remove(client: Client, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must process remove without errors
|
||||
|
@ -230,6 +230,32 @@ def test_get_self_failed_http_error(web_client: WebClient, mocker: MockerFixture
|
||||
assert web_client.get_self().status == BuildStatusEnum.Unknown
|
||||
|
||||
|
||||
def test_reload_auth(web_client: WebClient, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must process auth reload
|
||||
"""
|
||||
requests_mock = mocker.patch("requests.Session.post")
|
||||
|
||||
web_client.reload_auth()
|
||||
requests_mock.assert_called_with(pytest.helpers.anyvar(str, True))
|
||||
|
||||
|
||||
def test_reload_auth_failed(web_client: WebClient, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must suppress any exception happened during auth reload
|
||||
"""
|
||||
mocker.patch("requests.Session.post", side_effect=Exception())
|
||||
web_client.reload_auth()
|
||||
|
||||
|
||||
def test_reload_auth_failed_http_error(web_client: WebClient, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must suppress any exception happened during removal
|
||||
"""
|
||||
mocker.patch("requests.Session.post", side_effect=requests.exceptions.HTTPError())
|
||||
web_client.reload_auth()
|
||||
|
||||
|
||||
def test_remove(web_client: WebClient, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must process package removal
|
||||
|
@ -5,6 +5,7 @@ import pytest
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.exceptions import InitializeException
|
||||
|
||||
|
||||
def test_from_path(mocker: MockerFixture) -> None:
|
||||
@ -115,6 +116,7 @@ def test_getlist_single(configuration: Configuration) -> None:
|
||||
"""
|
||||
configuration.set_option("build", "test_list", "a")
|
||||
assert configuration.getlist("build", "test_list") == ["a"]
|
||||
assert configuration.getlist("build", "test_list") == ["a"]
|
||||
|
||||
|
||||
def test_load_includes_missing(configuration: Configuration) -> None:
|
||||
@ -170,6 +172,36 @@ def test_merge_sections_missing(configuration: Configuration) -> None:
|
||||
assert configuration.get("build", "key") == "value"
|
||||
|
||||
|
||||
def test_reload(configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must reload configuration
|
||||
"""
|
||||
load_mock = mocker.patch("ahriman.core.configuration.Configuration.load")
|
||||
merge_mock = mocker.patch("ahriman.core.configuration.Configuration.merge_sections")
|
||||
|
||||
configuration.reload()
|
||||
load_mock.assert_called_once()
|
||||
merge_mock.assert_called_once()
|
||||
|
||||
|
||||
def test_reload_no_architecture(configuration: Configuration) -> None:
|
||||
"""
|
||||
must raise exception on reload if no architecture set
|
||||
"""
|
||||
configuration.architecture = None
|
||||
with pytest.raises(InitializeException):
|
||||
configuration.reload()
|
||||
|
||||
|
||||
def test_reload_no_path(configuration: Configuration) -> None:
|
||||
"""
|
||||
must raise exception on reload if no path set
|
||||
"""
|
||||
configuration.path = None
|
||||
with pytest.raises(InitializeException):
|
||||
configuration.reload()
|
||||
|
||||
|
||||
def test_set_option(configuration: Configuration) -> None:
|
||||
"""
|
||||
must set option correctly
|
||||
|
Reference in New Issue
Block a user