mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-06-28 14:51:43 +00:00
replace several store_true keys to booleanoptionalaction alternative (#74)
This commit is contained in:
@ -24,7 +24,7 @@ def application_packages(configuration: Configuration, database: SQLite, mocker:
|
||||
"""
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
|
||||
return ApplicationPackages("x86_64", configuration, no_report=True, unsafe=False)
|
||||
return ApplicationPackages("x86_64", configuration, report=False, unsafe=False)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@ -43,7 +43,7 @@ def application_properties(configuration: Configuration, database: SQLite,
|
||||
"""
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
|
||||
return ApplicationProperties("x86_64", configuration, no_report=True, unsafe=False)
|
||||
return ApplicationProperties("x86_64", configuration, report=False, unsafe=False)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@ -62,4 +62,4 @@ def application_repository(configuration: Configuration, database: SQLite,
|
||||
"""
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
|
||||
return ApplicationRepository("x86_64", configuration, no_report=True, unsafe=False)
|
||||
return ApplicationRepository("x86_64", configuration, report=False, unsafe=False)
|
||||
|
@ -1,7 +1,7 @@
|
||||
import pytest
|
||||
|
||||
from pytest_mock import MockerFixture
|
||||
from unittest import mock
|
||||
from unittest.mock import call as MockCall
|
||||
|
||||
from ahriman.application.application.application_repository import ApplicationRepository
|
||||
from ahriman.core.tree import Leaf, Tree
|
||||
@ -22,7 +22,7 @@ def test_clean_cache(application_repository: ApplicationRepository, mocker: Mock
|
||||
must clean cache directory
|
||||
"""
|
||||
clear_mock = mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_cache")
|
||||
application_repository.clean(True, False, False, False)
|
||||
application_repository.clean(cache=True, chroot=False, manual=False, packages=False, pacman=False)
|
||||
clear_mock.assert_called_once_with()
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@ def test_clean_chroot(application_repository: ApplicationRepository, mocker: Moc
|
||||
must clean chroot directory
|
||||
"""
|
||||
clear_mock = mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_chroot")
|
||||
application_repository.clean(False, True, False, False)
|
||||
application_repository.clean(cache=False, chroot=True, manual=False, packages=False, pacman=False)
|
||||
clear_mock.assert_called_once_with()
|
||||
|
||||
|
||||
@ -40,7 +40,7 @@ def test_clean_manual(application_repository: ApplicationRepository, mocker: Moc
|
||||
must clean manual directory
|
||||
"""
|
||||
clear_mock = mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_queue")
|
||||
application_repository.clean(False, False, True, False)
|
||||
application_repository.clean(cache=False, chroot=False, manual=True, packages=False, pacman=False)
|
||||
clear_mock.assert_called_once_with()
|
||||
|
||||
|
||||
@ -49,7 +49,16 @@ def test_clean_packages(application_repository: ApplicationRepository, mocker: M
|
||||
must clean packages directory
|
||||
"""
|
||||
clear_mock = mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_packages")
|
||||
application_repository.clean(False, False, False, True)
|
||||
application_repository.clean(cache=False, chroot=False, manual=False, packages=True, pacman=False)
|
||||
clear_mock.assert_called_once_with()
|
||||
|
||||
|
||||
def test_clean_pacman(application_repository: ApplicationRepository, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must clean packages directory
|
||||
"""
|
||||
clear_mock = mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_pacman")
|
||||
application_repository.clean(cache=False, chroot=False, manual=False, packages=False, pacman=True)
|
||||
clear_mock.assert_called_once_with()
|
||||
|
||||
|
||||
@ -68,8 +77,8 @@ def test_sign(application_repository: ApplicationRepository, package_ahriman: Pa
|
||||
|
||||
application_repository.sign([])
|
||||
copy_mock.assert_has_calls([
|
||||
mock.call(pytest.helpers.anyvar(int), pytest.helpers.anyvar(int)),
|
||||
mock.call(pytest.helpers.anyvar(int), pytest.helpers.anyvar(int))
|
||||
MockCall(pytest.helpers.anyvar(int), pytest.helpers.anyvar(int)),
|
||||
MockCall(pytest.helpers.anyvar(int), pytest.helpers.anyvar(int))
|
||||
])
|
||||
update_mock.assert_called_once_with([])
|
||||
sign_repository_mock.assert_called_once_with(application_repository.repository.repo.repo_path)
|
||||
@ -168,8 +177,8 @@ def test_update(application_repository: ApplicationRepository, package_ahriman:
|
||||
|
||||
application_repository.update([package_ahriman])
|
||||
build_mock.assert_called_once_with([package_ahriman])
|
||||
update_mock.assert_has_calls([mock.call(paths), mock.call(paths)])
|
||||
on_result_mock.assert_has_calls([mock.call(result), mock.call(result)])
|
||||
update_mock.assert_has_calls([MockCall(paths), MockCall(paths)])
|
||||
on_result_mock.assert_has_calls([MockCall(result), MockCall(result)])
|
||||
|
||||
|
||||
def test_update_empty(application_repository: ApplicationRepository, package_ahriman: Package,
|
||||
@ -199,8 +208,8 @@ def test_updates_all(application_repository: ApplicationRepository, package_ahri
|
||||
updates_local_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_local")
|
||||
updates_manual_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_manual")
|
||||
|
||||
application_repository.updates([], no_aur=False, no_local=False, no_manual=False, no_vcs=False, log_fn=print)
|
||||
updates_aur_mock.assert_called_once_with([], False)
|
||||
application_repository.updates([], aur=True, local=True, manual=True, vcs=True, log_fn=print)
|
||||
updates_aur_mock.assert_called_once_with([], vcs=True)
|
||||
updates_local_mock.assert_called_once_with()
|
||||
updates_manual_mock.assert_called_once_with()
|
||||
|
||||
@ -214,7 +223,7 @@ def test_updates_disabled(application_repository: ApplicationRepository, mocker:
|
||||
updates_local_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_local")
|
||||
updates_manual_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_manual")
|
||||
|
||||
application_repository.updates([], no_aur=True, no_local=True, no_manual=True, no_vcs=False, log_fn=print)
|
||||
application_repository.updates([], aur=False, local=False, manual=False, vcs=True, log_fn=print)
|
||||
updates_aur_mock.assert_not_called()
|
||||
updates_local_mock.assert_not_called()
|
||||
updates_manual_mock.assert_not_called()
|
||||
@ -229,7 +238,7 @@ def test_updates_no_aur(application_repository: ApplicationRepository, mocker: M
|
||||
updates_local_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_local")
|
||||
updates_manual_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_manual")
|
||||
|
||||
application_repository.updates([], no_aur=True, no_local=False, no_manual=False, no_vcs=False, log_fn=print)
|
||||
application_repository.updates([], aur=False, local=True, manual=True, vcs=True, log_fn=print)
|
||||
updates_aur_mock.assert_not_called()
|
||||
updates_local_mock.assert_called_once_with()
|
||||
updates_manual_mock.assert_called_once_with()
|
||||
@ -244,8 +253,8 @@ def test_updates_no_local(application_repository: ApplicationRepository, mocker:
|
||||
updates_local_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_local")
|
||||
updates_manual_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_manual")
|
||||
|
||||
application_repository.updates([], no_aur=False, no_local=True, no_manual=False, no_vcs=False, log_fn=print)
|
||||
updates_aur_mock.assert_called_once_with([], False)
|
||||
application_repository.updates([], aur=True, local=False, manual=True, vcs=True, log_fn=print)
|
||||
updates_aur_mock.assert_called_once_with([], vcs=True)
|
||||
updates_local_mock.assert_not_called()
|
||||
updates_manual_mock.assert_called_once_with()
|
||||
|
||||
@ -259,8 +268,8 @@ def test_updates_no_manual(application_repository: ApplicationRepository, mocker
|
||||
updates_local_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_local")
|
||||
updates_manual_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_manual")
|
||||
|
||||
application_repository.updates([], no_aur=False, no_local=False, no_manual=True, no_vcs=False, log_fn=print)
|
||||
updates_aur_mock.assert_called_once_with([], False)
|
||||
application_repository.updates([], aur=True, local=True, manual=False, vcs=True, log_fn=print)
|
||||
updates_aur_mock.assert_called_once_with([], vcs=True)
|
||||
updates_local_mock.assert_called_once_with()
|
||||
updates_manual_mock.assert_not_called()
|
||||
|
||||
@ -274,8 +283,8 @@ def test_updates_no_vcs(application_repository: ApplicationRepository, mocker: M
|
||||
updates_local_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_local")
|
||||
updates_manual_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_manual")
|
||||
|
||||
application_repository.updates([], no_aur=False, no_local=False, no_manual=False, no_vcs=True, log_fn=print)
|
||||
updates_aur_mock.assert_called_once_with([], True)
|
||||
application_repository.updates([], aur=True, local=True, manual=True, vcs=False, log_fn=print)
|
||||
updates_aur_mock.assert_called_once_with([], vcs=False)
|
||||
updates_local_mock.assert_called_once_with()
|
||||
updates_manual_mock.assert_called_once_with()
|
||||
|
||||
@ -289,8 +298,7 @@ def test_updates_with_filter(application_repository: ApplicationRepository, mock
|
||||
updates_local_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_local")
|
||||
updates_manual_mock = mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.updates_manual")
|
||||
|
||||
application_repository.updates(["filter"], no_aur=False, no_local=False, no_manual=False, no_vcs=False,
|
||||
log_fn=print)
|
||||
updates_aur_mock.assert_called_once_with(["filter"], False)
|
||||
application_repository.updates(["filter"], aur=True, local=True, manual=True, vcs=True, log_fn=print)
|
||||
updates_aur_mock.assert_called_once_with(["filter"], vcs=True)
|
||||
updates_local_mock.assert_called_once_with()
|
||||
updates_manual_mock.assert_called_once_with()
|
||||
|
@ -25,7 +25,7 @@ def application(configuration: Configuration, database: SQLite, mocker: MockerFi
|
||||
"""
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
|
||||
return Application("x86_64", configuration, no_report=True, unsafe=False)
|
||||
return Application("x86_64", configuration, report=False, unsafe=False)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@ -36,7 +36,7 @@ def args() -> argparse.Namespace:
|
||||
Returns:
|
||||
argparse.Namespace: command line arguments test instance
|
||||
"""
|
||||
return argparse.Namespace(architecture=None, lock=None, force=False, unsafe=False, no_report=True)
|
||||
return argparse.Namespace(architecture=None, lock=None, force=False, unsafe=False, report=False)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@ -6,7 +6,7 @@ from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.application.handlers import Handler
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.exceptions import ExitCode, MissingArchitecture, MultipleArchitectures
|
||||
from ahriman.core.exceptions import ExitCode, MissingArchitectureError, MultipleArchitecturesError
|
||||
|
||||
|
||||
def test_architectures_extract(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
@ -29,7 +29,7 @@ def test_architectures_extract_empty(args: argparse.Namespace, configuration: Co
|
||||
args.configuration = configuration.path
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_architectures", return_value=set())
|
||||
|
||||
with pytest.raises(MissingArchitecture):
|
||||
with pytest.raises(MissingArchitectureError):
|
||||
Handler.architectures_extract(args)
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@ def test_architectures_extract_exception(args: argparse.Namespace, mocker: Mocke
|
||||
"""
|
||||
args.command = "config"
|
||||
mocker.patch.object(Handler, "ALLOW_AUTO_ARCHITECTURE_RUN", False)
|
||||
with pytest.raises(MissingArchitecture):
|
||||
with pytest.raises(MissingArchitectureError):
|
||||
Handler.architectures_extract(args)
|
||||
|
||||
|
||||
@ -112,7 +112,7 @@ def test_execute_multiple_not_supported(args: argparse.Namespace, mocker: Mocker
|
||||
args.command = "web"
|
||||
mocker.patch.object(Handler, "ALLOW_MULTI_ARCHITECTURE_RUN", False)
|
||||
|
||||
with pytest.raises(MultipleArchitectures):
|
||||
with pytest.raises(MultipleArchitecturesError):
|
||||
Handler.execute(args)
|
||||
|
||||
|
||||
@ -135,7 +135,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration) -> None:
|
||||
must raise NotImplemented for missing method
|
||||
"""
|
||||
with pytest.raises(NotImplementedError):
|
||||
Handler.run(args, "x86_64", configuration, True, True)
|
||||
Handler.run(args, "x86_64", configuration, report=True, unsafe=True)
|
||||
|
||||
|
||||
def test_check_if_empty() -> None:
|
||||
|
@ -38,7 +38,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
||||
application_mock = mocker.patch("ahriman.application.application.Application.add")
|
||||
on_start_mock = mocker.patch("ahriman.application.application.Application.on_start")
|
||||
|
||||
Add.run(args, "x86_64", configuration, True, False)
|
||||
Add.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
application_mock.assert_called_once_with(args.package, args.source, args.without_dependencies)
|
||||
on_start_mock.assert_called_once_with()
|
||||
|
||||
@ -58,8 +58,9 @@ def test_run_with_updates(args: argparse.Namespace, configuration: Configuration
|
||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
|
||||
updates_mock = mocker.patch("ahriman.application.application.Application.updates", return_value=[package_ahriman])
|
||||
|
||||
Add.run(args, "x86_64", configuration, True, False)
|
||||
updates_mock.assert_called_once_with(args.package, True, True, False, True, pytest.helpers.anyvar(int))
|
||||
Add.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
updates_mock.assert_called_once_with(args.package, aur=False, local=False, manual=True, vcs=False,
|
||||
log_fn=pytest.helpers.anyvar(int))
|
||||
application_mock.assert_called_once_with([package_ahriman])
|
||||
check_mock.assert_called_once_with(False, False)
|
||||
|
||||
@ -77,5 +78,5 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat
|
||||
mocker.patch("ahriman.application.application.Application.updates")
|
||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
|
||||
|
||||
Add.run(args, "x86_64", configuration, True, False)
|
||||
Add.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
check_mock.assert_called_once_with(True, True)
|
||||
|
@ -33,7 +33,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
||||
add_mock = tarfile.__enter__.return_value = MagicMock()
|
||||
mocker.patch("tarfile.TarFile.__new__", return_value=tarfile)
|
||||
|
||||
Backup.run(args, "x86_64", configuration, True, False)
|
||||
Backup.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
add_mock.add.assert_called_once_with(Path("path"))
|
||||
|
||||
|
||||
|
@ -20,6 +20,7 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
|
||||
args.chroot = False
|
||||
args.manual = False
|
||||
args.packages = False
|
||||
args.pacman = False
|
||||
return args
|
||||
|
||||
|
||||
@ -32,6 +33,6 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
||||
application_mock = mocker.patch("ahriman.application.application.Application.clean")
|
||||
on_start_mock = mocker.patch("ahriman.application.application.Application.on_start")
|
||||
|
||||
Clean.run(args, "x86_64", configuration, True, False)
|
||||
application_mock.assert_called_once_with(False, False, False, False)
|
||||
Clean.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
application_mock.assert_called_once_with(cache=False, chroot=False, manual=False, packages=False, pacman=False)
|
||||
on_start_mock.assert_called_once_with()
|
||||
|
@ -17,10 +17,10 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
|
||||
argparse.Namespace: generated arguments for these test cases
|
||||
"""
|
||||
args.interval = 60 * 60 * 12
|
||||
args.no_aur = False
|
||||
args.no_local = False
|
||||
args.no_manual = False
|
||||
args.no_vcs = False
|
||||
args.aur = True
|
||||
args.local = True
|
||||
args.manual = True
|
||||
args.vcs = True
|
||||
return args
|
||||
|
||||
|
||||
@ -33,8 +33,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
||||
start_mock = mocker.patch("threading.Timer.start")
|
||||
join_mock = mocker.patch("threading.Timer.join")
|
||||
|
||||
Daemon.run(args, "x86_64", configuration, True, False)
|
||||
Daemon._SHOULD_RUN = False
|
||||
run_mock.assert_called_once_with(args, "x86_64", configuration, True, False)
|
||||
Daemon.run(args, "x86_64", configuration, report=True, unsafe=False)
|
||||
run_mock.assert_called_once_with(args, "x86_64", configuration, report=True, unsafe=False)
|
||||
start_mock.assert_called_once_with()
|
||||
join_mock.assert_called_once_with()
|
||||
|
@ -15,7 +15,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
||||
application_mock = mocker.patch("ahriman.core.configuration.Configuration.dump",
|
||||
return_value=configuration.dump())
|
||||
|
||||
Dump.run(args, "x86_64", configuration, True, False)
|
||||
Dump.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
application_mock.assert_called_once_with()
|
||||
print_mock.assert_called()
|
||||
|
||||
|
@ -29,7 +29,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
||||
args = _default_args(args)
|
||||
parse_mock = mocker.patch("argparse.ArgumentParser.parse_args")
|
||||
|
||||
Help.run(args, "x86_64", configuration, True, False)
|
||||
Help.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
parse_mock.assert_called_once_with(["--help"])
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ def test_run_command(args: argparse.Namespace, configuration: Configuration, moc
|
||||
args.command = "aur-search"
|
||||
parse_mock = mocker.patch("argparse.ArgumentParser.parse_args")
|
||||
|
||||
Help.run(args, "x86_64", configuration, True, False)
|
||||
Help.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
parse_mock.assert_called_once_with(["aur-search", "--help"])
|
||||
|
||||
|
||||
|
@ -29,7 +29,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
application_mock = mocker.patch("ahriman.core.sign.gpg.GPG.key_import")
|
||||
|
||||
KeyImport.run(args, "x86_64", configuration, True, False)
|
||||
KeyImport.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
application_mock.assert_called_once_with(args.key_server, args.key)
|
||||
|
||||
|
||||
|
@ -42,7 +42,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
||||
return_value=(args.package, PkgbuildPatch(None, "patch")))
|
||||
application_mock = mocker.patch("ahriman.application.handlers.Patch.patch_set_create")
|
||||
|
||||
Patch.run(args, "x86_64", configuration, True, False)
|
||||
Patch.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
patch_mock.assert_called_once_with(args.package, args.track)
|
||||
application_mock.assert_called_once_with(pytest.helpers.anyvar(int), args.package, PkgbuildPatch(None, "patch"))
|
||||
|
||||
@ -60,7 +60,7 @@ def test_run_function(args: argparse.Namespace, configuration: Configuration, mo
|
||||
patch_mock = mocker.patch("ahriman.application.handlers.Patch.patch_create_from_function", return_value=patch)
|
||||
application_mock = mocker.patch("ahriman.application.handlers.Patch.patch_set_create")
|
||||
|
||||
Patch.run(args, "x86_64", configuration, True, False)
|
||||
Patch.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
patch_mock.assert_called_once_with(args.variable, args.patch)
|
||||
application_mock.assert_called_once_with(pytest.helpers.anyvar(int), args.package, patch)
|
||||
|
||||
@ -75,7 +75,7 @@ def test_run_list(args: argparse.Namespace, configuration: Configuration, mocker
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
application_mock = mocker.patch("ahriman.application.handlers.Patch.patch_set_list")
|
||||
|
||||
Patch.run(args, "x86_64", configuration, True, False)
|
||||
Patch.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
application_mock.assert_called_once_with(pytest.helpers.anyvar(int), args.package, ["version"], False)
|
||||
|
||||
|
||||
@ -89,7 +89,7 @@ def test_run_remove(args: argparse.Namespace, configuration: Configuration, mock
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
application_mock = mocker.patch("ahriman.application.handlers.Patch.patch_set_remove")
|
||||
|
||||
Patch.run(args, "x86_64", configuration, True, False)
|
||||
Patch.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
application_mock.assert_called_once_with(pytest.helpers.anyvar(int), args.package, ["version"])
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@ import argparse
|
||||
import pytest
|
||||
|
||||
from pytest_mock import MockerFixture
|
||||
from unittest import mock
|
||||
from unittest.mock import call as MockCall
|
||||
|
||||
from ahriman.application.application import Application
|
||||
from ahriman.application.handlers import Rebuild
|
||||
@ -43,10 +43,10 @@ def test_run(args: argparse.Namespace, package_ahriman: Package,
|
||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
|
||||
on_start_mock = mocker.patch("ahriman.application.application.Application.on_start")
|
||||
|
||||
Rebuild.run(args, "x86_64", configuration, True, False)
|
||||
Rebuild.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
application_packages_mock.assert_called_once_with(None)
|
||||
application_mock.assert_called_once_with([package_ahriman])
|
||||
check_mock.assert_has_calls([mock.call(False, False), mock.call(False, False)])
|
||||
check_mock.assert_has_calls([MockCall(False, False), MockCall(False, False)])
|
||||
on_start_mock.assert_called_once_with()
|
||||
|
||||
|
||||
@ -61,7 +61,7 @@ def test_run_extract_packages(args: argparse.Namespace, configuration: Configura
|
||||
mocker.patch("ahriman.application.application.Application.add")
|
||||
extract_mock = mocker.patch("ahriman.application.handlers.Rebuild.extract_packages", return_value=[])
|
||||
|
||||
Rebuild.run(args, "x86_64", configuration, True, False)
|
||||
Rebuild.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
extract_mock.assert_called_once_with(pytest.helpers.anyvar(int))
|
||||
|
||||
|
||||
@ -77,7 +77,7 @@ def test_run_dry_run(args: argparse.Namespace, configuration: Configuration,
|
||||
application_mock = mocker.patch("ahriman.application.application.Application.update")
|
||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
|
||||
|
||||
Rebuild.run(args, "x86_64", configuration, True, False)
|
||||
Rebuild.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
application_mock.assert_not_called()
|
||||
check_mock.assert_called_once_with(False, False)
|
||||
|
||||
@ -92,7 +92,7 @@ def test_run_filter(args: argparse.Namespace, configuration: Configuration, mock
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
application_packages_mock = mocker.patch("ahriman.core.repository.repository.Repository.packages_depend_on")
|
||||
|
||||
Rebuild.run(args, "x86_64", configuration, True, False)
|
||||
Rebuild.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
application_packages_mock.assert_called_once_with({"python-aur"})
|
||||
|
||||
|
||||
@ -105,7 +105,7 @@ def test_run_without_filter(args: argparse.Namespace, configuration: Configurati
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
application_packages_mock = mocker.patch("ahriman.core.repository.repository.Repository.packages_depend_on")
|
||||
|
||||
Rebuild.run(args, "x86_64", configuration, True, False)
|
||||
Rebuild.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
application_packages_mock.assert_called_once_with(None)
|
||||
|
||||
|
||||
@ -121,7 +121,7 @@ def test_run_update_empty_exception(args: argparse.Namespace, configuration: Con
|
||||
mocker.patch("ahriman.core.repository.repository.Repository.packages_depend_on", return_value=[])
|
||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
|
||||
|
||||
Rebuild.run(args, "x86_64", configuration, True, False)
|
||||
Rebuild.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
check_mock.assert_called_once_with(True, True)
|
||||
|
||||
|
||||
@ -137,8 +137,8 @@ def test_run_build_empty_exception(args: argparse.Namespace, configuration: Conf
|
||||
mocker.patch("ahriman.application.application.Application.update", return_value=Result())
|
||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
|
||||
|
||||
Rebuild.run(args, "x86_64", configuration, True, False)
|
||||
check_mock.assert_has_calls([mock.call(True, False), mock.call(True, True)])
|
||||
Rebuild.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
check_mock.assert_has_calls([MockCall(True, False), MockCall(True, True)])
|
||||
|
||||
|
||||
def test_extract_packages(application: Application, mocker: MockerFixture) -> None:
|
||||
|
@ -29,6 +29,6 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
||||
application_mock = mocker.patch("ahriman.application.application.Application.remove")
|
||||
on_start_mock = mocker.patch("ahriman.application.application.Application.on_start")
|
||||
|
||||
Remove.run(args, "x86_64", configuration, True, False)
|
||||
Remove.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
application_mock.assert_called_once_with([])
|
||||
on_start_mock.assert_called_once_with()
|
||||
|
@ -18,7 +18,6 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
|
||||
argparse.Namespace: generated arguments for these test cases
|
||||
"""
|
||||
args.dry_run = False
|
||||
args.info = False
|
||||
return args
|
||||
|
||||
|
||||
@ -34,7 +33,7 @@ def test_run(args: argparse.Namespace, package_ahriman: Package,
|
||||
remove_mock = mocker.patch("ahriman.application.application.Application.remove")
|
||||
on_start_mock = mocker.patch("ahriman.application.application.Application.on_start")
|
||||
|
||||
RemoveUnknown.run(args, "x86_64", configuration, True, False)
|
||||
RemoveUnknown.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
application_mock.assert_called_once_with()
|
||||
remove_mock.assert_called_once_with([package_ahriman])
|
||||
on_start_mock.assert_called_once_with()
|
||||
@ -53,27 +52,7 @@ def test_run_dry_run(args: argparse.Namespace, configuration: Configuration, pac
|
||||
remove_mock = mocker.patch("ahriman.application.application.Application.remove")
|
||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||
|
||||
RemoveUnknown.run(args, "x86_64", configuration, True, False)
|
||||
RemoveUnknown.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
application_mock.assert_called_once_with()
|
||||
remove_mock.assert_not_called()
|
||||
print_mock.assert_called_once_with(False)
|
||||
|
||||
|
||||
def test_run_dry_run_verbose(args: argparse.Namespace, configuration: Configuration, package_ahriman: Package,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must run simplified command with increased verbosity
|
||||
"""
|
||||
args = _default_args(args)
|
||||
args.dry_run = True
|
||||
args.info = True
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
application_mock = mocker.patch("ahriman.application.application.Application.unknown",
|
||||
return_value=[package_ahriman])
|
||||
remove_mock = mocker.patch("ahriman.application.application.Application.remove")
|
||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||
|
||||
RemoveUnknown.run(args, "x86_64", configuration, True, False)
|
||||
application_mock.assert_called_once_with()
|
||||
remove_mock.assert_not_called()
|
||||
print_mock.assert_called_once_with(True)
|
||||
|
@ -32,7 +32,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
||||
extract_mock = tarfile.__enter__.return_value = MagicMock()
|
||||
mocker.patch("tarfile.TarFile.__new__", return_value=tarfile)
|
||||
|
||||
Restore.run(args, "x86_64", configuration, True, False)
|
||||
Restore.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
extract_mock.extractall.assert_called_once_with(path=args.output)
|
||||
|
||||
|
||||
|
@ -3,11 +3,11 @@ import dataclasses
|
||||
import pytest
|
||||
|
||||
from pytest_mock import MockerFixture
|
||||
from unittest import mock
|
||||
from unittest.mock import call as MockCall
|
||||
|
||||
from ahriman.application.handlers import Search
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.exceptions import InvalidOption
|
||||
from ahriman.core.exceptions import OptionError
|
||||
from ahriman.models.aur_package import AURPackage
|
||||
|
||||
|
||||
@ -41,11 +41,11 @@ def test_run(args: argparse.Namespace, configuration: Configuration, aur_package
|
||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
|
||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||
|
||||
Search.run(args, "x86_64", configuration, True, False)
|
||||
Search.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
aur_search_mock.assert_called_once_with("ahriman", pacman=pytest.helpers.anyvar(int))
|
||||
official_search_mock.assert_called_once_with("ahriman", pacman=pytest.helpers.anyvar(int))
|
||||
check_mock.assert_called_once_with(False, False)
|
||||
print_mock.assert_has_calls([mock.call(False), mock.call(False)])
|
||||
print_mock.assert_has_calls([MockCall(False), MockCall(False)])
|
||||
|
||||
|
||||
def test_run_empty_exception(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
@ -60,7 +60,7 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
|
||||
|
||||
Search.run(args, "x86_64", configuration, True, False)
|
||||
Search.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
check_mock.assert_called_once_with(True, True)
|
||||
|
||||
|
||||
@ -75,10 +75,10 @@ def test_run_sort(args: argparse.Namespace, configuration: Configuration, aur_pa
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
sort_mock = mocker.patch("ahriman.application.handlers.Search.sort")
|
||||
|
||||
Search.run(args, "x86_64", configuration, True, False)
|
||||
Search.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
sort_mock.assert_has_calls([
|
||||
mock.call([], "name"), mock.call().__iter__(),
|
||||
mock.call([aur_package_ahriman], "name"), mock.call().__iter__()
|
||||
MockCall([], "name"), MockCall().__iter__(),
|
||||
MockCall([aur_package_ahriman], "name"), MockCall().__iter__()
|
||||
])
|
||||
|
||||
|
||||
@ -94,10 +94,10 @@ def test_run_sort_by(args: argparse.Namespace, configuration: Configuration, aur
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
sort_mock = mocker.patch("ahriman.application.handlers.Search.sort")
|
||||
|
||||
Search.run(args, "x86_64", configuration, True, False)
|
||||
Search.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
sort_mock.assert_has_calls([
|
||||
mock.call([], "field"), mock.call().__iter__(),
|
||||
mock.call([aur_package_ahriman], "field"), mock.call().__iter__()
|
||||
MockCall([], "field"), MockCall().__iter__(),
|
||||
MockCall([aur_package_ahriman], "field"), MockCall().__iter__()
|
||||
])
|
||||
|
||||
|
||||
@ -118,7 +118,7 @@ def test_sort_exception(aur_package_ahriman: AURPackage) -> None:
|
||||
"""
|
||||
must raise an exception on unknown sorting field
|
||||
"""
|
||||
with pytest.raises(InvalidOption):
|
||||
with pytest.raises(OptionError):
|
||||
Search.sort([aur_package_ahriman], "random_field")
|
||||
|
||||
|
||||
|
@ -4,7 +4,7 @@ import pytest
|
||||
from pathlib import Path
|
||||
from pytest_mock import MockerFixture
|
||||
from typing import Any
|
||||
from unittest import mock
|
||||
from unittest.mock import call as MockCall
|
||||
|
||||
from ahriman.application.handlers import Setup
|
||||
from ahriman.core.configuration import Configuration
|
||||
@ -25,7 +25,7 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
|
||||
args.build_as_user = "ahriman"
|
||||
args.build_command = "ahriman"
|
||||
args.from_configuration = Path("/usr/share/devtools/pacman-extra.conf")
|
||||
args.no_multilib = False
|
||||
args.multilib = True
|
||||
args.packager = "John Doe <john@doe.com>"
|
||||
args.repository = "aur-clone"
|
||||
args.sign_key = "key"
|
||||
@ -48,11 +48,11 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository_
|
||||
executable_mock = mocker.patch("ahriman.application.handlers.Setup.executable_create")
|
||||
init_mock = mocker.patch("ahriman.core.alpm.repo.Repo.init")
|
||||
|
||||
Setup.run(args, "x86_64", configuration, True, False)
|
||||
Setup.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
ahriman_configuration_mock.assert_called_once_with(
|
||||
args, "x86_64", args.repository, configuration.include, repository_paths)
|
||||
devtools_configuration_mock.assert_called_once_with(
|
||||
args.build_command, "x86_64", args.from_configuration, args.no_multilib, args.repository, repository_paths)
|
||||
args.build_command, "x86_64", args.from_configuration, args.multilib, args.repository, repository_paths)
|
||||
makepkg_configuration_mock.assert_called_once_with(args.packager, repository_paths)
|
||||
sudo_configuration_mock.assert_called_once_with(repository_paths, args.build_command, "x86_64")
|
||||
executable_mock.assert_called_once_with(repository_paths, args.build_command, "x86_64")
|
||||
@ -84,13 +84,13 @@ def test_configuration_create_ahriman(args: argparse.Namespace, configuration: C
|
||||
|
||||
Setup.configuration_create_ahriman(args, "x86_64", args.repository, configuration.include, repository_paths)
|
||||
set_option_mock.assert_has_calls([
|
||||
mock.call(Configuration.section_name("build", "x86_64"), "build_command", str(command)),
|
||||
mock.call("repository", "name", args.repository),
|
||||
mock.call(Configuration.section_name("build", "x86_64"), "makechrootpkg_flags", f"-U {args.build_as_user}"),
|
||||
mock.call(Configuration.section_name("sign", "x86_64"), "target",
|
||||
" ".join([target.name.lower() for target in args.sign_target])),
|
||||
mock.call(Configuration.section_name("sign", "x86_64"), "key", args.sign_key),
|
||||
mock.call(Configuration.section_name("web", "x86_64"), "port", str(args.web_port)),
|
||||
MockCall(Configuration.section_name("build", "x86_64"), "build_command", str(command)),
|
||||
MockCall("repository", "name", args.repository),
|
||||
MockCall(Configuration.section_name("build", "x86_64"), "makechrootpkg_flags", f"-U {args.build_as_user}"),
|
||||
MockCall(Configuration.section_name("sign", "x86_64"), "target",
|
||||
" ".join([target.name.lower() for target in args.sign_target])),
|
||||
MockCall(Configuration.section_name("sign", "x86_64"), "key", args.sign_key),
|
||||
MockCall(Configuration.section_name("web", "x86_64"), "port", str(args.web_port)),
|
||||
])
|
||||
write_mock.assert_called_once_with(pytest.helpers.anyvar(int))
|
||||
|
||||
@ -107,11 +107,8 @@ def test_configuration_create_devtools(args: argparse.Namespace, repository_path
|
||||
write_mock = mocker.patch("ahriman.core.configuration.Configuration.write")
|
||||
|
||||
Setup.configuration_create_devtools(args.build_command, "x86_64", args.from_configuration,
|
||||
args.no_multilib, args.repository, repository_paths)
|
||||
add_section_mock.assert_has_calls([
|
||||
mock.call("multilib"),
|
||||
mock.call(args.repository)
|
||||
])
|
||||
args.multilib, args.repository, repository_paths)
|
||||
add_section_mock.assert_has_calls([MockCall("multilib"), MockCall(args.repository)])
|
||||
write_mock.assert_called_once_with(pytest.helpers.anyvar(int))
|
||||
|
||||
|
||||
@ -126,7 +123,7 @@ def test_configuration_create_devtools_no_multilib(args: argparse.Namespace, rep
|
||||
write_mock = mocker.patch("ahriman.core.configuration.Configuration.write")
|
||||
|
||||
Setup.configuration_create_devtools(args.build_command, "x86_64", args.from_configuration,
|
||||
True, args.repository, repository_paths)
|
||||
False, args.repository, repository_paths)
|
||||
write_mock.assert_called_once_with(pytest.helpers.anyvar(int))
|
||||
|
||||
|
||||
|
@ -29,7 +29,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
application_mock = mocker.patch("code.interact")
|
||||
|
||||
Shell.run(args, "x86_64", configuration, True, False)
|
||||
Shell.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
application_mock.assert_called_once_with(local=pytest.helpers.anyvar(int))
|
||||
|
||||
|
||||
@ -43,6 +43,6 @@ def test_run_verbose(args: argparse.Namespace, configuration: Configuration, moc
|
||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||
application_mock = mocker.patch("code.interact")
|
||||
|
||||
Shell.run(args, "x86_64", configuration, True, False)
|
||||
Shell.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
application_mock.assert_called_once_with(local=pytest.helpers.anyvar(int))
|
||||
print_mock.assert_called_once_with(verbose=False)
|
||||
|
@ -28,5 +28,5 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
application_mock = mocker.patch("ahriman.application.application.Application.sign")
|
||||
|
||||
Sign.run(args, "x86_64", configuration, True, False)
|
||||
Sign.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
application_mock.assert_called_once_with([])
|
||||
|
@ -1,7 +1,7 @@
|
||||
import argparse
|
||||
|
||||
from pytest_mock import MockerFixture
|
||||
from unittest import mock
|
||||
from unittest.mock import call as MockCall
|
||||
|
||||
from ahriman.application.handlers import Status
|
||||
from ahriman.core.configuration import Configuration
|
||||
@ -41,11 +41,11 @@ def test_run(args: argparse.Namespace, configuration: Configuration, package_ahr
|
||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
|
||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||
|
||||
Status.run(args, "x86_64", configuration, True, False)
|
||||
Status.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
application_mock.assert_called_once_with()
|
||||
packages_mock.assert_called_once_with(None)
|
||||
check_mock.assert_called_once_with(False, False)
|
||||
print_mock.assert_has_calls([mock.call(False) for _ in range(3)])
|
||||
print_mock.assert_has_calls([MockCall(False) for _ in range(3)])
|
||||
|
||||
|
||||
def test_run_empty_exception(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
@ -59,7 +59,7 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat
|
||||
mocker.patch("ahriman.core.status.client.Client.get", return_value=[])
|
||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
|
||||
|
||||
Status.run(args, "x86_64", configuration, True, False)
|
||||
Status.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
check_mock.assert_called_once_with(True, True)
|
||||
|
||||
|
||||
@ -75,8 +75,8 @@ def test_run_verbose(args: argparse.Namespace, configuration: Configuration, pac
|
||||
return_value=[(package_ahriman, BuildStatus(BuildStatusEnum.Success))])
|
||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||
|
||||
Status.run(args, "x86_64", configuration, True, False)
|
||||
print_mock.assert_has_calls([mock.call(True) for _ in range(2)])
|
||||
Status.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
print_mock.assert_has_calls([MockCall(True) for _ in range(2)])
|
||||
|
||||
|
||||
def test_run_with_package_filter(args: argparse.Namespace, configuration: Configuration, package_ahriman: Package,
|
||||
@ -90,7 +90,7 @@ def test_run_with_package_filter(args: argparse.Namespace, configuration: Config
|
||||
packages_mock = mocker.patch("ahriman.core.status.client.Client.get",
|
||||
return_value=[(package_ahriman, BuildStatus(BuildStatusEnum.Success))])
|
||||
|
||||
Status.run(args, "x86_64", configuration, True, False)
|
||||
Status.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
packages_mock.assert_called_once_with(package_ahriman.base)
|
||||
|
||||
|
||||
@ -107,8 +107,8 @@ def test_run_by_status(args: argparse.Namespace, configuration: Configuration, p
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||
|
||||
Status.run(args, "x86_64", configuration, True, False)
|
||||
print_mock.assert_has_calls([mock.call(False) for _ in range(2)])
|
||||
Status.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
print_mock.assert_has_calls([MockCall(False) for _ in range(2)])
|
||||
|
||||
|
||||
def test_imply_with_report(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
@ -119,7 +119,7 @@ def test_imply_with_report(args: argparse.Namespace, configuration: Configuratio
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
load_mock = mocker.patch("ahriman.core.status.client.Client.load")
|
||||
|
||||
Status.run(args, "x86_64", configuration, True, False)
|
||||
Status.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
load_mock.assert_called_once_with(configuration)
|
||||
|
||||
|
||||
|
@ -33,7 +33,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
update_self_mock = mocker.patch("ahriman.core.status.client.Client.update_self")
|
||||
|
||||
StatusUpdate.run(args, "x86_64", configuration, True, False)
|
||||
StatusUpdate.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
update_self_mock.assert_called_once_with(args.status)
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ def test_run_packages(args: argparse.Namespace, configuration: Configuration, pa
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
update_mock = mocker.patch("ahriman.core.status.client.Client.update")
|
||||
|
||||
StatusUpdate.run(args, "x86_64", configuration, True, False)
|
||||
StatusUpdate.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
update_mock.assert_called_once_with(package_ahriman.base, args.status)
|
||||
|
||||
|
||||
@ -62,7 +62,7 @@ def test_run_remove(args: argparse.Namespace, configuration: Configuration, pack
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
update_mock = mocker.patch("ahriman.core.status.client.Client.remove")
|
||||
|
||||
StatusUpdate.run(args, "x86_64", configuration, True, False)
|
||||
StatusUpdate.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
update_mock.assert_called_once_with(package_ahriman.base)
|
||||
|
||||
|
||||
@ -74,7 +74,7 @@ def test_imply_with_report(args: argparse.Namespace, configuration: Configuratio
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
load_mock = mocker.patch("ahriman.core.status.client.Client.load")
|
||||
|
||||
StatusUpdate.run(args, "x86_64", configuration, True, False)
|
||||
StatusUpdate.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
load_mock.assert_called_once_with(configuration)
|
||||
|
||||
|
||||
|
@ -31,7 +31,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
||||
application_mock = mocker.patch("ahriman.application.application.Application.on_result")
|
||||
on_start_mock = mocker.patch("ahriman.application.application.Application.on_start")
|
||||
|
||||
Triggers.run(args, "x86_64", configuration, True, False)
|
||||
Triggers.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
application_mock.assert_called_once_with(Result())
|
||||
on_start_mock.assert_called_once_with()
|
||||
|
||||
@ -48,6 +48,6 @@ def test_run_trigger(args: argparse.Namespace, configuration: Configuration, pac
|
||||
report_mock = mocker.patch("ahriman.core.report.ReportTrigger.on_result")
|
||||
upload_mock = mocker.patch("ahriman.core.upload.UploadTrigger.on_result")
|
||||
|
||||
Triggers.run(args, "x86_64", configuration, True, False)
|
||||
Triggers.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
report_mock.assert_called_once_with(Result(), [package_ahriman])
|
||||
upload_mock.assert_not_called()
|
||||
|
@ -32,7 +32,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
||||
return_value=["command"])
|
||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||
|
||||
UnsafeCommands.run(args, "x86_64", configuration, True, False)
|
||||
UnsafeCommands.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
commands_mock.assert_called_once_with(pytest.helpers.anyvar(int))
|
||||
print_mock.assert_called_once_with(verbose=True)
|
||||
|
||||
@ -47,7 +47,7 @@ def test_run_check(args: argparse.Namespace, configuration: Configuration, mocke
|
||||
return_value=["command"])
|
||||
check_mock = mocker.patch("ahriman.application.handlers.UnsafeCommands.check_unsafe")
|
||||
|
||||
UnsafeCommands.run(args, "x86_64", configuration, True, False)
|
||||
UnsafeCommands.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
commands_mock.assert_called_once_with(pytest.helpers.anyvar(int))
|
||||
check_mock.assert_called_once_with("clean", ["command"], pytest.helpers.anyvar(int))
|
||||
|
||||
|
@ -2,7 +2,7 @@ import argparse
|
||||
import pytest
|
||||
|
||||
from pytest_mock import MockerFixture
|
||||
from unittest import mock
|
||||
from unittest.mock import call as MockCall
|
||||
|
||||
from ahriman.application.application import Application
|
||||
from ahriman.application.handlers import Update
|
||||
@ -24,10 +24,10 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
|
||||
args.package = []
|
||||
args.dry_run = False
|
||||
args.exit_code = False
|
||||
args.no_aur = False
|
||||
args.no_local = False
|
||||
args.no_manual = False
|
||||
args.no_vcs = False
|
||||
args.aur = True
|
||||
args.local = True
|
||||
args.manual = True
|
||||
args.vcs = True
|
||||
args.refresh = 0
|
||||
return args
|
||||
|
||||
@ -46,11 +46,11 @@ def test_run(args: argparse.Namespace, package_ahriman: Package,
|
||||
updates_mock = mocker.patch("ahriman.application.application.Application.updates", return_value=[package_ahriman])
|
||||
on_start_mock = mocker.patch("ahriman.application.application.Application.on_start")
|
||||
|
||||
Update.run(args, "x86_64", configuration, True, False)
|
||||
Update.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
application_mock.assert_called_once_with([package_ahriman])
|
||||
updates_mock.assert_called_once_with(args.package, args.no_aur, args.no_local, args.no_manual, args.no_vcs,
|
||||
pytest.helpers.anyvar(int))
|
||||
check_mock.assert_has_calls([mock.call(False, False), mock.call(False, False)])
|
||||
updates_mock.assert_called_once_with(args.package, aur=args.aur, local=args.local, manual=args.manual, vcs=args.vcs,
|
||||
log_fn=pytest.helpers.anyvar(int))
|
||||
check_mock.assert_has_calls([MockCall(False, False), MockCall(False, False)])
|
||||
on_start_mock.assert_called_once_with()
|
||||
|
||||
|
||||
@ -65,7 +65,7 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat
|
||||
mocker.patch("ahriman.application.application.Application.updates", return_value=[])
|
||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
|
||||
|
||||
Update.run(args, "x86_64", configuration, True, False)
|
||||
Update.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
check_mock.assert_called_once_with(True, True)
|
||||
|
||||
|
||||
@ -81,8 +81,8 @@ def test_run_update_empty_exception(args: argparse.Namespace, package_ahriman: P
|
||||
mocker.patch("ahriman.application.application.Application.updates", return_value=[package_ahriman])
|
||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
|
||||
|
||||
Update.run(args, "x86_64", configuration, True, False)
|
||||
check_mock.assert_has_calls([mock.call(True, False), mock.call(True, True)])
|
||||
Update.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
check_mock.assert_has_calls([MockCall(True, False), MockCall(True, True)])
|
||||
|
||||
|
||||
def test_run_dry_run(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
@ -96,9 +96,9 @@ def test_run_dry_run(args: argparse.Namespace, configuration: Configuration, moc
|
||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
|
||||
updates_mock = mocker.patch("ahriman.application.application.Application.updates")
|
||||
|
||||
Update.run(args, "x86_64", configuration, True, False)
|
||||
updates_mock.assert_called_once_with(args.package, args.no_aur, args.no_local, args.no_manual, args.no_vcs,
|
||||
pytest.helpers.anyvar(int))
|
||||
Update.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
updates_mock.assert_called_once_with(args.package, aur=args.aur, local=args.local, manual=args.manual, vcs=args.vcs,
|
||||
log_fn=pytest.helpers.anyvar(int))
|
||||
application_mock.assert_not_called()
|
||||
check_mock.assert_called_once_with(False, pytest.helpers.anyvar(int))
|
||||
|
||||
@ -109,4 +109,4 @@ def test_log_fn(application: Application, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
logger_mock = mocker.patch("logging.Logger.info")
|
||||
Update.log_fn(application, False)("hello")
|
||||
logger_mock.assert_has_calls([mock.call("hello")])
|
||||
logger_mock.assert_has_calls([MockCall("hello")])
|
||||
|
@ -7,7 +7,7 @@ from pytest_mock import MockerFixture
|
||||
from ahriman.application.handlers import Users
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.database import SQLite
|
||||
from ahriman.core.exceptions import InitializeException
|
||||
from ahriman.core.exceptions import InitializeError
|
||||
from ahriman.models.action import Action
|
||||
from ahriman.models.user import User
|
||||
from ahriman.models.user_access import UserAccess
|
||||
@ -47,7 +47,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, database: S
|
||||
get_salt_mock = mocker.patch("ahriman.application.handlers.Users.get_salt", return_value="salt")
|
||||
update_mock = mocker.patch("ahriman.core.database.SQLite.user_update")
|
||||
|
||||
Users.run(args, "x86_64", configuration, True, False)
|
||||
Users.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
get_auth_configuration_mock.assert_called_once_with(configuration.include)
|
||||
create_configuration_mock.assert_called_once_with(pytest.helpers.anyvar(int), pytest.helpers.anyvar(int),
|
||||
pytest.helpers.anyvar(int), args.as_service, args.secure)
|
||||
@ -67,7 +67,7 @@ def test_run_list(args: argparse.Namespace, configuration: Configuration, databa
|
||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
|
||||
list_mock = mocker.patch("ahriman.core.database.SQLite.user_list", return_value=[user])
|
||||
|
||||
Users.run(args, "x86_64", configuration, True, False)
|
||||
Users.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
list_mock.assert_called_once_with("user", args.role)
|
||||
check_mock.assert_called_once_with(False, False)
|
||||
|
||||
@ -84,7 +84,7 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat
|
||||
mocker.patch("ahriman.core.database.SQLite.user_list", return_value=[])
|
||||
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
|
||||
|
||||
Users.run(args, "x86_64", configuration, True, False)
|
||||
Users.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
check_mock.assert_called_once_with(True, True)
|
||||
|
||||
|
||||
@ -98,7 +98,7 @@ def test_run_remove(args: argparse.Namespace, configuration: Configuration, data
|
||||
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
|
||||
remove_mock = mocker.patch("ahriman.core.database.SQLite.user_remove")
|
||||
|
||||
Users.run(args, "x86_64", configuration, True, False)
|
||||
Users.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
remove_mock.assert_called_once_with(args.username)
|
||||
|
||||
|
||||
@ -176,7 +176,7 @@ def test_configuration_write_not_loaded(configuration: Configuration, mocker: Mo
|
||||
configuration.path = None
|
||||
mocker.patch("pathlib.Path.open")
|
||||
|
||||
with pytest.raises(InitializeException):
|
||||
with pytest.raises(InitializeError):
|
||||
Users.configuration_write(configuration, secure=True)
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import argparse
|
||||
|
||||
from pytest_mock import MockerFixture
|
||||
from unittest import mock
|
||||
from unittest.mock import call as MockCall
|
||||
|
||||
from ahriman.application.handlers import Versions
|
||||
from ahriman.core.configuration import Configuration
|
||||
@ -14,9 +14,9 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
||||
application_mock = mocker.patch("ahriman.application.handlers.Versions.package_dependencies")
|
||||
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
||||
|
||||
Versions.run(args, "x86_64", configuration, True, False)
|
||||
Versions.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
application_mock.assert_called_once_with("ahriman", ("pacman", "s3", "web"))
|
||||
print_mock.assert_has_calls([mock.call(verbose=False, separator=" "), mock.call(verbose=False, separator=" ")])
|
||||
print_mock.assert_has_calls([MockCall(verbose=False, separator=" "), MockCall(verbose=False, separator=" ")])
|
||||
|
||||
|
||||
def test_package_dependencies() -> None:
|
||||
|
@ -31,7 +31,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
||||
setup_mock = mocker.patch("ahriman.web.web.setup_service")
|
||||
run_mock = mocker.patch("ahriman.web.web.run_server")
|
||||
|
||||
Web.run(args, "x86_64", configuration, True, False)
|
||||
Web.run(args, "x86_64", configuration, report=False, unsafe=False)
|
||||
setup_mock.assert_called_once_with("x86_64", configuration, pytest.helpers.anyvar(int))
|
||||
run_mock.assert_called_once_with(pytest.helpers.anyvar(int))
|
||||
|
||||
|
@ -47,12 +47,12 @@ def test_multiple_architectures(parser: argparse.ArgumentParser) -> None:
|
||||
|
||||
def test_subparsers_aur_search(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
aur-search command must imply architecture list, lock, no-report, quiet and unsafe
|
||||
aur-search command must imply architecture list, lock, report, quiet and unsafe
|
||||
"""
|
||||
args = parser.parse_args(["aur-search", "ahriman"])
|
||||
assert args.architecture == [""]
|
||||
assert args.lock is None
|
||||
assert args.no_report
|
||||
assert not args.report
|
||||
assert args.quiet
|
||||
assert args.unsafe
|
||||
|
||||
@ -99,12 +99,12 @@ def test_subparsers_daemon_option_interval(parser: argparse.ArgumentParser) -> N
|
||||
|
||||
def test_subparsers_help(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
help command must imply architecture list, lock, no-report, quiet, unsafe and parser
|
||||
help command must imply architecture list, lock, report, quiet, unsafe and parser
|
||||
"""
|
||||
args = parser.parse_args(["help"])
|
||||
assert args.architecture == [""]
|
||||
assert args.lock is None
|
||||
assert args.no_report
|
||||
assert not args.report
|
||||
assert args.quiet
|
||||
assert args.unsafe
|
||||
assert args.parser is not None and args.parser()
|
||||
@ -120,12 +120,12 @@ def test_subparsers_help_architecture(parser: argparse.ArgumentParser) -> None:
|
||||
|
||||
def test_subparsers_help_commands_unsafe(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
help-commands-unsafe command must imply architecture list, lock, no-report, quiet, unsafe and parser
|
||||
help-commands-unsafe command must imply architecture list, lock, report, quiet, unsafe and parser
|
||||
"""
|
||||
args = parser.parse_args(["help-commands-unsafe"])
|
||||
assert args.architecture == [""]
|
||||
assert args.lock is None
|
||||
assert args.no_report
|
||||
assert not args.report
|
||||
assert args.quiet
|
||||
assert args.unsafe
|
||||
assert args.parser is not None and args.parser()
|
||||
@ -141,12 +141,12 @@ def test_subparsers_help_commands_unsafe_architecture(parser: argparse.ArgumentP
|
||||
|
||||
def test_subparsers_key_import(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
key-import command must imply architecture list, lock and no-report
|
||||
key-import command must imply architecture list, lock and report
|
||||
"""
|
||||
args = parser.parse_args(["key-import", "key"])
|
||||
assert args.architecture == [""]
|
||||
assert args.lock is None
|
||||
assert args.no_report
|
||||
assert not args.report
|
||||
|
||||
|
||||
def test_subparsers_key_import_architecture(parser: argparse.ArgumentParser) -> None:
|
||||
@ -191,38 +191,38 @@ def test_subparsers_package_remove_architecture(parser: argparse.ArgumentParser)
|
||||
|
||||
def test_subparsers_package_status(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
package-status command must imply lock, no-report, quiet and unsafe
|
||||
package-status command must imply lock, report, quiet and unsafe
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "package-status"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
assert args.lock is None
|
||||
assert args.no_report
|
||||
assert not args.report
|
||||
assert args.quiet
|
||||
assert args.unsafe
|
||||
|
||||
|
||||
def test_subparsers_package_status_remove(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
package-status-remove command must imply action, lock, no-report, quiet and unsafe
|
||||
package-status-remove command must imply action, lock, report, quiet and unsafe
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "package-status-remove", "ahriman"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
assert args.action == Action.Remove
|
||||
assert args.lock is None
|
||||
assert args.no_report
|
||||
assert not args.report
|
||||
assert args.quiet
|
||||
assert args.unsafe
|
||||
|
||||
|
||||
def test_subparsers_package_status_update(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
package-status-update command must imply action, lock, no-report, quiet and unsafe
|
||||
package-status-update command must imply action, lock, report, quiet and unsafe
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "package-status-update"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
assert args.action == Action.Update
|
||||
assert args.lock is None
|
||||
assert args.no_report
|
||||
assert not args.report
|
||||
assert args.quiet
|
||||
assert args.unsafe
|
||||
|
||||
@ -239,13 +239,13 @@ def test_subparsers_package_status_update_option_status(parser: argparse.Argumen
|
||||
|
||||
def test_subparsers_patch_add(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
patch-add command must imply action, architecture list, lock and no-report
|
||||
patch-add command must imply action, architecture list, lock and report
|
||||
"""
|
||||
args = parser.parse_args(["patch-add", "ahriman", "version"])
|
||||
assert args.action == Action.Update
|
||||
assert args.architecture == [""]
|
||||
assert args.lock is None
|
||||
assert args.no_report
|
||||
assert not args.report
|
||||
|
||||
|
||||
def test_subparsers_patch_add_architecture(parser: argparse.ArgumentParser) -> None:
|
||||
@ -258,13 +258,13 @@ def test_subparsers_patch_add_architecture(parser: argparse.ArgumentParser) -> N
|
||||
|
||||
def test_subparsers_patch_list(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
patch-list command must imply action, architecture list, lock and no-report
|
||||
patch-list command must imply action, architecture list, lock and report
|
||||
"""
|
||||
args = parser.parse_args(["patch-list", "ahriman"])
|
||||
assert args.action == Action.List
|
||||
assert args.architecture == [""]
|
||||
assert args.lock is None
|
||||
assert args.no_report
|
||||
assert not args.report
|
||||
|
||||
|
||||
def test_subparsers_patch_list_architecture(parser: argparse.ArgumentParser) -> None:
|
||||
@ -277,13 +277,13 @@ def test_subparsers_patch_list_architecture(parser: argparse.ArgumentParser) ->
|
||||
|
||||
def test_subparsers_patch_remove(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
patch-remove command must imply action, architecture list, lock and no-report
|
||||
patch-remove command must imply action, architecture list, lock and report
|
||||
"""
|
||||
args = parser.parse_args(["patch-remove", "ahriman"])
|
||||
assert args.action == Action.Remove
|
||||
assert args.architecture == [""]
|
||||
assert args.lock is None
|
||||
assert args.no_report
|
||||
assert not args.report
|
||||
|
||||
|
||||
def test_subparsers_patch_remove_architecture(parser: argparse.ArgumentParser) -> None:
|
||||
@ -296,13 +296,13 @@ def test_subparsers_patch_remove_architecture(parser: argparse.ArgumentParser) -
|
||||
|
||||
def test_subparsers_patch_set_add(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
patch-set-add command must imply action, architecture list, lock, no-report and variable
|
||||
patch-set-add command must imply action, architecture list, lock, report and variable
|
||||
"""
|
||||
args = parser.parse_args(["patch-set-add", "ahriman"])
|
||||
assert args.action == Action.Update
|
||||
assert args.architecture == [""]
|
||||
assert args.lock is None
|
||||
assert args.no_report
|
||||
assert not args.report
|
||||
assert args.variable is None
|
||||
|
||||
|
||||
@ -332,12 +332,12 @@ def test_subparsers_patch_set_add_option_track(parser: argparse.ArgumentParser)
|
||||
|
||||
def test_subparsers_repo_backup(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
repo-backup command must imply architecture list, lock, no-report and unsafe
|
||||
repo-backup command must imply architecture list, lock, report and unsafe
|
||||
"""
|
||||
args = parser.parse_args(["repo-backup", "output.zip"])
|
||||
assert args.architecture == [""]
|
||||
assert args.lock is None
|
||||
assert args.no_report
|
||||
assert not args.report
|
||||
assert args.unsafe
|
||||
|
||||
|
||||
@ -351,12 +351,12 @@ def test_subparsers_repo_backup_architecture(parser: argparse.ArgumentParser) ->
|
||||
|
||||
def test_subparsers_repo_check(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
repo-check command must imply dry-run, no-aur and no-manual
|
||||
repo-check command must imply dry-run, aur and manual
|
||||
"""
|
||||
args = parser.parse_args(["repo-check"])
|
||||
assert args.dry_run
|
||||
assert not args.no_aur
|
||||
assert args.no_manual
|
||||
assert args.aur
|
||||
assert not args.manual
|
||||
|
||||
|
||||
def test_subparsers_repo_check_architecture(parser: argparse.ArgumentParser) -> None:
|
||||
@ -402,12 +402,12 @@ def test_subparsers_repo_clean_architecture(parser: argparse.ArgumentParser) ->
|
||||
|
||||
def test_subparsers_repo_config(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
repo-config command must imply lock, no-report, quiet and unsafe
|
||||
repo-config command must imply lock, report, quiet and unsafe
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "repo-config"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
assert args.lock is None
|
||||
assert args.no_report
|
||||
assert not args.report
|
||||
assert args.quiet
|
||||
assert args.unsafe
|
||||
|
||||
@ -452,12 +452,12 @@ def test_subparsers_repo_report_architecture(parser: argparse.ArgumentParser) ->
|
||||
|
||||
def test_subparsers_repo_restore(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
repo-restore command must imply architecture list, lock, no-report and unsafe
|
||||
repo-restore command must imply architecture list, lock, report and unsafe
|
||||
"""
|
||||
args = parser.parse_args(["repo-restore", "output.zip"])
|
||||
assert args.architecture == [""]
|
||||
assert args.lock is None
|
||||
assert args.no_report
|
||||
assert not args.report
|
||||
assert args.unsafe
|
||||
|
||||
|
||||
@ -471,13 +471,13 @@ def test_subparsers_repo_restore_architecture(parser: argparse.ArgumentParser) -
|
||||
|
||||
def test_subparsers_repo_setup(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
repo-setup command must imply lock, no-report, quiet and unsafe
|
||||
repo-setup command must imply lock, report, quiet and unsafe
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "repo-setup", "--packager", "John Doe <john@doe.com>",
|
||||
"--repository", "aur-clone"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
assert args.lock is None
|
||||
assert args.no_report
|
||||
assert not args.report
|
||||
assert args.quiet
|
||||
assert args.unsafe
|
||||
|
||||
@ -516,13 +516,13 @@ def test_subparsers_repo_sign_architecture(parser: argparse.ArgumentParser) -> N
|
||||
|
||||
def test_subparsers_repo_status_update(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
re[p-status-update command must imply action, lock, no-report, package, quiet and unsafe
|
||||
re[p-status-update command must imply action, lock, report, package, quiet and unsafe
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "package-status-update"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
assert args.action == Action.Update
|
||||
assert args.lock is None
|
||||
assert args.no_report
|
||||
assert not args.report
|
||||
assert not args.package
|
||||
assert args.quiet
|
||||
assert args.unsafe
|
||||
@ -590,22 +590,22 @@ def test_subparsers_repo_update_option_refresh(parser: argparse.ArgumentParser)
|
||||
|
||||
def test_subparsers_shell(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
shell command must imply lock and no-report
|
||||
shell command must imply lock and report
|
||||
"""
|
||||
args = parser.parse_args(["shell"])
|
||||
assert args.lock is None
|
||||
assert args.no_report
|
||||
assert not args.report
|
||||
|
||||
|
||||
def test_subparsers_user_add(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
user-add command must imply action, architecture, lock, no-report, quiet and unsafe
|
||||
user-add command must imply action, architecture, lock, report, quiet and unsafe
|
||||
"""
|
||||
args = parser.parse_args(["user-add", "username"])
|
||||
assert args.action == Action.Update
|
||||
assert args.architecture == [""]
|
||||
assert args.lock is None
|
||||
assert args.no_report
|
||||
assert not args.report
|
||||
assert args.quiet
|
||||
assert args.unsafe
|
||||
|
||||
@ -630,13 +630,13 @@ def test_subparsers_user_add_option_role(parser: argparse.ArgumentParser) -> Non
|
||||
|
||||
def test_subparsers_user_list(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
user-list command must imply action, architecture, lock, no-report, password, quiet and unsafe
|
||||
user-list command must imply action, architecture, lock, report, password, quiet and unsafe
|
||||
"""
|
||||
args = parser.parse_args(["user-list"])
|
||||
assert args.action == Action.List
|
||||
assert args.architecture == [""]
|
||||
assert args.lock is None
|
||||
assert args.no_report
|
||||
assert not args.report
|
||||
assert args.password is not None
|
||||
assert args.quiet
|
||||
assert args.unsafe
|
||||
@ -660,13 +660,13 @@ def test_subparsers_user_list_option_role(parser: argparse.ArgumentParser) -> No
|
||||
|
||||
def test_subparsers_user_remove(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
user-remove command must imply action, architecture, lock, no-report, password, quiet, role and unsafe
|
||||
user-remove command must imply action, architecture, lock, report, password, quiet, role and unsafe
|
||||
"""
|
||||
args = parser.parse_args(["user-remove", "username"])
|
||||
assert args.action == Action.Remove
|
||||
assert args.architecture == [""]
|
||||
assert args.lock is None
|
||||
assert args.no_report
|
||||
assert not args.report
|
||||
assert args.password is not None
|
||||
assert args.quiet
|
||||
assert args.unsafe
|
||||
@ -682,12 +682,12 @@ def test_subparsers_user_remove_architecture(parser: argparse.ArgumentParser) ->
|
||||
|
||||
def test_subparsers_version(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
version command must imply architecture, lock, no-report, quiet and unsafe
|
||||
version command must imply architecture, lock, report, quiet and unsafe
|
||||
"""
|
||||
args = parser.parse_args(["version"])
|
||||
assert args.architecture == [""]
|
||||
assert args.lock is None
|
||||
assert args.no_report
|
||||
assert not args.report
|
||||
assert args.quiet
|
||||
assert args.unsafe
|
||||
|
||||
@ -702,12 +702,12 @@ def test_subparsers_version_architecture(parser: argparse.ArgumentParser) -> Non
|
||||
|
||||
def test_subparsers_web(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
web command must imply lock, no_report and parser
|
||||
web command must imply lock, report and parser
|
||||
"""
|
||||
args = parser.parse_args(["-a", "x86_64", "web"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
assert args.lock is None
|
||||
assert args.no_report
|
||||
assert not args.report
|
||||
assert args.parser is not None and args.parser()
|
||||
|
||||
|
||||
|
@ -3,11 +3,11 @@ import tempfile
|
||||
|
||||
from pathlib import Path
|
||||
from pytest_mock import MockerFixture
|
||||
from unittest import mock
|
||||
from unittest.mock import call as MockCall
|
||||
|
||||
from ahriman import version
|
||||
from ahriman.application.lock import Lock
|
||||
from ahriman.core.exceptions import DuplicateRun, UnsafeRun
|
||||
from ahriman.core.exceptions import DuplicateRunError, UnsafeRunError
|
||||
from ahriman.models.build_status import BuildStatus, BuildStatusEnum
|
||||
from ahriman.models.internal_status import InternalStatus
|
||||
|
||||
@ -28,10 +28,7 @@ def test_enter(lock: Lock, mocker: MockerFixture) -> None:
|
||||
clear_mock.assert_called_once_with()
|
||||
create_mock.assert_called_once_with()
|
||||
check_version_mock.assert_called_once_with()
|
||||
update_status_mock.assert_has_calls([
|
||||
mock.call(BuildStatusEnum.Building),
|
||||
mock.call(BuildStatusEnum.Success)
|
||||
])
|
||||
update_status_mock.assert_has_calls([MockCall(BuildStatusEnum.Building), MockCall(BuildStatusEnum.Success)])
|
||||
|
||||
|
||||
def test_exit_with_exception(lock: Lock, mocker: MockerFixture) -> None:
|
||||
@ -46,10 +43,7 @@ def test_exit_with_exception(lock: Lock, mocker: MockerFixture) -> None:
|
||||
with pytest.raises(Exception):
|
||||
with lock:
|
||||
raise Exception()
|
||||
update_status_mock.assert_has_calls([
|
||||
mock.call(BuildStatusEnum.Building),
|
||||
mock.call(BuildStatusEnum.Failed)
|
||||
])
|
||||
update_status_mock.assert_has_calls([MockCall(BuildStatusEnum.Building), MockCall(BuildStatusEnum.Failed)])
|
||||
|
||||
|
||||
def test_check_version(lock: Lock, mocker: MockerFixture) -> None:
|
||||
@ -82,15 +76,15 @@ def test_check_user(lock: Lock, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
check_user_patch = mocker.patch("ahriman.application.lock.check_user")
|
||||
lock.check_user()
|
||||
check_user_patch.assert_called_once_with(lock.paths, False)
|
||||
check_user_patch.assert_called_once_with(lock.paths, unsafe=False)
|
||||
|
||||
|
||||
def test_check_user_exception(lock: Lock, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must raise exception if user differs
|
||||
"""
|
||||
mocker.patch("ahriman.application.lock.check_user", side_effect=UnsafeRun(0, 1))
|
||||
with pytest.raises(UnsafeRun):
|
||||
mocker.patch("ahriman.application.lock.check_user", side_effect=UnsafeRunError(0, 1))
|
||||
with pytest.raises(UnsafeRunError):
|
||||
lock.check_user()
|
||||
|
||||
|
||||
@ -148,7 +142,7 @@ def test_create_exception(lock: Lock) -> None:
|
||||
lock.path = Path(tempfile.mktemp()) # nosec
|
||||
lock.path.touch()
|
||||
|
||||
with pytest.raises(DuplicateRun):
|
||||
with pytest.raises(DuplicateRunError):
|
||||
lock.create()
|
||||
lock.path.unlink()
|
||||
|
||||
|
@ -8,7 +8,7 @@ from unittest.mock import MagicMock
|
||||
|
||||
from ahriman.core.alpm.pacman import Pacman
|
||||
from ahriman.core.alpm.remote import AUR
|
||||
from ahriman.core.exceptions import InvalidPackageInfo
|
||||
from ahriman.core.exceptions import PackageInfoError, UnknownPackageError
|
||||
from ahriman.models.aur_package import AURPackage
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ def test_parse_response_error(resource_path_root: Path) -> None:
|
||||
must raise exception on invalid response
|
||||
"""
|
||||
response = (resource_path_root / "models" / "aur_error").read_text()
|
||||
with pytest.raises(InvalidPackageInfo, match="Incorrect request type specified."):
|
||||
with pytest.raises(PackageInfoError, match="Incorrect request type specified."):
|
||||
AUR.parse_response(json.loads(response))
|
||||
|
||||
|
||||
@ -46,7 +46,7 @@ def test_parse_response_unknown_error() -> None:
|
||||
"""
|
||||
must raise exception on invalid response with empty error message
|
||||
"""
|
||||
with pytest.raises(InvalidPackageInfo, match="Unknown API error"):
|
||||
with pytest.raises(PackageInfoError, match="Unknown API error"):
|
||||
AUR.parse_response({"type": "error"})
|
||||
|
||||
|
||||
@ -142,6 +142,16 @@ def test_package_info(aur: AUR, aur_package_ahriman: AURPackage, pacman: Pacman,
|
||||
request_mock.assert_called_once_with("info", aur_package_ahriman.name)
|
||||
|
||||
|
||||
def test_package_info_not_found(aur: AUR, aur_package_ahriman: AURPackage, pacman: Pacman,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must raise UnknownPackage exception in case if no package was found
|
||||
"""
|
||||
mocker.patch("ahriman.core.alpm.remote.AUR.make_request", return_value=[])
|
||||
with pytest.raises(UnknownPackageError, match=aur_package_ahriman.name):
|
||||
assert aur.package_info(aur_package_ahriman.name, pacman=pacman)
|
||||
|
||||
|
||||
def test_package_search(aur: AUR, aur_package_ahriman: AURPackage, pacman: Pacman, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must make request for search
|
||||
|
@ -8,7 +8,7 @@ from unittest.mock import MagicMock
|
||||
|
||||
from ahriman.core.alpm.pacman import Pacman
|
||||
from ahriman.core.alpm.remote import Official
|
||||
from ahriman.core.exceptions import InvalidPackageInfo
|
||||
from ahriman.core.exceptions import PackageInfoError, UnknownPackageError
|
||||
from ahriman.models.aur_package import AURPackage
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ def test_parse_response_unknown_error(resource_path_root: Path) -> None:
|
||||
must raise exception on invalid response with empty error message
|
||||
"""
|
||||
response = (resource_path_root / "models" / "official_error").read_text()
|
||||
with pytest.raises(InvalidPackageInfo, match="API validation error"):
|
||||
with pytest.raises(PackageInfoError, match="API validation error"):
|
||||
Official.parse_response(json.loads(response))
|
||||
|
||||
|
||||
@ -119,6 +119,16 @@ def test_package_info(official: Official, aur_package_akonadi: AURPackage, pacma
|
||||
request_mock.assert_called_once_with(aur_package_akonadi.name, by="name")
|
||||
|
||||
|
||||
def test_package_info_not_found(official: Official, aur_package_ahriman: AURPackage, pacman: Pacman,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must raise UnknownPackage exception in case if no package was found
|
||||
"""
|
||||
mocker.patch("ahriman.core.alpm.remote.Official.make_request", return_value=[])
|
||||
with pytest.raises(UnknownPackageError, match=aur_package_ahriman.name):
|
||||
assert official.package_info(aur_package_ahriman.name, pacman=pacman)
|
||||
|
||||
|
||||
def test_package_search(official: Official, aur_package_akonadi: AURPackage, pacman: Pacman,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
|
@ -1,12 +1,15 @@
|
||||
import pytest
|
||||
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.core.alpm.pacman import Pacman
|
||||
from ahriman.core.alpm.remote import OfficialSyncdb
|
||||
from ahriman.core.exceptions import UnknownPackageError
|
||||
from ahriman.models.aur_package import AURPackage
|
||||
|
||||
|
||||
def test_package_info(official_syncdb: OfficialSyncdb, aur_package_akonadi: AURPackage,
|
||||
pacman: Pacman, mocker: MockerFixture) -> None:
|
||||
def test_package_info(official_syncdb: OfficialSyncdb, aur_package_akonadi: AURPackage, pacman: Pacman,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must return package info from the database
|
||||
"""
|
||||
@ -16,3 +19,13 @@ def test_package_info(official_syncdb: OfficialSyncdb, aur_package_akonadi: AURP
|
||||
package = official_syncdb.package_info(aur_package_akonadi.name, pacman=pacman)
|
||||
get_mock.assert_called_once_with(aur_package_akonadi.name)
|
||||
assert package == aur_package_akonadi
|
||||
|
||||
|
||||
def test_package_info_not_found(official_syncdb: OfficialSyncdb, aur_package_akonadi: AURPackage, pacman: Pacman,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must raise UnknownPackage exception in case if no package was found
|
||||
"""
|
||||
mocker.patch("ahriman.core.alpm.pacman.Pacman.package_get", return_value=[])
|
||||
with pytest.raises(UnknownPackageError, match=aur_package_akonadi.name):
|
||||
assert official_syncdb.package_info(aur_package_akonadi.name, pacman=pacman)
|
||||
|
@ -1,7 +1,7 @@
|
||||
import pytest
|
||||
|
||||
from pytest_mock import MockerFixture
|
||||
from unittest import mock
|
||||
from unittest.mock import call as MockCall
|
||||
|
||||
from ahriman.core.alpm.pacman import Pacman
|
||||
from ahriman.core.alpm.remote import Remote
|
||||
@ -25,7 +25,7 @@ def test_multisearch(aur_package_ahriman: AURPackage, pacman: Pacman, mocker: Mo
|
||||
search_mock = mocker.patch("ahriman.core.alpm.remote.Remote.search", return_value=[aur_package_ahriman])
|
||||
|
||||
assert Remote.multisearch(*terms, pacman=pacman) == [aur_package_ahriman]
|
||||
search_mock.assert_has_calls([mock.call("ahriman", pacman=pacman), mock.call("cool", pacman=pacman)])
|
||||
search_mock.assert_has_calls([MockCall("ahriman", pacman=pacman), MockCall("cool", pacman=pacman)])
|
||||
|
||||
|
||||
def test_multisearch_empty(pacman: Pacman, mocker: MockerFixture) -> None:
|
||||
|
@ -4,7 +4,7 @@ import pytest
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.core.auth import OAuth
|
||||
from ahriman.core.exceptions import InvalidOption
|
||||
from ahriman.core.exceptions import OptionError
|
||||
|
||||
|
||||
def test_auth_control(oauth: OAuth) -> None:
|
||||
@ -28,7 +28,7 @@ def test_get_provider_not_a_type() -> None:
|
||||
"""
|
||||
must raise an exception if attribute is not a type
|
||||
"""
|
||||
with pytest.raises(InvalidOption):
|
||||
with pytest.raises(OptionError):
|
||||
OAuth.get_provider("__version__")
|
||||
|
||||
|
||||
@ -36,9 +36,9 @@ def test_get_provider_invalid_type() -> None:
|
||||
"""
|
||||
must raise an exception if attribute is not an OAuth2 client
|
||||
"""
|
||||
with pytest.raises(InvalidOption):
|
||||
with pytest.raises(OptionError):
|
||||
OAuth.get_provider("User")
|
||||
with pytest.raises(InvalidOption):
|
||||
with pytest.raises(OptionError):
|
||||
OAuth.get_provider("OAuth1Client")
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@ import pytest
|
||||
|
||||
from pathlib import Path
|
||||
from pytest_mock import MockerFixture
|
||||
from unittest import mock
|
||||
from unittest.mock import call as MockCall
|
||||
|
||||
from ahriman.core.build_tools.sources import Sources
|
||||
from ahriman.models.package import Package
|
||||
@ -55,12 +55,12 @@ def test_fetch_existing(remote_source: RemoteSource, mocker: MockerFixture) -> N
|
||||
local = Path("local")
|
||||
Sources.fetch(local, remote_source)
|
||||
check_output_mock.assert_has_calls([
|
||||
mock.call("git", "fetch", "origin", remote_source.branch,
|
||||
exception=None, cwd=local, logger=pytest.helpers.anyvar(int)),
|
||||
mock.call("git", "checkout", "--force", remote_source.branch,
|
||||
exception=None, cwd=local, logger=pytest.helpers.anyvar(int)),
|
||||
mock.call("git", "reset", "--hard", f"origin/{remote_source.branch}",
|
||||
exception=None, cwd=local, logger=pytest.helpers.anyvar(int))
|
||||
MockCall("git", "fetch", "origin", remote_source.branch,
|
||||
exception=None, cwd=local, logger=pytest.helpers.anyvar(int)),
|
||||
MockCall("git", "checkout", "--force", remote_source.branch,
|
||||
exception=None, cwd=local, logger=pytest.helpers.anyvar(int)),
|
||||
MockCall("git", "reset", "--hard", f"origin/{remote_source.branch}",
|
||||
exception=None, cwd=local, logger=pytest.helpers.anyvar(int))
|
||||
])
|
||||
move_mock.assert_called_once_with(local.resolve(), local)
|
||||
|
||||
@ -76,12 +76,12 @@ def test_fetch_new(remote_source: RemoteSource, mocker: MockerFixture) -> None:
|
||||
local = Path("local")
|
||||
Sources.fetch(local, remote_source)
|
||||
check_output_mock.assert_has_calls([
|
||||
mock.call("git", "clone", "--branch", remote_source.branch, "--single-branch",
|
||||
remote_source.git_url, str(local), exception=None, cwd=local, logger=pytest.helpers.anyvar(int)),
|
||||
mock.call("git", "checkout", "--force", remote_source.branch,
|
||||
exception=None, cwd=local, logger=pytest.helpers.anyvar(int)),
|
||||
mock.call("git", "reset", "--hard", f"origin/{remote_source.branch}",
|
||||
exception=None, cwd=local, logger=pytest.helpers.anyvar(int))
|
||||
MockCall("git", "clone", "--branch", remote_source.branch, "--single-branch",
|
||||
remote_source.git_url, str(local), exception=None, cwd=local, logger=pytest.helpers.anyvar(int)),
|
||||
MockCall("git", "checkout", "--force", remote_source.branch,
|
||||
exception=None, cwd=local, logger=pytest.helpers.anyvar(int)),
|
||||
MockCall("git", "reset", "--hard", f"origin/{remote_source.branch}",
|
||||
exception=None, cwd=local, logger=pytest.helpers.anyvar(int))
|
||||
])
|
||||
move_mock.assert_called_once_with(local.resolve(), local)
|
||||
|
||||
@ -97,10 +97,10 @@ def test_fetch_new_without_remote(mocker: MockerFixture) -> None:
|
||||
local = Path("local")
|
||||
Sources.fetch(local, None)
|
||||
check_output_mock.assert_has_calls([
|
||||
mock.call("git", "checkout", "--force", Sources.DEFAULT_BRANCH,
|
||||
exception=None, cwd=local, logger=pytest.helpers.anyvar(int)),
|
||||
mock.call("git", "reset", "--hard", f"origin/{Sources.DEFAULT_BRANCH}",
|
||||
exception=None, cwd=local, logger=pytest.helpers.anyvar(int))
|
||||
MockCall("git", "checkout", "--force", Sources.DEFAULT_BRANCH,
|
||||
exception=None, cwd=local, logger=pytest.helpers.anyvar(int)),
|
||||
MockCall("git", "reset", "--hard", f"origin/{Sources.DEFAULT_BRANCH}",
|
||||
exception=None, cwd=local, logger=pytest.helpers.anyvar(int))
|
||||
])
|
||||
move_mock.assert_called_once_with(local.resolve(), local)
|
||||
|
||||
@ -237,7 +237,7 @@ def test_add(sources: Sources, mocker: MockerFixture) -> None:
|
||||
|
||||
local = Path("local")
|
||||
sources.add(local, "pattern1", "pattern2")
|
||||
glob_mock.assert_has_calls([mock.call("pattern1"), mock.call("pattern2")])
|
||||
glob_mock.assert_has_calls([MockCall("pattern1"), MockCall("pattern2")])
|
||||
check_output_mock.assert_called_once_with(
|
||||
"git", "add", "--intent-to-add", "1", "2", "1", "2",
|
||||
exception=None, cwd=local, logger=pytest.helpers.anyvar(int))
|
||||
|
@ -2,7 +2,7 @@ import pytest
|
||||
|
||||
from pytest_mock import MockerFixture
|
||||
from sqlite3 import Connection
|
||||
from unittest import mock
|
||||
from unittest.mock import call as MockCall
|
||||
|
||||
from ahriman.core.database.data import migrate_package_statuses
|
||||
from ahriman.models.package import Package
|
||||
@ -22,11 +22,11 @@ def test_migrate_package_statuses(connection: Connection, package_ahriman: Packa
|
||||
|
||||
migrate_package_statuses(connection, repository_paths)
|
||||
connection.execute.assert_has_calls([
|
||||
mock.call(pytest.helpers.anyvar(str, strict=True), pytest.helpers.anyvar(int)),
|
||||
mock.call(pytest.helpers.anyvar(str, strict=True), pytest.helpers.anyvar(int)),
|
||||
MockCall(pytest.helpers.anyvar(str, strict=True), pytest.helpers.anyvar(int)),
|
||||
MockCall(pytest.helpers.anyvar(str, strict=True), pytest.helpers.anyvar(int)),
|
||||
])
|
||||
connection.executemany.assert_has_calls([
|
||||
mock.call(pytest.helpers.anyvar(str, strict=True), pytest.helpers.anyvar(int)),
|
||||
MockCall(pytest.helpers.anyvar(str, strict=True), pytest.helpers.anyvar(int)),
|
||||
])
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import pytest
|
||||
|
||||
from sqlite3 import Connection
|
||||
from unittest import mock
|
||||
from unittest.mock import call as MockCall
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.database.data import migrate_users_data
|
||||
@ -16,6 +16,6 @@ def test_migrate_users_data(connection: Connection, configuration: Configuration
|
||||
|
||||
migrate_users_data(connection, configuration)
|
||||
connection.execute.assert_has_calls([
|
||||
mock.call(pytest.helpers.anyvar(str, strict=True), pytest.helpers.anyvar(int)),
|
||||
mock.call(pytest.helpers.anyvar(str, strict=True), pytest.helpers.anyvar(int)),
|
||||
MockCall(pytest.helpers.anyvar(str, strict=True), pytest.helpers.anyvar(int)),
|
||||
MockCall(pytest.helpers.anyvar(str, strict=True), pytest.helpers.anyvar(int)),
|
||||
])
|
||||
|
@ -2,8 +2,7 @@ import pytest
|
||||
|
||||
from pytest_mock import MockerFixture
|
||||
from sqlite3 import Connection
|
||||
from unittest import mock
|
||||
from unittest.mock import MagicMock
|
||||
from unittest.mock import MagicMock, call as MockCall
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.database.migrations import Migrations
|
||||
@ -52,10 +51,10 @@ def test_run(migrations: Migrations, mocker: MockerFixture) -> None:
|
||||
migrations.run()
|
||||
validate_mock.assert_called_once_with()
|
||||
cursor.execute.assert_has_calls([
|
||||
mock.call("begin exclusive"),
|
||||
mock.call("select 1"),
|
||||
mock.call("pragma user_version = 1"),
|
||||
mock.call("commit"),
|
||||
MockCall("begin exclusive"),
|
||||
MockCall("select 1"),
|
||||
MockCall("pragma user_version = 1"),
|
||||
MockCall("commit"),
|
||||
])
|
||||
cursor.close.assert_called_once_with()
|
||||
migrate_data_mock.assert_called_once_with(
|
||||
@ -77,8 +76,8 @@ def test_run_migration_exception(migrations: Migrations, mocker: MockerFixture)
|
||||
with pytest.raises(Exception):
|
||||
migrations.run()
|
||||
cursor.execute.assert_has_calls([
|
||||
mock.call("begin exclusive"),
|
||||
mock.call("rollback"),
|
||||
MockCall("begin exclusive"),
|
||||
MockCall("rollback"),
|
||||
])
|
||||
cursor.close.assert_called_once_with()
|
||||
|
||||
|
@ -2,7 +2,7 @@ import pytest
|
||||
|
||||
from pytest_mock import MockerFixture
|
||||
from sqlite3 import Connection
|
||||
from unittest import mock
|
||||
from unittest.mock import call as MockCall
|
||||
|
||||
from ahriman.core.database import SQLite
|
||||
from ahriman.models.build_status import BuildStatus, BuildStatusEnum
|
||||
@ -17,8 +17,8 @@ def test_package_remove_package_base(database: SQLite, connection: Connection) -
|
||||
"""
|
||||
database._package_remove_package_base(connection, "package")
|
||||
connection.execute.assert_has_calls([
|
||||
mock.call(pytest.helpers.anyvar(str, strict=True), {"package_base": "package"}),
|
||||
mock.call(pytest.helpers.anyvar(str, strict=True), {"package_base": "package"}),
|
||||
MockCall(pytest.helpers.anyvar(str, strict=True), {"package_base": "package"}),
|
||||
MockCall(pytest.helpers.anyvar(str, strict=True), {"package_base": "package"}),
|
||||
])
|
||||
|
||||
|
||||
|
@ -2,10 +2,10 @@ import pytest
|
||||
|
||||
from pathlib import Path
|
||||
from pytest_mock import MockerFixture
|
||||
from unittest import mock
|
||||
from unittest.mock import call as MockCall
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.exceptions import GitRemoteFailed
|
||||
from ahriman.core.exceptions import GitRemoteError
|
||||
from ahriman.core.gitremote.remote_pull import RemotePull
|
||||
|
||||
|
||||
@ -39,12 +39,12 @@ def test_repo_copy(configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
|
||||
runner.repo_copy(Path("local"))
|
||||
copytree_mock.assert_has_calls([
|
||||
mock.call(Path("local") / "package1", configuration.repository_paths.cache_for("package1"), dirs_exist_ok=True),
|
||||
mock.call(Path("local") / "package3", configuration.repository_paths.cache_for("package3"), dirs_exist_ok=True),
|
||||
MockCall(Path("local") / "package1", configuration.repository_paths.cache_for("package1"), dirs_exist_ok=True),
|
||||
MockCall(Path("local") / "package3", configuration.repository_paths.cache_for("package3"), dirs_exist_ok=True),
|
||||
])
|
||||
init_mock.assert_has_calls([
|
||||
mock.call(configuration.repository_paths.cache_for("package1")),
|
||||
mock.call(configuration.repository_paths.cache_for("package3")),
|
||||
MockCall(configuration.repository_paths.cache_for("package1")),
|
||||
MockCall(configuration.repository_paths.cache_for("package3")),
|
||||
])
|
||||
|
||||
|
||||
@ -66,5 +66,5 @@ def test_run_failed(configuration: Configuration, mocker: MockerFixture) -> None
|
||||
mocker.patch("ahriman.core.gitremote.remote_pull.RemotePull.repo_clone", side_effect=Exception())
|
||||
runner = RemotePull(configuration, "gitremote")
|
||||
|
||||
with pytest.raises(GitRemoteFailed):
|
||||
with pytest.raises(GitRemoteError):
|
||||
runner.run()
|
||||
|
@ -2,10 +2,10 @@ import pytest
|
||||
|
||||
from pathlib import Path
|
||||
from pytest_mock import MockerFixture
|
||||
from unittest import mock
|
||||
from unittest.mock import call as MockCall
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.exceptions import GitRemoteFailed
|
||||
from ahriman.core.exceptions import GitRemoteError
|
||||
from ahriman.core.gitremote.remote_push import RemotePush
|
||||
from ahriman.models.package import Package
|
||||
from ahriman.models.result import Result
|
||||
@ -22,9 +22,9 @@ def test_package_update(package_ahriman: Package, mocker: MockerFixture) -> None
|
||||
local = Path("local")
|
||||
RemotePush.package_update(package_ahriman, local)
|
||||
rmtree_mock.assert_has_calls([
|
||||
mock.call(local / package_ahriman.base, ignore_errors=True),
|
||||
mock.call(pytest.helpers.anyvar(int), onerror=pytest.helpers.anyvar(int)), # removal of the TemporaryDirectory
|
||||
mock.call(local / package_ahriman.base / ".git", ignore_errors=True),
|
||||
MockCall(local / package_ahriman.base, ignore_errors=True),
|
||||
MockCall(pytest.helpers.anyvar(int), onerror=pytest.helpers.anyvar(int)), # removal of the TemporaryDirectory
|
||||
MockCall(local / package_ahriman.base / ".git", ignore_errors=True),
|
||||
])
|
||||
fetch_mock.assert_called_once_with(pytest.helpers.anyvar(int), package_ahriman.remote)
|
||||
copytree_mock.assert_called_once_with(pytest.helpers.anyvar(int), local / package_ahriman.base)
|
||||
@ -63,5 +63,5 @@ def test_run_failed(configuration: Configuration, result: Result, mocker: Mocker
|
||||
mocker.patch("ahriman.core.build_tools.sources.Sources.fetch", side_effect=Exception())
|
||||
runner = RemotePush(configuration, "gitremote")
|
||||
|
||||
with pytest.raises(GitRemoteFailed):
|
||||
with pytest.raises(GitRemoteError):
|
||||
runner.run(result)
|
||||
|
@ -1,5 +1,5 @@
|
||||
from pytest_mock import MockerFixture
|
||||
from unittest import mock
|
||||
from unittest.mock import call as MockCall
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.report.console import Console
|
||||
@ -17,4 +17,4 @@ def test_generate(configuration: Configuration, result: Result, package_python_s
|
||||
report = Console("x86_64", configuration, "console")
|
||||
|
||||
report.generate([], result)
|
||||
print_mock.assert_has_calls([mock.call(verbose=True), mock.call(verbose=True)])
|
||||
print_mock.assert_has_calls([MockCall(verbose=True), MockCall(verbose=True)])
|
||||
|
@ -3,7 +3,7 @@ import pytest
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.exceptions import ReportFailed
|
||||
from ahriman.core.exceptions import ReportError
|
||||
from ahriman.core.report.report import Report
|
||||
from ahriman.models.report_settings import ReportSettings
|
||||
from ahriman.models.result import Result
|
||||
@ -14,7 +14,7 @@ def test_report_failure(configuration: Configuration, mocker: MockerFixture) ->
|
||||
must raise ReportFailed on errors
|
||||
"""
|
||||
mocker.patch("ahriman.core.report.html.HTML.generate", side_effect=Exception())
|
||||
with pytest.raises(ReportFailed):
|
||||
with pytest.raises(ReportError):
|
||||
Report.load("x86_64", configuration, "html").run(Result(), [])
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@ import pytest
|
||||
import requests
|
||||
|
||||
from pytest_mock import MockerFixture
|
||||
from unittest import mock
|
||||
from unittest.mock import call as MockCall
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.report.telegram import Telegram
|
||||
@ -81,7 +81,7 @@ def test_generate_big_text(configuration: Configuration, package_ahriman: Packag
|
||||
report = Telegram("x86_64", configuration, "telegram")
|
||||
report.generate([package_ahriman], result)
|
||||
send_mock.assert_has_calls([
|
||||
mock.call(pytest.helpers.anyvar(str, strict=True)), mock.call(pytest.helpers.anyvar(str, strict=True))
|
||||
MockCall(pytest.helpers.anyvar(str, strict=True)), MockCall(pytest.helpers.anyvar(str, strict=True))
|
||||
])
|
||||
|
||||
|
||||
@ -96,9 +96,9 @@ def test_generate_very_big_text(configuration: Configuration, package_ahriman: P
|
||||
report = Telegram("x86_64", configuration, "telegram")
|
||||
report.generate([package_ahriman], result)
|
||||
send_mock.assert_has_calls([
|
||||
mock.call(pytest.helpers.anyvar(str, strict=True)),
|
||||
mock.call(pytest.helpers.anyvar(str, strict=True)),
|
||||
mock.call(pytest.helpers.anyvar(str, strict=True)),
|
||||
MockCall(pytest.helpers.anyvar(str, strict=True)),
|
||||
MockCall(pytest.helpers.anyvar(str, strict=True)),
|
||||
MockCall(pytest.helpers.anyvar(str, strict=True)),
|
||||
])
|
||||
|
||||
|
||||
|
@ -24,7 +24,7 @@ def cleaner(configuration: Configuration, database: SQLite, mocker: MockerFixtur
|
||||
Cleaner: cleaner test instance
|
||||
"""
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
return Cleaner("x86_64", configuration, database, no_report=True, unsafe=False)
|
||||
return Cleaner("x86_64", configuration, database, report=False, unsafe=False)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@ -45,7 +45,7 @@ def executor(configuration: Configuration, database: SQLite, mocker: MockerFixtu
|
||||
mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_packages")
|
||||
mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_queue")
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
return Executor("x86_64", configuration, database, no_report=True, unsafe=False)
|
||||
return Executor("x86_64", configuration, database, report=False, unsafe=False)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@ -62,7 +62,7 @@ def repository(configuration: Configuration, database: SQLite, mocker: MockerFix
|
||||
Repository: repository test instance
|
||||
"""
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
return Repository("x86_64", configuration, database, no_report=True, unsafe=False)
|
||||
return Repository("x86_64", configuration, database, report=False, unsafe=False)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@ -83,4 +83,4 @@ def update_handler(configuration: Configuration, database: SQLite, mocker: Mocke
|
||||
mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_packages")
|
||||
mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_queue")
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
return UpdateHandler("x86_64", configuration, database, no_report=True, unsafe=False)
|
||||
return UpdateHandler("x86_64", configuration, database, report=False, unsafe=False)
|
||||
|
@ -3,7 +3,7 @@ import shutil
|
||||
|
||||
from pathlib import Path
|
||||
from pytest_mock import MockerFixture
|
||||
from unittest import mock
|
||||
from unittest.mock import call as MockCall
|
||||
|
||||
from ahriman.core.repository.cleaner import Cleaner
|
||||
|
||||
@ -24,9 +24,9 @@ def _mock_clear_check() -> None:
|
||||
mocker helper for clear tests
|
||||
"""
|
||||
shutil.rmtree.assert_has_calls([
|
||||
mock.call(Path("a")),
|
||||
mock.call(Path("b")),
|
||||
mock.call(Path("c"))
|
||||
MockCall(Path("a")),
|
||||
MockCall(Path("b")),
|
||||
MockCall(Path("c"))
|
||||
])
|
||||
|
||||
|
||||
@ -65,7 +65,16 @@ def test_clear_packages(cleaner: Cleaner, mocker: MockerFixture) -> None:
|
||||
mocker.patch("pathlib.Path.unlink")
|
||||
|
||||
cleaner.clear_packages()
|
||||
Path.unlink.assert_has_calls([mock.call(), mock.call(), mock.call()])
|
||||
Path.unlink.assert_has_calls([MockCall(), MockCall(), MockCall()])
|
||||
|
||||
|
||||
def test_clear_pacman(cleaner: Cleaner, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must delete built packages
|
||||
"""
|
||||
_mock_clear(mocker)
|
||||
cleaner.clear_pacman()
|
||||
_mock_clear_check()
|
||||
|
||||
|
||||
def test_clear_queue(cleaner: Cleaner, mocker: MockerFixture) -> None:
|
||||
|
@ -2,7 +2,7 @@ import pytest
|
||||
|
||||
from pathlib import Path
|
||||
from pytest_mock import MockerFixture
|
||||
from unittest import mock
|
||||
from unittest.mock import call as MockCall
|
||||
|
||||
from ahriman.core.repository.executor import Executor
|
||||
from ahriman.models.package import Package
|
||||
@ -88,7 +88,7 @@ def test_process_remove_base_multiple(executor: Executor, package_python_schedul
|
||||
executor.process_remove([package_python_schedule.base])
|
||||
# must remove via alpm wrapper
|
||||
repo_remove_mock.assert_has_calls([
|
||||
mock.call(package, props.filepath)
|
||||
MockCall(package, props.filepath)
|
||||
for package, props in package_python_schedule.packages.items()
|
||||
], any_order=True)
|
||||
# must update status
|
||||
@ -186,7 +186,7 @@ def test_process_update_group(executor: Executor, package_python_schedule: Packa
|
||||
|
||||
executor.process_update([package.filepath for package in package_python_schedule.packages.values()])
|
||||
repo_add_mock.assert_has_calls([
|
||||
mock.call(executor.paths.repository / package.filepath)
|
||||
MockCall(executor.paths.repository / package.filepath)
|
||||
for package in package_python_schedule.packages.values()
|
||||
], any_order=True)
|
||||
status_client_mock.assert_called_once_with(package_python_schedule)
|
||||
@ -208,8 +208,8 @@ def test_process_update_unsafe(executor: Executor, package_ahriman: Package, moc
|
||||
|
||||
executor.process_update([Path(path)])
|
||||
move_mock.assert_has_calls([
|
||||
mock.call(executor.paths.packages / path, executor.paths.packages / safe_path),
|
||||
mock.call(executor.paths.packages / safe_path, executor.paths.repository / safe_path)
|
||||
MockCall(executor.paths.packages / path, executor.paths.packages / safe_path),
|
||||
MockCall(executor.paths.packages / safe_path, executor.paths.repository / safe_path)
|
||||
])
|
||||
repo_add_mock.assert_called_once_with(executor.paths.repository / safe_path)
|
||||
|
||||
|
@ -2,7 +2,7 @@ from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.database import SQLite
|
||||
from ahriman.core.exceptions import UnsafeRun
|
||||
from ahriman.core.exceptions import UnsafeRunError
|
||||
from ahriman.core.repository.repository_properties import RepositoryProperties
|
||||
from ahriman.core.status.web_client import WebClient
|
||||
|
||||
@ -13,7 +13,7 @@ def test_create_tree_on_load(configuration: Configuration, database: SQLite, moc
|
||||
"""
|
||||
mocker.patch("ahriman.core.repository.repository_properties.check_user")
|
||||
tree_create_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
RepositoryProperties("x86_64", configuration, database, True, False)
|
||||
RepositoryProperties("x86_64", configuration, database, report=False, unsafe=False)
|
||||
|
||||
tree_create_mock.assert_called_once_with()
|
||||
|
||||
@ -22,9 +22,9 @@ def test_create_tree_on_load_unsafe(configuration: Configuration, database: SQLi
|
||||
"""
|
||||
must not create tree on load in case if user differs from the root owner
|
||||
"""
|
||||
mocker.patch("ahriman.core.repository.repository_properties.check_user", side_effect=UnsafeRun(0, 1))
|
||||
mocker.patch("ahriman.core.repository.repository_properties.check_user", side_effect=UnsafeRunError(0, 1))
|
||||
tree_create_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
RepositoryProperties("x86_64", configuration, database, True, False)
|
||||
RepositoryProperties("x86_64", configuration, database, report=False, unsafe=False)
|
||||
|
||||
tree_create_mock.assert_not_called()
|
||||
|
||||
@ -35,7 +35,7 @@ def test_create_dummy_report_client(configuration: Configuration, database: SQLi
|
||||
"""
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
load_mock = mocker.patch("ahriman.core.status.client.Client.load")
|
||||
properties = RepositoryProperties("x86_64", configuration, database, True, False)
|
||||
properties = RepositoryProperties("x86_64", configuration, database, report=False, unsafe=False)
|
||||
|
||||
load_mock.assert_not_called()
|
||||
assert not isinstance(properties.reporter, WebClient)
|
||||
@ -47,6 +47,6 @@ def test_create_full_report_client(configuration: Configuration, database: SQLit
|
||||
"""
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
load_mock = mocker.patch("ahriman.core.status.client.Client.load")
|
||||
RepositoryProperties("x86_64", configuration, database, False, False)
|
||||
RepositoryProperties("x86_64", configuration, database, report=True, unsafe=True)
|
||||
|
||||
load_mock.assert_called_once_with(configuration)
|
||||
|
@ -26,7 +26,7 @@ def test_updates_aur(update_handler: UpdateHandler, package_ahriman: Package,
|
||||
mocker.patch("ahriman.models.package.Package.from_aur", return_value=package_ahriman)
|
||||
status_client_mock = mocker.patch("ahriman.core.status.client.Client.set_pending")
|
||||
|
||||
assert update_handler.updates_aur([], False) == [package_ahriman]
|
||||
assert update_handler.updates_aur([], vcs=True) == [package_ahriman]
|
||||
status_client_mock.assert_called_once_with(package_ahriman.base)
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ def test_updates_aur_official(update_handler: UpdateHandler, package_ahriman: Pa
|
||||
mocker.patch("ahriman.models.package.Package.from_official", return_value=package_ahriman)
|
||||
status_client_mock = mocker.patch("ahriman.core.status.client.Client.set_pending")
|
||||
|
||||
assert update_handler.updates_aur([], False) == [package_ahriman]
|
||||
assert update_handler.updates_aur([], vcs=True) == [package_ahriman]
|
||||
status_client_mock.assert_called_once_with(package_ahriman.base)
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ def test_updates_aur_failed(update_handler: UpdateHandler, package_ahriman: Pack
|
||||
mocker.patch("ahriman.models.package.Package.from_aur", side_effect=Exception())
|
||||
status_client_mock = mocker.patch("ahriman.core.status.client.Client.set_failed")
|
||||
|
||||
update_handler.updates_aur([], False)
|
||||
update_handler.updates_aur([], vcs=True)
|
||||
status_client_mock.assert_called_once_with(package_ahriman.base)
|
||||
|
||||
|
||||
@ -68,7 +68,7 @@ def test_updates_aur_filter(update_handler: UpdateHandler, package_ahriman: Pack
|
||||
mocker.patch("ahriman.models.package.Package.is_outdated", return_value=True)
|
||||
package_load_mock = mocker.patch("ahriman.models.package.Package.from_aur", return_value=package_ahriman)
|
||||
|
||||
assert update_handler.updates_aur([package_ahriman.base], False) == [package_ahriman]
|
||||
assert update_handler.updates_aur([package_ahriman.base], vcs=True) == [package_ahriman]
|
||||
package_load_mock.assert_called_once_with(package_ahriman.base, update_handler.pacman)
|
||||
|
||||
|
||||
@ -81,7 +81,7 @@ def test_updates_aur_ignore(update_handler: UpdateHandler, package_ahriman: Pack
|
||||
mocker.patch("ahriman.core.repository.update_handler.UpdateHandler.packages", return_value=[package_ahriman])
|
||||
package_load_mock = mocker.patch("ahriman.models.package.Package.from_aur")
|
||||
|
||||
update_handler.updates_aur([], False)
|
||||
update_handler.updates_aur([], vcs=True)
|
||||
package_load_mock.assert_not_called()
|
||||
|
||||
|
||||
@ -94,7 +94,7 @@ def test_updates_aur_ignore_vcs(update_handler: UpdateHandler, package_ahriman:
|
||||
mocker.patch("ahriman.models.package.Package.is_vcs", return_value=True)
|
||||
package_is_outdated_mock = mocker.patch("ahriman.models.package.Package.is_outdated")
|
||||
|
||||
update_handler.updates_aur([], True)
|
||||
update_handler.updates_aur([], vcs=False)
|
||||
package_is_outdated_mock.assert_not_called()
|
||||
|
||||
|
||||
|
@ -4,7 +4,7 @@ from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.database import SQLite
|
||||
from ahriman.core.exceptions import UnknownPackage
|
||||
from ahriman.core.exceptions import UnknownPackageError
|
||||
from ahriman.core.status.watcher import Watcher
|
||||
from ahriman.core.status.web_client import WebClient
|
||||
from ahriman.models.build_status import BuildStatus, BuildStatusEnum
|
||||
@ -39,7 +39,7 @@ def test_get_failed(watcher: Watcher, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must fail on unknown package
|
||||
"""
|
||||
with pytest.raises(UnknownPackage):
|
||||
with pytest.raises(UnknownPackageError):
|
||||
watcher.get(package_ahriman.base)
|
||||
|
||||
|
||||
@ -124,7 +124,7 @@ def test_update_unknown(watcher: Watcher, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must fail on unknown package status update only
|
||||
"""
|
||||
with pytest.raises(UnknownPackage):
|
||||
with pytest.raises(UnknownPackageError):
|
||||
watcher.update(package_ahriman.base, BuildStatusEnum.Unknown, None)
|
||||
|
||||
|
||||
|
@ -4,10 +4,10 @@ import pytest
|
||||
|
||||
from pathlib import Path
|
||||
from pytest_mock import MockerFixture
|
||||
from unittest import mock
|
||||
from unittest.mock import call as MockCall
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.exceptions import InitializeException
|
||||
from ahriman.core.exceptions import InitializeError
|
||||
from ahriman.models.repository_paths import RepositoryPaths
|
||||
|
||||
|
||||
@ -62,7 +62,7 @@ def test_check_loaded_path(configuration: Configuration) -> None:
|
||||
must raise exception if path is none
|
||||
"""
|
||||
configuration.path = None
|
||||
with pytest.raises(InitializeException):
|
||||
with pytest.raises(InitializeError):
|
||||
configuration.check_loaded()
|
||||
|
||||
|
||||
@ -71,7 +71,7 @@ def test_check_loaded_architecture(configuration: Configuration) -> None:
|
||||
must raise exception if architecture is none
|
||||
"""
|
||||
configuration.architecture = None
|
||||
with pytest.raises(InitializeException):
|
||||
with pytest.raises(InitializeError):
|
||||
configuration.check_loaded()
|
||||
|
||||
|
||||
@ -312,7 +312,7 @@ def test_reload_clear(configuration: Configuration, mocker: MockerFixture) -> No
|
||||
sections = configuration.sections()
|
||||
|
||||
configuration.reload()
|
||||
clear_mock.assert_has_calls([mock.call(section) for section in sections])
|
||||
clear_mock.assert_has_calls([MockCall(section) for section in sections])
|
||||
|
||||
|
||||
def test_reload_no_architecture(configuration: Configuration) -> None:
|
||||
@ -320,7 +320,7 @@ def test_reload_no_architecture(configuration: Configuration) -> None:
|
||||
must raise exception on reload if no architecture set
|
||||
"""
|
||||
configuration.architecture = None
|
||||
with pytest.raises(InitializeException):
|
||||
with pytest.raises(InitializeError):
|
||||
configuration.reload()
|
||||
|
||||
|
||||
@ -329,7 +329,7 @@ def test_reload_no_path(configuration: Configuration) -> None:
|
||||
must raise exception on reload if no path set
|
||||
"""
|
||||
configuration.path = None
|
||||
with pytest.raises(InitializeException):
|
||||
with pytest.raises(InitializeError):
|
||||
configuration.reload()
|
||||
|
||||
|
||||
|
@ -8,7 +8,7 @@ from pathlib import Path
|
||||
from pytest_mock import MockerFixture
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
from ahriman.core.exceptions import BuildFailed, InvalidOption, UnsafeRun
|
||||
from ahriman.core.exceptions import BuildError, OptionError, UnsafeRunError
|
||||
from ahriman.core.util import check_output, check_user, exception_response_text, filter_json, full_version, \
|
||||
enum_values, package_like, pretty_datetime, pretty_size, safe_filename, walk
|
||||
from ahriman.models.package import Package
|
||||
@ -93,12 +93,12 @@ def test_check_output_failure_exception(mocker: MockerFixture) -> None:
|
||||
must raise exception provided instead of default
|
||||
"""
|
||||
mocker.patch("subprocess.Popen.wait", return_value=1)
|
||||
exception = BuildFailed("")
|
||||
exception = BuildError("")
|
||||
|
||||
with pytest.raises(BuildFailed):
|
||||
with pytest.raises(BuildError):
|
||||
check_output("echo", "hello", exception=exception)
|
||||
|
||||
with pytest.raises(BuildFailed):
|
||||
with pytest.raises(BuildError):
|
||||
check_output("echo", "hello", exception=exception, logger=logging.getLogger(""))
|
||||
|
||||
|
||||
@ -108,7 +108,7 @@ def test_check_user(mocker: MockerFixture) -> None:
|
||||
"""
|
||||
paths = RepositoryPaths(Path.cwd(), "x86_64")
|
||||
mocker.patch("os.getuid", return_value=paths.root_owner[0])
|
||||
check_user(paths, False)
|
||||
check_user(paths, unsafe=False)
|
||||
|
||||
|
||||
def test_check_user_no_directory(repository_paths: RepositoryPaths, mocker: MockerFixture) -> None:
|
||||
@ -116,7 +116,7 @@ def test_check_user_no_directory(repository_paths: RepositoryPaths, mocker: Mock
|
||||
must not fail in case if no directory found
|
||||
"""
|
||||
mocker.patch("pathlib.Path.exists", return_value=False)
|
||||
check_user(repository_paths, False)
|
||||
check_user(repository_paths, unsafe=False)
|
||||
|
||||
|
||||
def test_check_user_exception(mocker: MockerFixture) -> None:
|
||||
@ -126,8 +126,17 @@ def test_check_user_exception(mocker: MockerFixture) -> None:
|
||||
paths = RepositoryPaths(Path.cwd(), "x86_64")
|
||||
mocker.patch("os.getuid", return_value=paths.root_owner[0] + 1)
|
||||
|
||||
with pytest.raises(UnsafeRun):
|
||||
check_user(paths, False)
|
||||
with pytest.raises(UnsafeRunError):
|
||||
check_user(paths, unsafe=False)
|
||||
|
||||
|
||||
def test_check_user_unsafe(mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must skip check if unsafe flag is set
|
||||
"""
|
||||
paths = RepositoryPaths(Path.cwd(), "x86_64")
|
||||
mocker.patch("os.getuid", return_value=paths.root_owner[0] + 1)
|
||||
check_user(paths, unsafe=True)
|
||||
|
||||
|
||||
def test_exception_response_text() -> None:
|
||||
@ -149,15 +158,6 @@ def test_exception_response_text_empty() -> None:
|
||||
assert exception_response_text(exception) == ""
|
||||
|
||||
|
||||
def test_check_unsafe(mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must skip check if unsafe flag is set
|
||||
"""
|
||||
paths = RepositoryPaths(Path.cwd(), "x86_64")
|
||||
mocker.patch("os.getuid", return_value=paths.root_owner[0] + 1)
|
||||
check_user(paths, True)
|
||||
|
||||
|
||||
def test_filter_json(package_ahriman: Package) -> None:
|
||||
"""
|
||||
must filter fields by known list
|
||||
@ -283,7 +283,7 @@ def test_pretty_size_pbytes_failure() -> None:
|
||||
"""
|
||||
must raise exception if level >= 4 supplied
|
||||
"""
|
||||
with pytest.raises(InvalidOption):
|
||||
with pytest.raises(OptionError):
|
||||
pretty_size(42 * 1024 * 1024 * 1024 * 1024, 4).split()
|
||||
|
||||
|
||||
|
@ -4,7 +4,7 @@ from pathlib import Path
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.exceptions import InvalidExtension
|
||||
from ahriman.core.exceptions import ExtensionError
|
||||
from ahriman.core.triggers import TriggerLoader
|
||||
from ahriman.models.package import Package
|
||||
from ahriman.models.result import Result
|
||||
@ -22,7 +22,7 @@ def test_load_trigger_package_invalid_import(trigger_loader: TriggerLoader, mock
|
||||
must raise InvalidExtension on invalid import
|
||||
"""
|
||||
mocker.patch("ahriman.core.triggers.trigger_loader.importlib.import_module", side_effect=ModuleNotFoundError())
|
||||
with pytest.raises(InvalidExtension):
|
||||
with pytest.raises(ExtensionError):
|
||||
trigger_loader.load_trigger("random.module")
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ def test_load_trigger_package_not_trigger(trigger_loader: TriggerLoader) -> None
|
||||
"""
|
||||
must raise InvalidExtension if imported module is not a type
|
||||
"""
|
||||
with pytest.raises(InvalidExtension):
|
||||
with pytest.raises(ExtensionError):
|
||||
trigger_loader.load_trigger("ahriman.core.util.check_output")
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@ def test_load_trigger_package_error_on_creation(trigger_loader: TriggerLoader, m
|
||||
must raise InvalidException on trigger initialization if any exception is thrown
|
||||
"""
|
||||
mocker.patch("ahriman.core.triggers.trigger.Trigger.__init__", side_effect=Exception())
|
||||
with pytest.raises(InvalidExtension):
|
||||
with pytest.raises(ExtensionError):
|
||||
trigger_loader.load_trigger("ahriman.core.report.ReportTrigger")
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ def test_load_trigger_package_is_not_trigger(trigger_loader: TriggerLoader) -> N
|
||||
"""
|
||||
must raise InvalidExtension if loaded class is not a trigger
|
||||
"""
|
||||
with pytest.raises(InvalidExtension):
|
||||
with pytest.raises(ExtensionError):
|
||||
trigger_loader.load_trigger("ahriman.core.sign.gpg.GPG")
|
||||
|
||||
|
||||
@ -64,7 +64,7 @@ def test_load_trigger_path_directory(trigger_loader: TriggerLoader, resource_pat
|
||||
must raise InvalidExtension if provided import path is directory
|
||||
"""
|
||||
path = resource_path_root.parent.parent / "src" / "ahriman" / "core" / "report"
|
||||
with pytest.raises(InvalidExtension):
|
||||
with pytest.raises(ExtensionError):
|
||||
trigger_loader.load_trigger(f"{path}.ReportTrigger")
|
||||
|
||||
|
||||
@ -72,7 +72,7 @@ def test_load_trigger_path_not_found(trigger_loader: TriggerLoader) -> None:
|
||||
"""
|
||||
must raise InvalidExtension if file cannot be found
|
||||
"""
|
||||
with pytest.raises(InvalidExtension):
|
||||
with pytest.raises(ExtensionError):
|
||||
trigger_loader.load_trigger("/some/random/path.py.SomeRandomModule")
|
||||
|
||||
|
||||
|
@ -4,7 +4,7 @@ import requests
|
||||
from pathlib import Path
|
||||
from pytest_mock import MockerFixture
|
||||
from typing import Any, Dict
|
||||
from unittest import mock
|
||||
from unittest.mock import call as MockCall
|
||||
|
||||
from ahriman.core.upload.github import Github
|
||||
|
||||
@ -52,8 +52,8 @@ def test_asset_upload_with_removal(github: Github, github_release: Dict[str, Any
|
||||
github.asset_upload(github_release, Path("asset_name"))
|
||||
github.asset_upload(github_release, Path("/root/asset_name"))
|
||||
remove_mock.assert_has_calls([
|
||||
mock.call(github_release, "asset_name"),
|
||||
mock.call(github_release, "asset_name"),
|
||||
MockCall(github_release, "asset_name"),
|
||||
MockCall(github_release, "asset_name"),
|
||||
])
|
||||
|
||||
|
||||
@ -105,8 +105,8 @@ def test_files_upload(github: Github, github_release: Dict[str, Any], mocker: Mo
|
||||
upload_mock = mocker.patch("ahriman.core.upload.github.Github.asset_upload")
|
||||
github.files_upload(github_release, {Path("a"): "a", Path("b"): "c", Path("c"): "c"}, {"a": "a", "b": "b"})
|
||||
upload_mock.assert_has_calls([
|
||||
mock.call(github_release, Path("b")),
|
||||
mock.call(github_release, Path("c")),
|
||||
MockCall(github_release, Path("b")),
|
||||
MockCall(github_release, Path("c")),
|
||||
])
|
||||
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
from pathlib import Path
|
||||
from pytest_mock import MockerFixture
|
||||
from typing import Any, List, Optional, Tuple
|
||||
from unittest import mock
|
||||
from unittest.mock import MagicMock
|
||||
from unittest.mock import MagicMock, call as MockCall
|
||||
|
||||
from ahriman.core.upload.s3 import S3
|
||||
|
||||
@ -67,11 +66,11 @@ def test_files_upload(s3: S3, s3_remote_objects: List[Any], mocker: MockerFixtur
|
||||
s3.files_upload(root, local_files, remote_objects)
|
||||
upload_mock.upload_file.assert_has_calls(
|
||||
[
|
||||
mock.call(
|
||||
MockCall(
|
||||
Filename=str(root / s3.architecture / "b"),
|
||||
Key=f"{s3.architecture}/{s3.architecture}/b",
|
||||
ExtraArgs={"ContentType": "text/html"}),
|
||||
mock.call(
|
||||
MockCall(
|
||||
Filename=str(root / s3.architecture / "d"),
|
||||
Key=f"{s3.architecture}/{s3.architecture}/d",
|
||||
ExtraArgs=None),
|
||||
|
@ -4,7 +4,7 @@ from pathlib import Path
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.core.exceptions import SyncFailed
|
||||
from ahriman.core.exceptions import SynchronizationError
|
||||
from ahriman.core.upload.upload import Upload
|
||||
from ahriman.models.upload_settings import UploadSettings
|
||||
|
||||
@ -14,7 +14,7 @@ def test_upload_failure(configuration: Configuration, mocker: MockerFixture) ->
|
||||
must raise SyncFailed on errors
|
||||
"""
|
||||
mocker.patch("ahriman.core.upload.rsync.Rsync.sync", side_effect=Exception())
|
||||
with pytest.raises(SyncFailed):
|
||||
with pytest.raises(SynchronizationError):
|
||||
Upload.load("x86_64", configuration, "rsync").run(Path("path"), [])
|
||||
|
||||
|
||||
|
@ -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"))
|
||||
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
||||
|
@ -3,7 +3,7 @@ import pytest
|
||||
from aiohttp import web
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.core.exceptions import InitializeException
|
||||
from ahriman.core.exceptions import InitializeError
|
||||
from ahriman.core.status.watcher import Watcher
|
||||
from ahriman.web.web import on_shutdown, on_startup, run_server
|
||||
|
||||
@ -35,7 +35,7 @@ async def test_on_startup_exception(application: web.Application, watcher: Watch
|
||||
mocker.patch("aiohttp.web.Application.__getitem__", return_value=watcher)
|
||||
mocker.patch("ahriman.core.status.watcher.Watcher.load", side_effect=Exception())
|
||||
|
||||
with pytest.raises(InitializeException):
|
||||
with pytest.raises(InitializeError):
|
||||
await on_startup(application)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user