mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-11-17 22:13:41 +00:00
feat: allow to use one application for multiple repositories (#111)
* allow to use one application for multiple repositories * update tests * handle None append argument everywhere * rewrite repository definition logic * drop optional flags from docs * support of new schema in systemd units * add migration docs and ability to migrate tree automatically * use repostory id instead * verbose multiarchitectureerror * object path support for s3 sync * fix tests after rebase
This commit is contained in:
@ -19,12 +19,13 @@ def test_init_with_local_cache(configuration: Configuration, mocker: MockerFixtu
|
||||
mocker.patch("ahriman.core.alpm.pacman.Pacman.database_copy")
|
||||
sync_mock = mocker.patch("ahriman.core.alpm.pacman.Pacman.database_sync")
|
||||
configuration.set_option("alpm", "use_ahriman_cache", "yes")
|
||||
_, repository_id = configuration.check_loaded()
|
||||
|
||||
# pyalpm.Handle is trying to reach the directory we've asked, thus we need to patch it a bit
|
||||
with TemporaryDirectory(ignore_cleanup_errors=True) as pacman_root:
|
||||
mocker.patch.object(RepositoryPaths, "pacman", Path(pacman_root))
|
||||
# during the creation pyalpm.Handle will create also version file which we would like to remove later
|
||||
pacman = Pacman("x86_64", configuration, refresh_database=PacmanSynchronization.Enabled)
|
||||
pacman = Pacman(repository_id, configuration, refresh_database=PacmanSynchronization.Enabled)
|
||||
assert pacman.handle
|
||||
sync_mock.assert_called_once_with(pytest.helpers.anyvar(int), force=False)
|
||||
|
||||
@ -36,12 +37,13 @@ def test_init_with_local_cache_forced(configuration: Configuration, mocker: Mock
|
||||
mocker.patch("ahriman.core.alpm.pacman.Pacman.database_copy")
|
||||
sync_mock = mocker.patch("ahriman.core.alpm.pacman.Pacman.database_sync")
|
||||
configuration.set_option("alpm", "use_ahriman_cache", "yes")
|
||||
_, repository_id = configuration.check_loaded()
|
||||
|
||||
# pyalpm.Handle is trying to reach the directory we've asked, thus we need to patch it a bit
|
||||
with TemporaryDirectory(ignore_cleanup_errors=True) as pacman_root:
|
||||
mocker.patch.object(RepositoryPaths, "pacman", Path(pacman_root))
|
||||
# during the creation pyalpm.Handle will create also version file which we would like to remove later
|
||||
pacman = Pacman("x86_64", configuration, refresh_database=PacmanSynchronization.Force)
|
||||
pacman = Pacman(repository_id, configuration, refresh_database=PacmanSynchronization.Force)
|
||||
assert pacman.handle
|
||||
sync_mock.assert_called_once_with(pytest.helpers.anyvar(int), force=True)
|
||||
|
||||
@ -56,10 +58,12 @@ def test_database_copy(pacman: Pacman, repository_paths: RepositoryPaths, mocker
|
||||
mocker.patch("pathlib.Path.is_dir", return_value=True)
|
||||
# root database exists, local database does not
|
||||
mocker.patch("pathlib.Path.is_file", autospec=True, side_effect=lambda p: p.is_relative_to(path))
|
||||
mkdir_mock = mocker.patch("pathlib.Path.mkdir")
|
||||
copy_mock = mocker.patch("shutil.copy")
|
||||
chown_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.chown")
|
||||
|
||||
pacman.database_copy(pacman.handle, database, path, repository_paths, use_ahriman_cache=True)
|
||||
mkdir_mock.assert_called_once_with(mode=0o755, exist_ok=True)
|
||||
copy_mock.assert_called_once_with(path / "sync" / "core.db", dst_path)
|
||||
chown_mock.assert_called_once_with(dst_path)
|
||||
|
||||
@ -128,8 +132,8 @@ def test_database_init(pacman: Pacman, configuration: Configuration) -> None:
|
||||
must init database with settings
|
||||
"""
|
||||
mirror = configuration.get("alpm", "mirror")
|
||||
database = pacman.database_init(pacman.handle, "test", mirror, "x86_64")
|
||||
assert len(database.servers) == 1
|
||||
database = pacman.database_init(pacman.handle, "testing", mirror, "x86_64")
|
||||
assert database.servers == ["https://geo.mirror.pkgbuild.com/testing/os/x86_64"]
|
||||
|
||||
|
||||
def test_database_sync(pacman: Pacman) -> None:
|
||||
|
||||
Reference in New Issue
Block a user