mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-04-23 23:07:17 +00:00
use generic removal method
This commit is contained in:
parent
be09c04e78
commit
a83f1d5aa5
@ -68,8 +68,7 @@ class Patch(Handler):
|
||||
package = Package.load(sources_dir, application.repository.pacman, application.repository.aur_url)
|
||||
patch_dir = application.repository.paths.patches_for(package.base)
|
||||
|
||||
if patch_dir.is_dir():
|
||||
shutil.rmtree(patch_dir) # remove old patches
|
||||
Patch.patch_set_remove(application, package.base) # remove old patches
|
||||
patch_dir.mkdir(mode=0o755, parents=True)
|
||||
|
||||
Sources.patch_create(sources_dir, patch_dir / "00-main.patch", *track)
|
||||
|
@ -92,26 +92,15 @@ def test_patch_set_create(application: Application, package_ahriman: Package, mo
|
||||
must create patch set for the package
|
||||
"""
|
||||
mocker.patch("ahriman.models.package.Package.load", return_value=package_ahriman)
|
||||
remove_mock = mocker.patch("ahriman.application.handlers.patch.Patch.patch_set_remove")
|
||||
create_mock = mocker.patch("ahriman.core.build_tools.sources.Sources.patch_create")
|
||||
patch_dir = application.repository.paths.patches_for(package_ahriman.base)
|
||||
|
||||
Patch.patch_set_create(application, Path("path"), ["*.patch"])
|
||||
remove_mock.assert_called_once_with(application, package_ahriman.base)
|
||||
create_mock.assert_called_once_with(Path("path"), patch_dir / "00-main.patch", "*.patch")
|
||||
|
||||
|
||||
def test_patch_set_create_clear(application: Application, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must clear patches directory before new set creation
|
||||
"""
|
||||
mocker.patch("pathlib.Path.is_dir", return_value=True)
|
||||
mocker.patch("ahriman.models.package.Package.load", return_value=package_ahriman)
|
||||
mocker.patch("ahriman.core.build_tools.sources.Sources.patch_create")
|
||||
remove_mock = mocker.patch("shutil.rmtree")
|
||||
|
||||
Patch.patch_set_create(application, Path("path"), ["*.patch"])
|
||||
remove_mock.assert_called()
|
||||
|
||||
|
||||
def test_patch_set_remove(application: Application, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must remove patch set for the package
|
||||
|
Loading…
Reference in New Issue
Block a user