disallow to create tree in case of unsafe run

This commit is contained in:
2021-10-14 04:44:36 +03:00
parent a83f1d5aa5
commit 233b1f7f39
29 changed files with 114 additions and 59 deletions

View File

@ -25,7 +25,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
must run command
"""
args = _default_args(args)
mocker.patch("pathlib.Path.mkdir")
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
application_mock = mocker.patch("ahriman.application.application.Application.add")
Add.run(args, "x86_64", configuration, True)
@ -38,8 +38,8 @@ def test_run_with_updates(args: argparse.Namespace, configuration: Configuration
"""
args = _default_args(args)
args.now = True
mocker.patch("pathlib.Path.mkdir")
mocker.patch("ahriman.application.application.Application.add")
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
application_mock = mocker.patch("ahriman.application.application.Application.update")
updates_mock = mocker.patch("ahriman.application.application.Application.get_updates")

View File

@ -25,7 +25,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
must run command
"""
args = _default_args(args)
mocker.patch("pathlib.Path.mkdir")
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
application_mock = mocker.patch("ahriman.application.application.Application.clean")
Clean.run(args, "x86_64", configuration, True)

View File

@ -10,7 +10,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
"""
must run command
"""
mocker.patch("pathlib.Path.mkdir")
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
print_mock = mocker.patch("ahriman.application.handlers.dump.Dump._print")
application_mock = mocker.patch("ahriman.core.configuration.Configuration.dump",
return_value=configuration.dump())

View File

@ -10,6 +10,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
"""
must run command
"""
mocker.patch("ahriman.core.repository.properties.check_user")
tree_create_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
init_mock = mocker.patch("ahriman.core.alpm.repo.Repo.init")

View File

@ -22,7 +22,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
must run command
"""
args = _default_args(args)
mocker.patch("pathlib.Path.mkdir")
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)

View File

@ -28,7 +28,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
"""
args = _default_args(args)
args.action = Action.Update
mocker.patch("pathlib.Path.mkdir")
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
application_mock = mocker.patch("ahriman.application.handlers.patch.Patch.patch_set_create")
Patch.run(args, "x86_64", configuration, True)
@ -41,7 +41,7 @@ def test_run_list(args: argparse.Namespace, configuration: Configuration, mocker
"""
args = _default_args(args)
args.action = Action.List
mocker.patch("pathlib.Path.mkdir")
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
application_mock = mocker.patch("ahriman.application.handlers.patch.Patch.patch_set_list")
Patch.run(args, "x86_64", configuration, True)
@ -54,7 +54,7 @@ def test_run_remove(args: argparse.Namespace, configuration: Configuration, mock
"""
args = _default_args(args)
args.action = Action.Remove
mocker.patch("pathlib.Path.mkdir")
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
application_mock = mocker.patch("ahriman.application.handlers.patch.Patch.patch_set_remove")
Patch.run(args, "x86_64", configuration, True)
@ -91,6 +91,7 @@ def test_patch_set_create(application: Application, package_ahriman: Package, mo
"""
must create patch set for the package
"""
mocker.patch("pathlib.Path.mkdir")
mocker.patch("ahriman.models.package.Package.load", return_value=package_ahriman)
remove_mock = mocker.patch("ahriman.application.handlers.patch.Patch.patch_set_remove")
create_mock = mocker.patch("ahriman.core.build_tools.sources.Sources.patch_create")

View File

@ -22,7 +22,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
must run command
"""
args = _default_args(args)
mocker.patch("pathlib.Path.mkdir")
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
application_packages_mock = mocker.patch("ahriman.core.repository.repository.Repository.packages")
application_mock = mocker.patch("ahriman.application.application.Application.update")
@ -39,9 +39,9 @@ def test_run_filter(args: argparse.Namespace, configuration: Configuration,
"""
args = _default_args(args)
args.depends_on = ["python-aur"]
mocker.patch("pathlib.Path.mkdir")
mocker.patch("ahriman.core.repository.repository.Repository.packages",
return_value=[package_ahriman, package_python_schedule])
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
application_mock = mocker.patch("ahriman.application.application.Application.update")
Rebuild.run(args, "x86_64", configuration, True)
@ -55,9 +55,9 @@ def test_run_without_filter(args: argparse.Namespace, configuration: Configurati
must run command for all packages if no filter supplied
"""
args = _default_args(args)
mocker.patch("pathlib.Path.mkdir")
mocker.patch("ahriman.core.repository.repository.Repository.packages",
return_value=[package_ahriman, package_python_schedule])
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
application_mock = mocker.patch("ahriman.application.application.Application.update")
Rebuild.run(args, "x86_64", configuration, True)

View File

@ -21,7 +21,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
must run command
"""
args = _default_args(args)
mocker.patch("pathlib.Path.mkdir")
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
application_mock = mocker.patch("ahriman.application.application.Application.remove")
Remove.run(args, "x86_64", configuration, True)

View File

@ -22,7 +22,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
must run command
"""
args = _default_args(args)
mocker.patch("pathlib.Path.mkdir")
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
application_mock = mocker.patch("ahriman.application.application.Application.unknown")
remove_mock = mocker.patch("ahriman.application.application.Application.remove")
@ -38,7 +38,7 @@ def test_run_dry_run(args: argparse.Namespace, configuration: Configuration, pac
"""
args = _default_args(args)
args.dry_run = True
mocker.patch("pathlib.Path.mkdir")
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")

View File

@ -21,7 +21,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
must run command
"""
args = _default_args(args)
mocker.patch("pathlib.Path.mkdir")
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
application_mock = mocker.patch("ahriman.application.application.Application.report")
Report.run(args, "x86_64", configuration, True)

View File

@ -32,7 +32,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
must run command
"""
args = _default_args(args)
mocker.patch("pathlib.Path.mkdir")
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
ahriman_configuration_mock = mocker.patch("ahriman.application.handlers.setup.Setup.configuration_create_ahriman")
devtools_configuration_mock = mocker.patch("ahriman.application.handlers.setup.Setup.configuration_create_devtools")
makepkg_configuration_mock = mocker.patch("ahriman.application.handlers.setup.Setup.configuration_create_makepkg")

View File

@ -21,7 +21,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
must run command
"""
args = _default_args(args)
mocker.patch("pathlib.Path.mkdir")
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)

View File

@ -26,7 +26,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, package_ahr
must run command
"""
args = _default_args(args)
mocker.patch("pathlib.Path.mkdir")
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
application_mock = mocker.patch("ahriman.core.status.client.Client.get_self")
packages_mock = mocker.patch("ahriman.core.status.client.Client.get",
return_value=[(package_ahriman, BuildStatus(BuildStatusEnum.Success)),
@ -46,7 +46,7 @@ def test_run_with_package_filter(args: argparse.Namespace, configuration: Config
"""
args = _default_args(args)
args.package = [package_ahriman.base]
mocker.patch("pathlib.Path.mkdir")
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
packages_mock = mocker.patch("ahriman.core.status.client.Client.get",
return_value=[(package_ahriman, BuildStatus(BuildStatusEnum.Success))])
@ -61,10 +61,10 @@ def test_run_by_status(args: argparse.Namespace, configuration: Configuration, p
"""
args = _default_args(args)
args.status = BuildStatusEnum.Failed
mocker.patch("pathlib.Path.mkdir")
mocker.patch("ahriman.core.status.client.Client.get",
return_value=[(package_ahriman, BuildStatus(BuildStatusEnum.Success)),
(package_python_schedule, BuildStatus(BuildStatusEnum.Failed))])
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
pretty_print_mock = mocker.patch("ahriman.models.package.Package.pretty_print")
Status.run(args, "x86_64", configuration, True)
@ -76,7 +76,7 @@ def test_imply_with_report(args: argparse.Namespace, configuration: Configuratio
must create application object with native reporting
"""
args = _default_args(args)
mocker.patch("pathlib.Path.mkdir")
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)

View File

@ -26,7 +26,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
must run command
"""
args = _default_args(args)
mocker.patch("pathlib.Path.mkdir")
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)
@ -40,7 +40,7 @@ def test_run_packages(args: argparse.Namespace, configuration: Configuration, pa
"""
args = _default_args(args)
args.package = [package_ahriman.base]
mocker.patch("pathlib.Path.mkdir")
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)
@ -55,7 +55,7 @@ def test_run_remove(args: argparse.Namespace, configuration: Configuration, pack
args = _default_args(args)
args.package = [package_ahriman.base]
args.action = Action.Remove
mocker.patch("pathlib.Path.mkdir")
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)
@ -67,7 +67,7 @@ def test_imply_with_report(args: argparse.Namespace, configuration: Configuratio
must create application object with native reporting
"""
args = _default_args(args)
mocker.patch("pathlib.Path.mkdir")
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)

View File

@ -21,7 +21,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
must run command
"""
args = _default_args(args)
mocker.patch("pathlib.Path.mkdir")
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
application_mock = mocker.patch("ahriman.application.application.Application.sync")
Sync.run(args, "x86_64", configuration, True)

View File

@ -26,7 +26,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
must run command
"""
args = _default_args(args)
mocker.patch("pathlib.Path.mkdir")
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
application_mock = mocker.patch("ahriman.application.application.Application.update")
updates_mock = mocker.patch("ahriman.application.application.Application.get_updates")
@ -41,7 +41,7 @@ def test_run_dry_run(args: argparse.Namespace, configuration: Configuration, moc
"""
args = _default_args(args)
args.dry_run = True
mocker.patch("pathlib.Path.mkdir")
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
updates_mock = mocker.patch("ahriman.application.application.Application.get_updates")
Update.run(args, "x86_64", configuration, True)

View File

@ -33,7 +33,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
must run command
"""
args = _default_args(args)
mocker.patch("pathlib.Path.mkdir")
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
get_auth_configuration_mock = mocker.patch("ahriman.application.handlers.User.configuration_get")
create_configuration_mock = mocker.patch("ahriman.application.handlers.User.configuration_create")
write_configuration_mock = mocker.patch("ahriman.application.handlers.User.configuration_write")
@ -56,7 +56,7 @@ def test_run_remove(args: argparse.Namespace, configuration: Configuration, mock
"""
args = _default_args(args)
args.action = Action.Remove
mocker.patch("pathlib.Path.mkdir")
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
get_auth_configuration_mock = mocker.patch("ahriman.application.handlers.User.configuration_get")
create_configuration_mock = mocker.patch("ahriman.application.handlers.User.configuration_create")
write_configuration_mock = mocker.patch("ahriman.application.handlers.User.configuration_write")

View File

@ -21,8 +21,8 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
must run command
"""
args = _default_args(args)
mocker.patch("pathlib.Path.mkdir")
mocker.patch("ahriman.core.spawn.Spawn.start")
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
setup_mock = mocker.patch("ahriman.web.web.setup_service")
run_mock = mocker.patch("ahriman.web.web.run_server")