mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-11-12 19:43:42 +00:00
Compare commits
2 Commits
10b783ab8d
...
78314146b8
| Author | SHA1 | Date | |
|---|---|---|---|
| 78314146b8 | |||
| 25b66b5b60 |
29
docs/ahriman.core.archive.rst
Normal file
29
docs/ahriman.core.archive.rst
Normal file
@ -0,0 +1,29 @@
|
||||
ahriman.core.archive package
|
||||
============================
|
||||
|
||||
Submodules
|
||||
----------
|
||||
|
||||
ahriman.core.archive.archive\_tree module
|
||||
-----------------------------------------
|
||||
|
||||
.. automodule:: ahriman.core.archive.archive_tree
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
ahriman.core.archive.archive\_trigger module
|
||||
--------------------------------------------
|
||||
|
||||
.. automodule:: ahriman.core.archive.archive_trigger
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
Module contents
|
||||
---------------
|
||||
|
||||
.. automodule:: ahriman.core.archive
|
||||
:members:
|
||||
:no-undoc-members:
|
||||
:show-inheritance:
|
||||
@ -8,6 +8,7 @@ Subpackages
|
||||
:maxdepth: 4
|
||||
|
||||
ahriman.core.alpm
|
||||
ahriman.core.archive
|
||||
ahriman.core.auth
|
||||
ahriman.core.build_tools
|
||||
ahriman.core.configuration
|
||||
|
||||
@ -57,7 +57,7 @@ def test_repo_init(repo: Repo, mocker: MockerFixture) -> None:
|
||||
assert check_output_mock.call_args[0][0] == "repo-add"
|
||||
|
||||
|
||||
def test_repo_remove(repo: Repo, package_ahriman: Package,mocker: MockerFixture) -> None:
|
||||
def test_repo_remove(repo: Repo, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must call repo-remove on package removal
|
||||
"""
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
from dataclasses import replace
|
||||
from pathlib import Path
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
@ -23,6 +22,7 @@ def test_symlinks_create(archive_tree: ArchiveTree, package_ahriman: Package, pa
|
||||
must create symlinks
|
||||
"""
|
||||
_original_exists = Path.exists
|
||||
|
||||
def exists_mock(path: Path) -> bool:
|
||||
if path.name in (package.filename for package in package_python_schedule.packages.values()):
|
||||
return True
|
||||
@ -63,6 +63,53 @@ def test_symlinks_create_empty_filename(archive_tree: ArchiveTree, package_ahrim
|
||||
symlinks_mock.assert_not_called()
|
||||
|
||||
|
||||
def test_symlinks_fix(archive_tree: ArchiveTree, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must fix broken symlinks
|
||||
"""
|
||||
_original_exists = Path.exists
|
||||
|
||||
def exists_mock(path: Path) -> bool:
|
||||
if path.name == "symlink":
|
||||
return True
|
||||
return _original_exists(path)
|
||||
|
||||
mocker.patch("pathlib.Path.is_symlink", side_effect=[True, True, False])
|
||||
mocker.patch("pathlib.Path.exists", autospec=True, side_effect=exists_mock)
|
||||
walk_mock = mocker.patch("ahriman.core.archive.archive_tree.walk", return_value=[
|
||||
archive_tree.repository_for() / filename
|
||||
for filename in ("symlink", "broken_symlink", "file")
|
||||
])
|
||||
remove_mock = mocker.patch("ahriman.core.alpm.repo.Repo.remove")
|
||||
|
||||
archive_tree.symlinks_fix()
|
||||
walk_mock.assert_called_once_with(archive_tree.paths.archive / "repos")
|
||||
remove_mock.assert_called_once_with(None, archive_tree.repository_for() / "broken_symlink")
|
||||
|
||||
|
||||
def test_symlinks_fix_foreign_repository(archive_tree: ArchiveTree, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must skip symlinks check if repository name or architecture doesn't match
|
||||
"""
|
||||
_original_exists = Path.exists
|
||||
|
||||
def exists_mock(path: Path) -> bool:
|
||||
if path.name == "symlink":
|
||||
return True
|
||||
return _original_exists(path)
|
||||
|
||||
mocker.patch("pathlib.Path.is_symlink", side_effect=[True, True, False])
|
||||
mocker.patch("pathlib.Path.exists", autospec=True, side_effect=exists_mock)
|
||||
mocker.patch("ahriman.core.archive.archive_tree.walk", return_value=[
|
||||
archive_tree.repository_for().with_name("i686") / filename
|
||||
for filename in ("symlink", "broken_symlink", "file")
|
||||
])
|
||||
remove_mock = mocker.patch("ahriman.core.alpm.repo.Repo.remove")
|
||||
|
||||
archive_tree.symlinks_fix()
|
||||
remove_mock.assert_not_called()
|
||||
|
||||
|
||||
def test_tree_create(archive_tree: ArchiveTree, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must create repository root if not exists
|
||||
|
||||
Reference in New Issue
Block a user