mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-06-28 14:51:43 +00:00
Compare commits
2 Commits
e119f092b4
...
7769a4a6e0
Author | SHA1 | Date | |
---|---|---|---|
7769a4a6e0 | |||
066d1b1dde |
2621
docs/_static/architecture.dot
vendored
2621
docs/_static/architecture.dot
vendored
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,7 @@
|
||||
|
||||
pkgbase='ahriman'
|
||||
pkgname=('ahriman' 'ahriman-core' 'ahriman-triggers' 'ahriman-web')
|
||||
pkgver=2.18.2
|
||||
pkgver=2.18.3
|
||||
pkgrel=1
|
||||
pkgdesc="ArcH linux ReposItory MANager"
|
||||
arch=('any')
|
||||
|
@ -17,4 +17,4 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
__version__ = "2.18.2"
|
||||
__version__ = "2.18.3"
|
||||
|
@ -210,6 +210,17 @@ class Configuration(configparser.RawConfigParser):
|
||||
raise InitializeError("Configuration path and/or repository id are not set")
|
||||
return self.path, self.repository_id
|
||||
|
||||
def copy_from(self, configuration: Self) -> None:
|
||||
"""
|
||||
copy values from another instance overriding existing
|
||||
|
||||
Args:
|
||||
configuration(Self): configuration instance to merge from
|
||||
"""
|
||||
for section in configuration.sections():
|
||||
for key, value in configuration.items(section):
|
||||
self.set_option(section, key, value)
|
||||
|
||||
def dump(self) -> dict[str, dict[str, str]]:
|
||||
"""
|
||||
dump configuration to dictionary
|
||||
@ -220,6 +231,7 @@ class Configuration(configparser.RawConfigParser):
|
||||
return {
|
||||
section: dict(self.items(section))
|
||||
for section in self.sections()
|
||||
if self[section]
|
||||
}
|
||||
|
||||
# pylint and mypy are too stupid to find these methods
|
||||
|
@ -72,8 +72,8 @@ def setup_routes(application: Application, configuration: Configuration) -> None
|
||||
application(Application): web application instance
|
||||
configuration(Configuration): configuration instance
|
||||
"""
|
||||
application.router.add_static("/static", configuration.getpath("web", "static_path"), name="_static",
|
||||
follow_symlinks=True)
|
||||
application.router.add_static("/static", configuration.getpath("web", "static_path"),
|
||||
name="_static", follow_symlinks=True)
|
||||
|
||||
for route, view in _dynamic_routes(configuration):
|
||||
application.router.add_view(route, view, name=_identifier(route))
|
||||
|
@ -144,6 +144,7 @@ def test_repositories_extract(args: argparse.Namespace, configuration: Configura
|
||||
args.architecture = "arch"
|
||||
args.configuration = configuration.path
|
||||
args.repository = "repo"
|
||||
mocker.patch("ahriman.core.configuration.Configuration.load", new=lambda self, _: self.copy_from(configuration))
|
||||
known_architectures_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_architectures")
|
||||
known_repositories_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_repositories")
|
||||
|
||||
@ -159,6 +160,7 @@ def test_repositories_extract_repository(args: argparse.Namespace, configuration
|
||||
"""
|
||||
args.architecture = "arch"
|
||||
args.configuration = configuration.path
|
||||
mocker.patch("ahriman.core.configuration.Configuration.load", new=lambda self, _: self.copy_from(configuration))
|
||||
known_architectures_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_architectures")
|
||||
known_repositories_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_repositories",
|
||||
return_value={"repo"})
|
||||
@ -175,6 +177,7 @@ def test_repositories_extract_repository_legacy(args: argparse.Namespace, config
|
||||
"""
|
||||
args.architecture = "arch"
|
||||
args.configuration = configuration.path
|
||||
mocker.patch("ahriman.core.configuration.Configuration.load", new=lambda self, _: self.copy_from(configuration))
|
||||
known_architectures_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_architectures")
|
||||
known_repositories_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_repositories",
|
||||
return_value=set())
|
||||
@ -191,6 +194,7 @@ def test_repositories_extract_architecture(args: argparse.Namespace, configurati
|
||||
"""
|
||||
args.configuration = configuration.path
|
||||
args.repository = "repo"
|
||||
mocker.patch("ahriman.core.configuration.Configuration.load", new=lambda self, _: self.copy_from(configuration))
|
||||
known_architectures_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_architectures",
|
||||
return_value={"arch"})
|
||||
known_repositories_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_repositories")
|
||||
@ -207,6 +211,7 @@ def test_repositories_extract_empty(args: argparse.Namespace, configuration: Con
|
||||
"""
|
||||
args.command = "config"
|
||||
args.configuration = configuration.path
|
||||
mocker.patch("ahriman.core.configuration.Configuration.load", new=lambda self, _: self.copy_from(configuration))
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_architectures", return_value=set())
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_repositories", return_value=set())
|
||||
|
||||
@ -221,6 +226,7 @@ def test_repositories_extract_systemd(args: argparse.Namespace, configuration: C
|
||||
"""
|
||||
args.configuration = configuration.path
|
||||
args.repository_id = "i686/some/repo/name"
|
||||
mocker.patch("ahriman.core.configuration.Configuration.load", new=lambda self, _: self.copy_from(configuration))
|
||||
known_architectures_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_architectures")
|
||||
known_repositories_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_repositories")
|
||||
|
||||
@ -236,6 +242,7 @@ def test_repositories_extract_systemd_with_dash(args: argparse.Namespace, config
|
||||
"""
|
||||
args.configuration = configuration.path
|
||||
args.repository_id = "i686-some-repo-name"
|
||||
mocker.patch("ahriman.core.configuration.Configuration.load", new=lambda self, _: self.copy_from(configuration))
|
||||
known_architectures_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_architectures")
|
||||
known_repositories_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_repositories")
|
||||
|
||||
@ -251,6 +258,7 @@ def test_repositories_extract_systemd_legacy(args: argparse.Namespace, configura
|
||||
"""
|
||||
args.configuration = configuration.path
|
||||
args.repository_id = "i686"
|
||||
mocker.patch("ahriman.core.configuration.Configuration.load", new=lambda self, _: self.copy_from(configuration))
|
||||
known_architectures_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_architectures")
|
||||
known_repositories_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_repositories",
|
||||
return_value=set())
|
||||
|
@ -79,6 +79,7 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat
|
||||
args = _default_args(args)
|
||||
args.exit_code = True
|
||||
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
|
||||
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
||||
mocker.patch("ahriman.core.repository.Repository.packages", return_value=[])
|
||||
mocker.patch("ahriman.application.application.Application.update")
|
||||
check_mock = mocker.patch("ahriman.application.handlers.handler.Handler.check_status")
|
||||
|
@ -1575,6 +1575,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
||||
args.command = ""
|
||||
args.handler = Handler
|
||||
|
||||
mocker.patch("ahriman.core.configuration.Configuration.load", new=lambda self, _: self.copy_from(configuration))
|
||||
mocker.patch("argparse.ArgumentParser.parse_args", return_value=args)
|
||||
|
||||
assert ahriman.run() == 1
|
||||
|
@ -1,8 +1,6 @@
|
||||
import datetime
|
||||
import pytest
|
||||
import tempfile
|
||||
|
||||
from collections.abc import Generator
|
||||
from pathlib import Path
|
||||
from pytest_mock import MockerFixture
|
||||
from typing import Any, TypeVar
|
||||
@ -251,38 +249,39 @@ def auth(configuration: Configuration) -> Auth:
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def configuration(repository_id: RepositoryId, resource_path_root: Path) -> Configuration:
|
||||
def configuration(repository_id: RepositoryId, tmp_path: Path, resource_path_root: Path) -> Configuration:
|
||||
"""
|
||||
configuration fixture
|
||||
|
||||
Args:
|
||||
repository_id(RepositoryId): repository identifier fixture
|
||||
tmp_path(Path): temporary path used by the fixture as root
|
||||
resource_path_root(Path): resource path root directory
|
||||
|
||||
Returns:
|
||||
Configuration: configuration test instance
|
||||
"""
|
||||
path = resource_path_root / "core" / "ahriman.ini"
|
||||
return Configuration.from_path(path, repository_id)
|
||||
|
||||
instance = Configuration.from_path(path, repository_id)
|
||||
instance.set_option("repository", "root", str(tmp_path))
|
||||
instance.set_option("settings", "database", str(tmp_path / "ahriman.db"))
|
||||
|
||||
return instance
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def database(configuration: Configuration) -> Generator[SQLite, None, None]:
|
||||
def database(configuration: Configuration) -> SQLite:
|
||||
"""
|
||||
database fixture
|
||||
|
||||
Args:
|
||||
configuration(Configuration): configuration fixture
|
||||
|
||||
Yields:
|
||||
Returns:
|
||||
SQLite: database test instance
|
||||
"""
|
||||
database_file = tempfile.mktemp(dir=configuration.repository_paths.root) # nosec
|
||||
configuration.set_option("settings", "database", database_file)
|
||||
|
||||
database = SQLite.load(configuration)
|
||||
yield database
|
||||
database.path.unlink()
|
||||
return SQLite.load(configuration)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@ -102,6 +102,15 @@ def test_check_loaded_architecture(configuration: Configuration) -> None:
|
||||
configuration.check_loaded()
|
||||
|
||||
|
||||
def test_copy_from(configuration: Configuration) -> None:
|
||||
"""
|
||||
must copy values from another instance
|
||||
"""
|
||||
instance = Configuration()
|
||||
instance.copy_from(configuration)
|
||||
assert instance.dump() == configuration.dump()
|
||||
|
||||
|
||||
def test_dump(configuration: Configuration) -> None:
|
||||
"""
|
||||
dump must not be empty
|
||||
|
@ -12,8 +12,6 @@ def test_load(configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
must correctly load instance
|
||||
"""
|
||||
init_mock = mocker.patch("ahriman.core.database.SQLite.init")
|
||||
configuration.set_option("settings", "database", "ahriman.db")
|
||||
|
||||
SQLite.load(configuration)
|
||||
init_mock.assert_called_once_with()
|
||||
|
||||
|
@ -30,7 +30,6 @@ triggers_known = ahriman.core.distributed.WorkerLoaderTrigger ahriman.core.distr
|
||||
|
||||
[repository]
|
||||
name = aur
|
||||
root = ../../../
|
||||
|
||||
[sign]
|
||||
target =
|
||||
|
Reference in New Issue
Block a user