mirror of
https://github.com/arcan1s/ahriman.git
synced 2026-08-22 08:17:26 +00:00
feat: read includes from list of directories
This commit is contained in:
@@ -137,7 +137,11 @@ def test_configuration_create_ahriman(args: argparse.Namespace, configuration: C
|
||||
MockCall("auth", "salt", pytest.helpers.anyvar(str, strict=True)),
|
||||
])
|
||||
write_mock.assert_called_once_with(pytest.helpers.anyvar(int))
|
||||
remove_mock.assert_called_once_with(configuration.include / "00-setup-overrides.ini", missing_ok=True)
|
||||
remove_mock.assert_called_once_with(
|
||||
next(
|
||||
path for path in configuration.include) /
|
||||
"00-setup-overrides.ini",
|
||||
missing_ok=True)
|
||||
|
||||
|
||||
def test_configuration_create_ahriman_no_multilib(args: argparse.Namespace, configuration: Configuration,
|
||||
|
||||
@@ -374,17 +374,16 @@ def test_load_environment(configuration: Configuration) -> None:
|
||||
assert configuration.get("section:identifier", "key") == "value2"
|
||||
|
||||
|
||||
def test_load_includes(mocker: MockerFixture) -> None:
|
||||
def test_load_includes(configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must load includes
|
||||
"""
|
||||
mocker.patch.object(Configuration, "logging_path", Path("logging"))
|
||||
read_mock = mocker.patch("ahriman.core.configuration.Configuration.read")
|
||||
glob_mock = mocker.patch("pathlib.Path.glob", autospec=True, return_value=[Path("include"), Path("logging")])
|
||||
configuration = Configuration()
|
||||
|
||||
configuration.load_includes(Path("path"))
|
||||
glob_mock.assert_called_once_with(Path("path"), "*.ini")
|
||||
configuration.load_includes()
|
||||
glob_mock.assert_called_once_with(configuration.path.absolute().parent, "*.ini")
|
||||
read_mock.assert_called_once_with(Path("include"))
|
||||
assert configuration.includes == [Path("include")]
|
||||
|
||||
@@ -415,17 +414,6 @@ def test_load_includes_no_section() -> None:
|
||||
configuration.load_includes()
|
||||
|
||||
|
||||
def test_load_includes_default_path(mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must load includes from default path
|
||||
"""
|
||||
mocker.patch.object(Configuration, "include", Path("path"))
|
||||
glob_mock = mocker.patch("pathlib.Path.glob", autospec=True, return_value=[])
|
||||
|
||||
Configuration().load_includes()
|
||||
glob_mock.assert_called_once_with(Path("path"), "*.ini")
|
||||
|
||||
|
||||
def test_merge_sections_missing(configuration: Configuration) -> None:
|
||||
"""
|
||||
must merge create section if not exists
|
||||
|
||||
@@ -134,6 +134,10 @@ def test_validate_path_type(validator: Validator, mocker: MockerFixture) -> None
|
||||
"""
|
||||
error_mock = mocker.patch("ahriman.core.configuration.validator.Validator._error")
|
||||
|
||||
validator._validate_path_type("file", "field", Path("42"))
|
||||
|
||||
mocker.patch("pathlib.Path.exists", return_value=True)
|
||||
|
||||
mocker.patch("pathlib.Path.is_file", return_value=True)
|
||||
validator._validate_path_type("file", "field", Path("1"))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user