fix: update packages properties after rebuild

This case leads to issue when it is impossible to update list of
implicit dependencies correctly in case of multi-packages
This commit is contained in:
2024-12-24 15:13:18 +02:00
parent 0660c33de3
commit 286ff4bcef
5 changed files with 44 additions and 2 deletions

View File

@ -29,9 +29,11 @@ def test_process_build(executor: Executor, package_ahriman: Package, passwd: Any
depends_on_mock = mocker.patch("ahriman.core.build_tools.package_archive.PackageArchive.depends_on",
return_value=Dependencies())
dependencies_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_dependencies_update")
with_packages_mock = mocker.patch("ahriman.models.package.Package.with_packages")
executor.process_build([package_ahriman], Packagers("packager"), bump_pkgrel=False)
init_mock.assert_called_once_with(pytest.helpers.anyvar(int), pytest.helpers.anyvar(int), None)
with_packages_mock.assert_called_once_with([Path(package_ahriman.base)], executor.pacman)
changes_mock.assert_called_once_with(package_ahriman.base)
depends_on_mock.assert_called_once_with()
dependencies_mock.assert_called_once_with(package_ahriman.base, Dependencies())

View File

@ -1,6 +1,8 @@
import copy
from pathlib import Path
from pytest_mock import MockerFixture
from unittest.mock import MagicMock
from unittest.mock import MagicMock, call as MockCall
from ahriman.core.alpm.pacman import Pacman
from ahriman.core.configuration import Configuration
@ -493,3 +495,23 @@ def test_build_status_pretty_print(package_ahriman: Package) -> None:
"""
assert package_ahriman.pretty_print()
assert isinstance(package_ahriman.pretty_print(), str)
def test_with_packages(package_ahriman: Package, package_python_schedule: Package, pacman: Pacman,
mocker: MockerFixture) -> None:
"""
must correctly replace packages descriptions
"""
paths = [Path("1"), Path("2")]
from_archive_mock = mocker.patch("ahriman.models.package.Package.from_archive", side_effect=[
package_ahriman, package_python_schedule
])
result = copy.deepcopy(package_ahriman)
package_ahriman.packages[package_ahriman.base].architecture = "i686"
result.with_packages(paths, pacman)
from_archive_mock.assert_has_calls([
MockCall(path, pacman) for path in paths
])
assert result.packages[result.base] == package_ahriman.packages[package_ahriman.base]