replace several store_true keys to booleanoptionalaction alternative (#74)

This commit is contained in:
2022-11-10 18:34:01 +03:00
committed by GitHub
parent e58ccdc8ad
commit 0eadef597a
120 changed files with 770 additions and 705 deletions

View File

@ -5,7 +5,7 @@ from pytest_mock import MockerFixture
from unittest.mock import MagicMock
from ahriman.core.alpm.pacman import Pacman
from ahriman.core.exceptions import InvalidPackageInfo
from ahriman.core.exceptions import PackageInfoError
from ahriman.models.aur_package import AURPackage
from ahriman.models.package import Package
from ahriman.models.repository_paths import RepositoryPaths
@ -114,7 +114,7 @@ def test_from_build_failed(package_ahriman: Package, mocker: MockerFixture) -> N
mocker.patch("ahriman.models.package.Package._check_output", return_value="")
mocker.patch("ahriman.models.package.parse_srcinfo", return_value=({"packages": {}}, ["an error"]))
with pytest.raises(InvalidPackageInfo):
with pytest.raises(PackageInfoError):
Package.from_build(Path("path"))
@ -159,7 +159,7 @@ def test_dependencies_failed(mocker: MockerFixture) -> None:
mocker.patch("ahriman.models.package.Package._check_output", return_value="")
mocker.patch("ahriman.models.package.parse_srcinfo", return_value=({"packages": {}}, ["an error"]))
with pytest.raises(InvalidPackageInfo):
with pytest.raises(PackageInfoError):
Package.dependencies(Path("path"))
@ -200,7 +200,7 @@ def test_supported_architectures_failed(mocker: MockerFixture) -> None:
mocker.patch("ahriman.models.package.Package._check_output", return_value="")
mocker.patch("ahriman.models.package.parse_srcinfo", return_value=({"packages": {}}, ["an error"]))
with pytest.raises(InvalidPackageInfo):
with pytest.raises(PackageInfoError):
Package.supported_architectures(Path("path"))

View File

@ -3,10 +3,9 @@ import pytest
from pathlib import Path
from pytest_mock import MockerFixture
from typing import Callable, Tuple
from unittest import mock
from unittest.mock import MagicMock
from unittest.mock import MagicMock, call as MockCall
from ahriman.core.exceptions import InvalidPath
from ahriman.core.exceptions import PathError
from ahriman.models.package import Package
from ahriman.models.repository_paths import RepositoryPaths
@ -89,8 +88,8 @@ def test_chown_parent(repository_paths: RepositoryPaths, mocker: MockerFixture)
path = repository_paths.root / "parent" / "path"
repository_paths.chown(path)
chown_mock.assert_has_calls([
mock.call(path, 42, 42, follow_symlinks=False),
mock.call(path.parent, 42, 42, follow_symlinks=False)
MockCall(path, 42, 42, follow_symlinks=False),
MockCall(path.parent, 42, 42, follow_symlinks=False)
])
@ -111,7 +110,7 @@ def test_chown_invalid_path(repository_paths: RepositoryPaths) -> None:
"""
must raise invalid path exception in case if directory outside the root supplied
"""
with pytest.raises(InvalidPath):
with pytest.raises(PathError):
repository_paths.chown(repository_paths.root.parent)
@ -128,7 +127,7 @@ def test_tree_clear(repository_paths: RepositoryPaths, package_ahriman: Package,
repository_paths.tree_clear(package_ahriman.base)
rmtree_mock.assert_has_calls(
[
mock.call(path, ignore_errors=True) for path in paths
MockCall(path, ignore_errors=True) for path in paths
], any_order=True)
@ -154,5 +153,5 @@ def test_tree_create(repository_paths: RepositoryPaths, mocker: MockerFixture) -
chown_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.chown")
repository_paths.tree_create()
mkdir_mock.assert_has_calls([mock.call(mode=0o755, parents=True, exist_ok=True) for _ in paths], any_order=True)
chown_mock.assert_has_calls([mock.call(pytest.helpers.anyvar(int)) for _ in paths], any_order=True)
mkdir_mock.assert_has_calls([MockCall(mode=0o755, parents=True, exist_ok=True) for _ in paths], any_order=True)
chown_mock.assert_has_calls([MockCall(pytest.helpers.anyvar(int)) for _ in paths], any_order=True)

View File

@ -1,6 +1,6 @@
import pytest
from ahriman.core.exceptions import SuccessFailed
from ahriman.core.exceptions import UnprocessedPackageStatusError
from ahriman.models.package import Package
from ahriman.models.result import Result
@ -99,7 +99,7 @@ def test_merge_exception(package_ahriman: Package) -> None:
right = Result()
right.add_success(package_ahriman)
with pytest.raises(SuccessFailed):
with pytest.raises(UnprocessedPackageStatusError):
left.merge(right)