remove unsafe flag from handlers

This flag became reduntant there and tree creation has been moved to
lock
This commit is contained in:
2023-07-07 03:15:02 +03:00
parent 721b447767
commit b7852f55c8
71 changed files with 150 additions and 247 deletions

View File

@ -27,7 +27,7 @@ def application_packages(configuration: Configuration, database: SQLite, reposit
"""
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
return ApplicationPackages("x86_64", configuration, report=False, unsafe=False)
return ApplicationPackages("x86_64", configuration, report=False)
@pytest.fixture
@ -47,7 +47,7 @@ def application_properties(configuration: Configuration, database: SQLite, repos
"""
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
return ApplicationProperties("x86_64", configuration, report=False, unsafe=False)
return ApplicationProperties("x86_64", configuration, report=False)
@pytest.fixture
@ -67,4 +67,4 @@ def application_repository(configuration: Configuration, database: SQLite, repos
"""
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
return ApplicationRepository("x86_64", configuration, report=False, unsafe=False)
return ApplicationRepository("x86_64", configuration, report=False)

View File

@ -26,10 +26,9 @@ def application(configuration: Configuration, repository: Repository, database:
Returns:
Application: application test instance
"""
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
return Application("x86_64", configuration, report=False, unsafe=False)
return Application("x86_64", configuration, report=False)
@pytest.fixture

View File

@ -143,7 +143,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, report=True, unsafe=True)
Handler.run(args, "x86_64", configuration, report=True)
def test_check_if_empty() -> None:

View File

@ -43,7 +43,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
dependencies_mock = mocker.patch("ahriman.application.application.Application.with_dependencies")
on_start_mock = mocker.patch("ahriman.application.application.Application.on_start")
Add.run(args, "x86_64", configuration, report=False, unsafe=False)
Add.run(args, "x86_64", configuration, report=False)
application_mock.assert_called_once_with(args.package, args.source, args.username)
dependencies_mock.assert_not_called()
on_start_mock.assert_called_once_with()
@ -67,7 +67,7 @@ def test_run_with_updates(args: argparse.Namespace, configuration: Configuration
return_value=[package_ahriman])
print_mock = mocker.patch("ahriman.application.application.Application.print_updates")
Add.run(args, "x86_64", configuration, report=False, unsafe=False)
Add.run(args, "x86_64", configuration, report=False)
updates_mock.assert_called_once_with(args.package, aur=False, local=False, manual=True, vcs=False)
application_mock.assert_called_once_with([package_ahriman],
Packagers(args.username, {package_ahriman.base: "packager"}))
@ -92,5 +92,5 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat
mocker.patch("ahriman.application.application.Application.print_updates")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
Add.run(args, "x86_64", configuration, report=False, unsafe=False)
Add.run(args, "x86_64", configuration, report=False)
check_mock.assert_called_once_with(True, True)

View File

@ -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, report=False, unsafe=False)
Backup.run(args, "x86_64", configuration, report=False)
add_mock.add.assert_called_once_with(Path("path"))

View File

@ -35,6 +35,6 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
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, report=False, unsafe=False)
Clean.run(args, "x86_64", configuration, report=False)
application_mock.assert_called_once_with(cache=False, chroot=False, manual=False, packages=False, pacman=False)
on_start_mock.assert_called_once_with()

View File

@ -33,7 +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, report=True, unsafe=False)
run_mock.assert_called_once_with(args, "x86_64", configuration, report=True, unsafe=False)
Daemon.run(args, "x86_64", configuration, report=True)
run_mock.assert_called_once_with(args, "x86_64", configuration, report=True)
start_mock.assert_called_once_with()
join_mock.assert_called_once_with()

View File

@ -29,7 +29,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, report=False, unsafe=False)
Dump.run(args, "x86_64", configuration, report=False)
application_mock.assert_called_once_with()
print_mock.assert_called()

View File

@ -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, report=False, unsafe=False)
Help.run(args, "x86_64", configuration, report=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, report=False, unsafe=False)
Help.run(args, "x86_64", configuration, report=False)
parse_mock.assert_called_once_with(["aur-search", "--help"])

View File

@ -31,7 +31,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
application_mock = mocker.patch("ahriman.core.sign.gpg.GPG.key_import")
KeyImport.run(args, "x86_64", configuration, report=False, unsafe=False)
KeyImport.run(args, "x86_64", configuration, report=False)
application_mock.assert_called_once_with(args.key_server, args.key)

View File

@ -44,7 +44,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
return_value=(args.package, PkgbuildPatch(None, "patch")))
application_mock = mocker.patch("ahriman.application.handlers.Patch.patch_set_create")
Patch.run(args, "x86_64", configuration, report=False, unsafe=False)
Patch.run(args, "x86_64", configuration, report=False)
patch_mock.assert_called_once_with(args.package, "x86_64", args.track)
application_mock.assert_called_once_with(pytest.helpers.anyvar(int), args.package, PkgbuildPatch(None, "patch"))
@ -63,7 +63,7 @@ def test_run_function(args: argparse.Namespace, configuration: Configuration, re
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, report=False, unsafe=False)
Patch.run(args, "x86_64", configuration, report=False)
patch_mock.assert_called_once_with(args.variable, args.patch)
application_mock.assert_called_once_with(pytest.helpers.anyvar(int), args.package, patch)
@ -79,7 +79,7 @@ def test_run_list(args: argparse.Namespace, configuration: Configuration, reposi
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
application_mock = mocker.patch("ahriman.application.handlers.Patch.patch_set_list")
Patch.run(args, "x86_64", configuration, report=False, unsafe=False)
Patch.run(args, "x86_64", configuration, report=False)
application_mock.assert_called_once_with(pytest.helpers.anyvar(int), args.package, ["version"], False)
@ -94,7 +94,7 @@ def test_run_remove(args: argparse.Namespace, configuration: Configuration, repo
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
application_mock = mocker.patch("ahriman.application.handlers.Patch.patch_set_remove")
Patch.run(args, "x86_64", configuration, report=False, unsafe=False)
Patch.run(args, "x86_64", configuration, report=False)
application_mock.assert_called_once_with(pytest.helpers.anyvar(int), args.package, ["version"])

View File

@ -48,7 +48,7 @@ def test_run(args: argparse.Namespace, package_ahriman: Package, configuration:
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, report=False, unsafe=False)
Rebuild.run(args, "x86_64", configuration, report=False)
extract_mock.assert_called_once_with(pytest.helpers.anyvar(int), args.status, from_database=args.from_database)
application_packages_mock.assert_called_once_with([package_ahriman], None)
application_mock.assert_called_once_with([package_ahriman], args.username)
@ -69,7 +69,7 @@ def test_run_extract_packages(args: argparse.Namespace, configuration: Configura
mocker.patch("ahriman.application.application.Application.print_updates")
extract_mock = mocker.patch("ahriman.application.handlers.Rebuild.extract_packages", return_value=[])
Rebuild.run(args, "x86_64", configuration, report=False, unsafe=False)
Rebuild.run(args, "x86_64", configuration, report=False)
extract_mock.assert_called_once_with(pytest.helpers.anyvar(int), args.status, from_database=args.from_database)
@ -86,7 +86,7 @@ def test_run_dry_run(args: argparse.Namespace, configuration: Configuration, rep
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
print_mock = mocker.patch("ahriman.application.application.Application.print_updates")
Rebuild.run(args, "x86_64", configuration, report=False, unsafe=False)
Rebuild.run(args, "x86_64", configuration, report=False)
application_mock.assert_not_called()
check_mock.assert_called_once_with(False, False)
print_mock.assert_called_once_with([package_ahriman], log_fn=pytest.helpers.anyvar(int))
@ -104,7 +104,7 @@ def test_run_filter(args: argparse.Namespace, configuration: Configuration, repo
mocker.patch("ahriman.application.handlers.Rebuild.extract_packages", return_value=[])
application_packages_mock = mocker.patch("ahriman.core.repository.repository.Repository.packages_depend_on")
Rebuild.run(args, "x86_64", configuration, report=False, unsafe=False)
Rebuild.run(args, "x86_64", configuration, report=False)
application_packages_mock.assert_called_once_with([], ["python-aur"])
@ -119,7 +119,7 @@ def test_run_without_filter(args: argparse.Namespace, configuration: Configurati
mocker.patch("ahriman.application.handlers.Rebuild.extract_packages", return_value=[])
application_packages_mock = mocker.patch("ahriman.core.repository.repository.Repository.packages_depend_on")
Rebuild.run(args, "x86_64", configuration, report=False, unsafe=False)
Rebuild.run(args, "x86_64", configuration, report=False)
application_packages_mock.assert_called_once_with([], None)
@ -137,7 +137,7 @@ def test_run_update_empty_exception(args: argparse.Namespace, configuration: Con
mocker.patch("ahriman.application.application.Application.print_updates")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
Rebuild.run(args, "x86_64", configuration, report=False, unsafe=False)
Rebuild.run(args, "x86_64", configuration, report=False)
check_mock.assert_called_once_with(True, True)
@ -154,7 +154,7 @@ 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, report=False, unsafe=False)
Rebuild.run(args, "x86_64", configuration, report=False)
check_mock.assert_has_calls([MockCall(True, False), MockCall(True, True)])

View File

@ -31,6 +31,6 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
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, report=False, unsafe=False)
Remove.run(args, "x86_64", configuration, report=False)
application_mock.assert_called_once_with([])
on_start_mock.assert_called_once_with()

View File

@ -34,7 +34,7 @@ def test_run(args: argparse.Namespace, package_ahriman: Package, configuration:
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, report=False, unsafe=False)
RemoveUnknown.run(args, "x86_64", configuration, report=False)
application_mock.assert_called_once_with()
remove_mock.assert_called_once_with([package_ahriman])
on_start_mock.assert_called_once_with()
@ -53,7 +53,7 @@ def test_run_dry_run(args: argparse.Namespace, configuration: Configuration, rep
remove_mock = mocker.patch("ahriman.application.application.Application.remove")
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
RemoveUnknown.run(args, "x86_64", configuration, report=False, unsafe=False)
RemoveUnknown.run(args, "x86_64", configuration, report=False)
application_mock.assert_called_once_with()
remove_mock.assert_not_called()
print_mock.assert_called_once_with(verbose=False)

View File

@ -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, report=False, unsafe=False)
Restore.run(args, "x86_64", configuration, report=False)
extract_mock.extractall.assert_called_once_with(path=args.output)

View File

@ -42,7 +42,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
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, report=False, unsafe=False)
Search.run(args, "x86_64", configuration, report=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)
@ -62,7 +62,7 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
Search.run(args, "x86_64", configuration, report=False, unsafe=False)
Search.run(args, "x86_64", configuration, report=False)
check_mock.assert_called_once_with(True, True)
@ -77,7 +77,7 @@ def test_run_sort(args: argparse.Namespace, configuration: Configuration, reposi
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
sort_mock = mocker.patch("ahriman.application.handlers.Search.sort")
Search.run(args, "x86_64", configuration, report=False, unsafe=False)
Search.run(args, "x86_64", configuration, report=False)
sort_mock.assert_has_calls([
MockCall([], "name"), MockCall().__iter__(),
MockCall([aur_package_ahriman], "name"), MockCall().__iter__()
@ -96,7 +96,7 @@ def test_run_sort_by(args: argparse.Namespace, configuration: Configuration, rep
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
sort_mock = mocker.patch("ahriman.application.handlers.Search.sort")
Search.run(args, "x86_64", configuration, report=False, unsafe=False)
Search.run(args, "x86_64", configuration, report=False)
sort_mock.assert_has_calls([
MockCall([], "field"), MockCall().__iter__(),
MockCall([aur_package_ahriman], "field"), MockCall().__iter__()

View File

@ -35,7 +35,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
application_mock = mocker.patch("ahriman.core.formatters.Printer.print")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
ServiceUpdates.run(args, "x86_64", configuration, report=False, unsafe=False)
ServiceUpdates.run(args, "x86_64", configuration, report=False)
package_mock.assert_called_once_with(package_ahriman.base, repository.pacman, None)
application_mock.assert_called_once_with(verbose=True, separator=" -> ")
check_mock.assert_called_once_with(args.exit_code, True)
@ -53,6 +53,6 @@ def test_run_skip(args: argparse.Namespace, configuration: Configuration, reposi
application_mock = mocker.patch("ahriman.core.formatters.Printer.print")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
ServiceUpdates.run(args, "x86_64", configuration, report=False, unsafe=False)
ServiceUpdates.run(args, "x86_64", configuration, report=False)
application_mock.assert_not_called()
check_mock.assert_not_called()

View File

@ -53,7 +53,7 @@ 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, report=False, unsafe=False)
Setup.run(args, "x86_64", configuration, report=False)
ahriman_configuration_mock.assert_called_once_with(args, "x86_64", args.repository, configuration)
devtools_configuration_mock.assert_called_once_with(
args.build_command, "x86_64", args.from_configuration, args.mirror, args.multilib, args.repository,

View File

@ -32,7 +32,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
application_mock = mocker.patch("code.interact")
Shell.run(args, "x86_64", configuration, report=False, unsafe=False)
Shell.run(args, "x86_64", configuration, report=False)
application_mock.assert_called_once_with(local=pytest.helpers.anyvar(int))
@ -46,7 +46,7 @@ def test_run_eval(args: argparse.Namespace, configuration: Configuration, reposi
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
application_mock = mocker.patch("code.InteractiveConsole.runcode")
Shell.run(args, "x86_64", configuration, report=False, unsafe=False)
Shell.run(args, "x86_64", configuration, report=False)
application_mock.assert_called_once_with(args.code)
@ -61,6 +61,6 @@ def test_run_verbose(args: argparse.Namespace, configuration: Configuration, rep
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
application_mock = mocker.patch("code.interact")
Shell.run(args, "x86_64", configuration, report=False, unsafe=False)
Shell.run(args, "x86_64", configuration, report=False)
application_mock.assert_called_once_with(local=pytest.helpers.anyvar(int))
print_mock.assert_called_once_with(verbose=False)

View File

@ -30,5 +30,5 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
application_mock = mocker.patch("ahriman.application.application.Application.sign")
Sign.run(args, "x86_64", configuration, report=False, unsafe=False)
Sign.run(args, "x86_64", configuration, report=False)
application_mock.assert_called_once_with([])

View File

@ -43,7 +43,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
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, report=False, unsafe=False)
Status.run(args, "x86_64", configuration, report=False)
application_mock.assert_called_once_with()
packages_mock.assert_called_once_with(None)
check_mock.assert_called_once_with(False, False)
@ -62,7 +62,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, report=False, unsafe=False)
Status.run(args, "x86_64", configuration, report=False)
check_mock.assert_called_once_with(True, True)
@ -78,7 +78,7 @@ def test_run_verbose(args: argparse.Namespace, configuration: Configuration, rep
return_value=[(package_ahriman, BuildStatus(BuildStatusEnum.Success))])
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
Status.run(args, "x86_64", configuration, report=False, unsafe=False)
Status.run(args, "x86_64", configuration, report=False)
print_mock.assert_has_calls([MockCall(verbose=True) for _ in range(2)])
@ -93,7 +93,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, report=False, unsafe=False)
Status.run(args, "x86_64", configuration, report=False)
packages_mock.assert_called_once_with(package_ahriman.base)
@ -110,7 +110,7 @@ def test_run_by_status(args: argparse.Namespace, configuration: Configuration, r
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
Status.run(args, "x86_64", configuration, report=False, unsafe=False)
Status.run(args, "x86_64", configuration, report=False)
print_mock.assert_has_calls([MockCall(verbose=False) for _ in range(2)])
@ -123,9 +123,8 @@ def test_imply_with_report(args: argparse.Namespace, configuration: Configuratio
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
load_mock = mocker.patch("ahriman.core.repository.Repository.load")
Status.run(args, "x86_64", configuration, report=False, unsafe=False)
load_mock.assert_called_once_with("x86_64", configuration, database,
report=True, unsafe=False, refresh_pacman_database=0)
Status.run(args, "x86_64", configuration, report=False)
load_mock.assert_called_once_with("x86_64", configuration, database, report=True, refresh_pacman_database=0)
def test_disallow_auto_architecture_run() -> None:

View File

@ -36,7 +36,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
update_self_mock = mocker.patch("ahriman.core.status.client.Client.update_self")
StatusUpdate.run(args, "x86_64", configuration, report=False, unsafe=False)
StatusUpdate.run(args, "x86_64", configuration, report=False)
update_self_mock.assert_called_once_with(args.status)
@ -50,7 +50,7 @@ def test_run_packages(args: argparse.Namespace, configuration: Configuration, re
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
update_mock = mocker.patch("ahriman.core.status.client.Client.update")
StatusUpdate.run(args, "x86_64", configuration, report=False, unsafe=False)
StatusUpdate.run(args, "x86_64", configuration, report=False)
update_mock.assert_called_once_with(package_ahriman.base, args.status)
@ -65,7 +65,7 @@ def test_run_remove(args: argparse.Namespace, configuration: Configuration, repo
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
update_mock = mocker.patch("ahriman.core.status.client.Client.remove")
StatusUpdate.run(args, "x86_64", configuration, report=False, unsafe=False)
StatusUpdate.run(args, "x86_64", configuration, report=False)
update_mock.assert_called_once_with(package_ahriman.base)
@ -78,9 +78,8 @@ def test_imply_with_report(args: argparse.Namespace, configuration: Configuratio
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
load_mock = mocker.patch("ahriman.core.repository.Repository.load")
StatusUpdate.run(args, "x86_64", configuration, report=False, unsafe=False)
load_mock.assert_called_once_with("x86_64", configuration, database,
report=True, unsafe=False, refresh_pacman_database=0)
StatusUpdate.run(args, "x86_64", configuration, report=False)
load_mock.assert_called_once_with("x86_64", configuration, database, report=True, refresh_pacman_database=0)
def test_disallow_auto_architecture_run() -> None:

View File

@ -18,7 +18,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
application_mock = mocker.patch("ahriman.core.tree.Tree.resolve", return_value=[[package_ahriman]])
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
Structure.run(args, "x86_64", configuration, report=False, unsafe=False)
Structure.run(args, "x86_64", configuration, report=False)
application_mock.assert_called_once_with([package_ahriman])
print_mock.assert_called_once_with(verbose=True, separator=" ")

View File

@ -33,7 +33,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
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, report=False, unsafe=False)
Triggers.run(args, "x86_64", configuration, report=False)
application_mock.assert_called_once_with(Result())
on_start_mock.assert_called_once_with()
@ -50,6 +50,6 @@ def test_run_trigger(args: argparse.Namespace, configuration: Configuration, rep
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, report=False, unsafe=False)
Triggers.run(args, "x86_64", configuration, report=False)
report_mock.assert_called_once_with(Result(), [package_ahriman])
upload_mock.assert_not_called()

View File

@ -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, report=False, unsafe=False)
UnsafeCommands.run(args, "x86_64", configuration, report=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, report=False, unsafe=False)
UnsafeCommands.run(args, "x86_64", configuration, report=False)
commands_mock.assert_called_once_with(pytest.helpers.anyvar(int))
check_mock.assert_called_once_with(["clean"], ["command"], pytest.helpers.anyvar(int))

View File

@ -53,7 +53,7 @@ def test_run(args: argparse.Namespace, package_ahriman: Package, configuration:
on_start_mock = mocker.patch("ahriman.application.application.Application.on_start")
print_mock = mocker.patch("ahriman.application.application.Application.print_updates")
Update.run(args, "x86_64", configuration, report=False, unsafe=False)
Update.run(args, "x86_64", configuration, report=False)
application_mock.assert_called_once_with([package_ahriman],
Packagers(args.username, {package_ahriman.base: "packager"}))
updates_mock.assert_called_once_with(args.package, aur=args.aur, local=args.local, manual=args.manual, vcs=args.vcs)
@ -75,7 +75,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, report=False, unsafe=False)
Update.run(args, "x86_64", configuration, report=False)
check_mock.assert_called_once_with(True, True)
@ -93,7 +93,7 @@ def test_run_update_empty_exception(args: argparse.Namespace, package_ahriman: P
mocker.patch("ahriman.application.application.Application.print_updates")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
Update.run(args, "x86_64", configuration, report=False, unsafe=False)
Update.run(args, "x86_64", configuration, report=False)
check_mock.assert_has_calls([MockCall(True, False), MockCall(True, True)])
@ -109,7 +109,7 @@ def test_run_dry_run(args: argparse.Namespace, configuration: Configuration, rep
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, report=False, unsafe=False)
Update.run(args, "x86_64", configuration, report=False)
updates_mock.assert_called_once_with(args.package, aur=args.aur, local=args.local, manual=args.manual, vcs=args.vcs)
application_mock.assert_not_called()
check_mock.assert_called_once_with(False, pytest.helpers.anyvar(int))

View File

@ -47,7 +47,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, database: S
create_user_mock = mocker.patch("ahriman.application.handlers.Users.user_create", return_value=user)
update_mock = mocker.patch("ahriman.core.database.SQLite.user_update")
Users.run(args, "x86_64", configuration, report=False, unsafe=False)
Users.run(args, "x86_64", configuration, report=False)
create_user_mock.assert_called_once_with(args)
update_mock.assert_called_once_with(user)
@ -63,7 +63,7 @@ def test_run_empty_salt(args: argparse.Namespace, configuration: Configuration,
mocker.patch("ahriman.models.user.User.hash_password", return_value=user)
with pytest.raises(configparser.NoOptionError):
Users.run(args, "x86_64", configuration, report=False, unsafe=False)
Users.run(args, "x86_64", configuration, report=False)
def test_run_empty_salt_without_password(args: argparse.Namespace, configuration: Configuration, database: SQLite,
@ -80,7 +80,7 @@ def test_run_empty_salt_without_password(args: argparse.Namespace, configuration
create_user_mock = mocker.patch("ahriman.application.handlers.Users.user_create", return_value=user)
update_mock = mocker.patch("ahriman.core.database.SQLite.user_update")
Users.run(args, "x86_64", configuration, report=False, unsafe=False)
Users.run(args, "x86_64", configuration, report=False)
create_user_mock.assert_called_once_with(args)
update_mock.assert_called_once_with(user)
@ -96,7 +96,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, report=False, unsafe=False)
Users.run(args, "x86_64", configuration, report=False)
list_mock.assert_called_once_with("user", args.role)
check_mock.assert_called_once_with(False, False)
@ -113,7 +113,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, report=False, unsafe=False)
Users.run(args, "x86_64", configuration, report=False)
check_mock.assert_called_once_with(True, True)
@ -127,7 +127,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, report=False, unsafe=False)
Users.run(args, "x86_64", configuration, report=False)
remove_mock.assert_called_once_with(args.username)

View File

@ -33,7 +33,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
application_mock = mocker.patch("ahriman.core.configuration.validator.Validator.validate", return_value=False)
Validate.run(args, "x86_64", configuration, report=False, unsafe=False)
Validate.run(args, "x86_64", configuration, report=False)
application_mock.assert_called_once_with(configuration.dump())
print_mock.assert_called_once_with(verbose=True)
@ -47,7 +47,7 @@ def test_run_skip(args: argparse.Namespace, configuration: Configuration, mocker
mocker.patch("ahriman.core.configuration.validator.Validator.validate", return_value=True)
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
Validate.run(args, "x86_64", configuration, report=False, unsafe=False)
Validate.run(args, "x86_64", configuration, report=False)
print_mock.assert_not_called()

View File

@ -14,7 +14,7 @@ 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, report=False, unsafe=False)
Versions.run(args, "x86_64", configuration, report=False)
application_mock.assert_called_once_with("ahriman")
print_mock.assert_has_calls([MockCall(verbose=False, separator=" "), MockCall(verbose=False, separator=" ")])

View File

@ -41,7 +41,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
stop_mock = mocker.patch("ahriman.core.spawn.Spawn.stop")
join_mock = mocker.patch("ahriman.core.spawn.Spawn.join")
Web.run(args, "x86_64", configuration, report=False, unsafe=False)
Web.run(args, "x86_64", configuration, report=False)
setup_mock.assert_called_once_with("x86_64", configuration, pytest.helpers.anyvar(int))
run_mock.assert_called_once_with(pytest.helpers.anyvar(int))
start_mock.assert_called_once_with()

View File

@ -57,8 +57,11 @@ def test_check_user(lock: Lock, mocker: MockerFixture) -> None:
must check user correctly
"""
check_user_patch = mocker.patch("ahriman.application.lock.check_user")
tree_create = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
lock.check_user()
check_user_patch.assert_called_once_with(lock.paths, unsafe=False)
tree_create.assert_called_once_with()
def test_check_user_exception(lock: Lock, mocker: MockerFixture) -> None:
@ -70,10 +73,11 @@ def test_check_user_exception(lock: Lock, mocker: MockerFixture) -> None:
lock.check_user()
def test_check_user_unsafe(lock: Lock) -> None:
def test_check_user_unsafe(lock: Lock, mocker: MockerFixture) -> None:
"""
must skip user check if unsafe flag set
"""
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
lock.unsafe = True
lock.check_user()

View File

@ -443,9 +443,8 @@ def repository(configuration: Configuration, database: SQLite, mocker: MockerFix
Returns:
Repository: repository test instance
"""
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
mocker.patch("ahriman.core.repository.Repository._set_context")
return Repository.load("x86_64", configuration, database, report=False, unsafe=False)
return Repository.load("x86_64", configuration, database, report=False)
@pytest.fixture

View File

@ -7,23 +7,23 @@ from ahriman.core.database import SQLite
from ahriman.core.repository.cleaner import Cleaner
from ahriman.core.repository.executor import Executor
from ahriman.core.repository.update_handler import UpdateHandler
from ahriman.models.pacman_synchronization import PacmanSynchronization
@pytest.fixture
def cleaner(configuration: Configuration, database: SQLite, mocker: MockerFixture) -> Cleaner:
def cleaner(configuration: Configuration, database: SQLite) -> Cleaner:
"""
fixture for cleaner
Args:
configuration(Configuration): configuration fixture
database(SQLite): database fixture
mocker(MockerFixture): mocker object
Returns:
Cleaner: cleaner test instance
"""
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
return Cleaner("x86_64", configuration, database, report=False, unsafe=False, refresh_pacman_database=0)
return Cleaner("x86_64", configuration, database, report=False,
refresh_pacman_database=PacmanSynchronization.Disabled)
@pytest.fixture
@ -43,8 +43,8 @@ def executor(configuration: Configuration, database: SQLite, mocker: MockerFixtu
mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_chroot")
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, report=False, unsafe=False, refresh_pacman_database=0)
return Executor("x86_64", configuration, database, report=False,
refresh_pacman_database=PacmanSynchronization.Disabled)
@pytest.fixture
@ -64,5 +64,5 @@ def update_handler(configuration: Configuration, database: SQLite, mocker: Mocke
mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_chroot")
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, report=False, unsafe=False, refresh_pacman_database=0)
return UpdateHandler("x86_64", configuration, database, report=False,
refresh_pacman_database=PacmanSynchronization.Disabled)

View File

@ -17,9 +17,8 @@ def test_load(configuration: Configuration, database: SQLite, mocker: MockerFixt
"""
must correctly load instance
"""
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
context_mock = mocker.patch("ahriman.core.repository.Repository._set_context")
Repository.load("x86_64", configuration, database, report=False, unsafe=False)
Repository.load("x86_64", configuration, database, report=False)
context_mock.assert_called_once_with()
@ -27,10 +26,9 @@ def test_set_context(configuration: Configuration, database: SQLite, mocker: Moc
"""
must set context variables
"""
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
set_mock = mocker.patch("ahriman.core._Context.set")
instance = Repository.load("x86_64", configuration, database, report=False, unsafe=False)
instance = Repository.load("x86_64", configuration, database, report=False)
set_mock.assert_has_calls([
MockCall(ContextKey("database", SQLite), instance.database),
MockCall(ContextKey("configuration", Configuration), instance.configuration),

View File

@ -1,39 +1,11 @@
from pytest_mock import MockerFixture
from ahriman.core.configuration import Configuration
from ahriman.core.database import SQLite
from ahriman.core.exceptions import UnsafeRunError
from ahriman.core.repository.repository_properties import RepositoryProperties
from ahriman.models.packagers import Packagers
from ahriman.models.pacman_synchronization import PacmanSynchronization
from ahriman.models.user import User
from ahriman.models.user_access import UserAccess
def test_create_tree_on_load(configuration: Configuration, database: SQLite, mocker: MockerFixture) -> None:
"""
must create tree on load
"""
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, report=False, unsafe=False,
refresh_pacman_database=PacmanSynchronization.Disabled)
tree_create_mock.assert_called_once_with()
def test_create_tree_on_load_unsafe(configuration: Configuration, database: SQLite, mocker: MockerFixture) -> None:
"""
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=UnsafeRunError(0, 1))
tree_create_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
RepositoryProperties("x86_64", configuration, database, report=False, unsafe=False,
refresh_pacman_database=PacmanSynchronization.Disabled)
tree_create_mock.assert_not_called()
def test_packager(repository: RepositoryProperties, mocker: MockerFixture) -> None:
"""
must extract packager

View File

@ -19,7 +19,7 @@ def test_force_no_report(configuration: Configuration, database: SQLite, mocker:
load_mock = mocker.patch("ahriman.core.repository.Repository.load")
Watcher("x86_64", configuration, database)
load_mock.assert_called_once_with("x86_64", configuration, database, report=False, unsafe=False)
load_mock.assert_called_once_with("x86_64", configuration, database, report=False)
def test_get(watcher: Watcher, package_ahriman: Package) -> None: