add docker support (#52)

* add docker support

* make shellcheck happy
This commit is contained in:
2022-03-13 23:43:25 +03:00
committed by GitHub
parent 9f4acacada
commit 61efbb71a2
59 changed files with 429 additions and 103 deletions

View File

@ -17,7 +17,7 @@ def application_packages(configuration: Configuration, mocker: MockerFixture) ->
:return: application test instance
"""
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
return Packages("x86_64", configuration, no_report=True)
return Packages("x86_64", configuration, no_report=True, unsafe=False)
@pytest.fixture
@ -29,7 +29,7 @@ def application_properties(configuration: Configuration, mocker: MockerFixture)
:return: application test instance
"""
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
return Properties("x86_64", configuration, no_report=True)
return Properties("x86_64", configuration, no_report=True, unsafe=False)
@pytest.fixture
@ -41,4 +41,4 @@ def application_repository(configuration: Configuration, mocker: MockerFixture)
:return: application test instance
"""
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
return Repository("x86_64", configuration, no_report=True)
return Repository("x86_64", configuration, no_report=True, unsafe=False)

View File

@ -18,7 +18,7 @@ def application(configuration: Configuration, mocker: MockerFixture) -> Applicat
:return: application test instance
"""
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
return Application("x86_64", configuration, no_report=True)
return Application("x86_64", configuration, no_report=True, unsafe=False)
@pytest.fixture

View File

@ -114,4 +114,4 @@ 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)
Handler.run(args, "x86_64", configuration, True, True)

View File

@ -30,7 +30,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.application.application.Application.add")
Add.run(args, "x86_64", configuration, True)
Add.run(args, "x86_64", configuration, True, False)
application_mock.assert_called_once_with(args.package, args.source, args.without_dependencies)
@ -46,6 +46,6 @@ def test_run_with_updates(args: argparse.Namespace, configuration: Configuration
application_mock = mocker.patch("ahriman.application.application.Application.update")
updates_mock = mocker.patch("ahriman.application.application.Application.updates", return_value=[package_ahriman])
Add.run(args, "x86_64", configuration, True)
Add.run(args, "x86_64", configuration, True, False)
updates_mock.assert_called_once_with(args.package, True, True, False, True, pytest.helpers.anyvar(int))
application_mock.assert_called_once_with([package_ahriman])

View File

@ -29,5 +29,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.clean")
Clean.run(args, "x86_64", configuration, True)
Clean.run(args, "x86_64", configuration, True, False)
application_mock.assert_called_once_with(False, False, False, False, False, False)

View File

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

View File

@ -14,7 +14,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
tree_create_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
init_mock = mocker.patch("ahriman.core.alpm.repo.Repo.init")
Init.run(args, "x86_64", configuration, True)
Init.run(args, "x86_64", configuration, True, False)
tree_create_mock.assert_called_once_with()
init_mock.assert_called_once_with()

View File

@ -25,7 +25,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)
KeyImport.run(args, "x86_64", configuration, True, False)
application_mock.assert_called_once_with(args.key_server, args.key)

View File

@ -32,7 +32,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.application.handlers.patch.Patch.patch_set_create")
Patch.run(args, "x86_64", configuration, True)
Patch.run(args, "x86_64", configuration, True, False)
application_mock.assert_called_once_with(pytest.helpers.anyvar(int), args.package, args.track)
@ -45,7 +45,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.patch_set_list")
Patch.run(args, "x86_64", configuration, True)
Patch.run(args, "x86_64", configuration, True, False)
application_mock.assert_called_once_with(pytest.helpers.anyvar(int), args.package)
@ -58,7 +58,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.patch_set_remove")
Patch.run(args, "x86_64", configuration, True)
Patch.run(args, "x86_64", configuration, True, False)
application_mock.assert_called_once_with(pytest.helpers.anyvar(int), args.package)

View File

@ -29,7 +29,7 @@ def test_run(args: argparse.Namespace, package_ahriman: Package,
return_value=[package_ahriman])
application_mock = mocker.patch("ahriman.application.application.Application.update")
Rebuild.run(args, "x86_64", configuration, True)
Rebuild.run(args, "x86_64", configuration, True, False)
application_packages_mock.assert_called_once_with(None)
application_mock.assert_called_once_with([package_ahriman])
@ -45,7 +45,7 @@ def test_run_dry_run(args: argparse.Namespace, configuration: Configuration,
mocker.patch("ahriman.core.repository.repository.Repository.packages_depends_on", return_value=[package_ahriman])
application_mock = mocker.patch("ahriman.application.application.Application.update")
Rebuild.run(args, "x86_64", configuration, True)
Rebuild.run(args, "x86_64", configuration, True, False)
application_mock.assert_not_called()
@ -59,7 +59,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_depends_on")
Rebuild.run(args, "x86_64", configuration, True)
Rebuild.run(args, "x86_64", configuration, True, False)
application_packages_mock.assert_called_once_with({"python-aur"})
@ -72,5 +72,5 @@ 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_depends_on")
Rebuild.run(args, "x86_64", configuration, True)
Rebuild.run(args, "x86_64", configuration, True, False)
application_packages_mock.assert_called_once_with(None)

View File

@ -24,5 +24,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.remove")
Remove.run(args, "x86_64", configuration, True)
Remove.run(args, "x86_64", configuration, True, False)
application_mock.assert_called_once_with([])

View File

@ -29,7 +29,7 @@ def test_run(args: argparse.Namespace, package_ahriman: Package,
return_value=[package_ahriman])
remove_mock = mocker.patch("ahriman.application.application.Application.remove")
RemoveUnknown.run(args, "x86_64", configuration, True)
RemoveUnknown.run(args, "x86_64", configuration, True, False)
application_mock.assert_called_once_with()
remove_mock.assert_called_once_with([package_ahriman])
@ -47,7 +47,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.application.formatters.printer.Printer.print")
RemoveUnknown.run(args, "x86_64", configuration, True)
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(False)
@ -67,7 +67,7 @@ def test_run_dry_run_verbose(args: argparse.Namespace, configuration: Configurat
remove_mock = mocker.patch("ahriman.application.application.Application.remove")
print_mock = mocker.patch("ahriman.application.formatters.printer.Printer.print")
RemoveUnknown.run(args, "x86_64", configuration, True)
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)

View File

@ -24,5 +24,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.report")
Report.run(args, "x86_64", configuration, True)
Report.run(args, "x86_64", configuration, True, False)
application_mock.assert_called_once_with(args.target, [])

View File

@ -31,7 +31,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, aur_package
search_mock = mocker.patch("ahriman.core.alpm.aur.AUR.multisearch", return_value=[aur_package_ahriman])
print_mock = mocker.patch("ahriman.application.formatters.printer.Printer.print")
Search.run(args, "x86_64", configuration, True)
Search.run(args, "x86_64", configuration, True, False)
search_mock.assert_called_once_with("ahriman")
print_mock.assert_called_once_with(False)
@ -45,7 +45,7 @@ def test_run_sort(args: argparse.Namespace, configuration: Configuration, aur_pa
mocker.patch("ahriman.core.alpm.aur.AUR.multisearch", return_value=[aur_package_ahriman])
sort_mock = mocker.patch("ahriman.application.handlers.search.Search.sort")
Search.run(args, "x86_64", configuration, True)
Search.run(args, "x86_64", configuration, True, False)
sort_mock.assert_called_once_with([aur_package_ahriman], "name")
@ -59,7 +59,7 @@ def test_run_sort_by(args: argparse.Namespace, configuration: Configuration, aur
mocker.patch("ahriman.core.alpm.aur.AUR.multisearch", return_value=[aur_package_ahriman])
sort_mock = mocker.patch("ahriman.application.handlers.search.Search.sort")
Search.run(args, "x86_64", configuration, True)
Search.run(args, "x86_64", configuration, True, False)
sort_mock.assert_called_once_with([aur_package_ahriman], "field")

View File

@ -17,6 +17,7 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
:param args: command line arguments fixture
:return: generated arguments for these test cases
"""
args.build_as_user = "ahriman"
args.build_command = "ahriman"
args.from_configuration = Path("/usr/share/devtools/pacman-extra.conf")
args.no_multilib = False
@ -41,7 +42,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
executable_mock = mocker.patch("ahriman.application.handlers.setup.Setup.executable_create")
paths = RepositoryPaths(configuration.getpath("repository", "root"), "x86_64")
Setup.run(args, "x86_64", configuration, True)
Setup.run(args, "x86_64", configuration, True, False)
ahriman_configuration_mock.assert_called_once_with(args, "x86_64", args.repository, configuration.include)
devtools_configuration_mock.assert_called_once_with(args.build_command, "x86_64", args.from_configuration,
args.no_multilib, args.repository, paths)
@ -73,6 +74,7 @@ def test_configuration_create_ahriman(args: argparse.Namespace, configuration: C
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),

View File

@ -24,5 +24,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)
Sign.run(args, "x86_64", configuration, True, False)
application_mock.assert_called_once_with([])

View File

@ -35,7 +35,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, package_ahr
(package_python_schedule, BuildStatus(BuildStatusEnum.Failed))])
print_mock = mocker.patch("ahriman.application.formatters.printer.Printer.print")
Status.run(args, "x86_64", configuration, True)
Status.run(args, "x86_64", configuration, True, False)
application_mock.assert_called_once_with()
packages_mock.assert_called_once_with(None)
print_mock.assert_has_calls([mock.call(False) for _ in range(3)])
@ -53,7 +53,7 @@ def test_run_verbose(args: argparse.Namespace, configuration: Configuration, pac
return_value=[(package_ahriman, BuildStatus(BuildStatusEnum.Success))])
print_mock = mocker.patch("ahriman.application.formatters.printer.Printer.print")
Status.run(args, "x86_64", configuration, True)
Status.run(args, "x86_64", configuration, True, False)
print_mock.assert_has_calls([mock.call(True) for _ in range(2)])
@ -68,7 +68,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)
Status.run(args, "x86_64", configuration, True, False)
packages_mock.assert_called_once_with(package_ahriman.base)
@ -85,7 +85,7 @@ 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.application.formatters.printer.Printer.print")
Status.run(args, "x86_64", configuration, True)
Status.run(args, "x86_64", configuration, True, False)
print_mock.assert_has_calls([mock.call(False) for _ in range(2)])
@ -97,7 +97,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)
Status.run(args, "x86_64", configuration, True, False)
load_mock.assert_called_once_with(configuration)

View File

@ -29,7 +29,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)
StatusUpdate.run(args, "x86_64", configuration, True, False)
update_self_mock.assert_called_once_with(args.status)
@ -43,7 +43,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)
StatusUpdate.run(args, "x86_64", configuration, True, False)
update_mock.assert_called_once_with(package_ahriman.base, args.status)
@ -58,7 +58,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)
StatusUpdate.run(args, "x86_64", configuration, True, False)
update_mock.assert_called_once_with(package_ahriman.base)
@ -70,7 +70,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)
StatusUpdate.run(args, "x86_64", configuration, True, False)
load_mock.assert_called_once_with(configuration)

View File

@ -24,5 +24,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.sync")
Sync.run(args, "x86_64", configuration, True)
Sync.run(args, "x86_64", configuration, True, False)
application_mock.assert_called_once_with(args.target, [])

View File

@ -34,7 +34,7 @@ def test_run(args: argparse.Namespace, package_ahriman: Package,
application_mock = mocker.patch("ahriman.application.application.Application.update")
updates_mock = mocker.patch("ahriman.application.application.Application.updates", return_value=[package_ahriman])
Update.run(args, "x86_64", configuration, True)
Update.run(args, "x86_64", configuration, True, 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))
@ -49,7 +49,7 @@ def test_run_dry_run(args: argparse.Namespace, configuration: Configuration, moc
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
updates_mock = mocker.patch("ahriman.application.application.Application.updates")
Update.run(args, "x86_64", configuration, True)
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))

View File

@ -41,7 +41,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
get_salt_mock = mocker.patch("ahriman.application.handlers.User.get_salt")
reload_mock = mocker.patch("ahriman.core.status.client.Client.reload_auth")
User.run(args, "x86_64", configuration, True)
User.run(args, "x86_64", configuration, True, 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)
@ -63,7 +63,7 @@ def test_run_remove(args: argparse.Namespace, configuration: Configuration, mock
write_configuration_mock = mocker.patch("ahriman.application.handlers.User.configuration_write")
reload_mock = mocker.patch("ahriman.core.status.client.Client.reload_auth")
User.run(args, "x86_64", configuration, True)
User.run(args, "x86_64", configuration, True, False)
get_auth_configuration_mock.assert_called_once_with(configuration.include)
create_configuration_mock.assert_not_called()
write_configuration_mock.assert_called_once_with(pytest.helpers.anyvar(int), args.secure)
@ -81,7 +81,7 @@ def test_run_no_reload(args: argparse.Namespace, configuration: Configuration, m
mocker.patch("ahriman.application.handlers.User.configuration_write")
reload_mock = mocker.patch("ahriman.core.status.client.Client.reload_auth")
User.run(args, "x86_64", configuration, True)
User.run(args, "x86_64", configuration, True, False)
reload_mock.assert_not_called()

View File

@ -27,7 +27,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)
Web.run(args, "x86_64", configuration, True, False)
setup_mock.assert_called_once_with("x86_64", configuration, pytest.helpers.anyvar(int))
run_mock.assert_called_once_with(pytest.helpers.anyvar(int))

View File

@ -0,0 +1,33 @@
import argparse
import pytest
from pytest_mock import MockerFixture
from ahriman.application.ahriman import _parser
from ahriman.application.handlers import UnsafeCommands
from ahriman.core.configuration import Configuration
def test_run(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
"""
must run command
"""
args.parser = _parser
commands_mock = mocker.patch("ahriman.application.handlers.UnsafeCommands.get_unsafe_commands",
return_value=["command"])
print_mock = mocker.patch("ahriman.application.formatters.printer.Printer.print")
UnsafeCommands.run(args, "x86_64", configuration, True, False)
commands_mock.assert_called_once_with(pytest.helpers.anyvar(int))
print_mock.assert_called_once_with(verbose=True)
def test_get_unsafe_commands() -> None:
"""
must return unsafe commands
"""
parser = _parser()
subparser = next(action for action in parser._actions if isinstance(action, argparse._SubParsersAction))
commands = UnsafeCommands.get_unsafe_commands(parser)
for command in commands:
assert subparser.choices[command].get_default("unsafe")

View File

@ -65,6 +65,27 @@ def test_subparsers_aur_search_architecture(parser: argparse.ArgumentParser) ->
assert args.architecture == [""]
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
"""
args = parser.parse_args(["help-commands-unsafe"])
assert args.architecture == [""]
assert args.lock is None
assert args.no_report
assert args.quiet
assert args.unsafe
assert args.parser is not None and args.parser()
def test_subparsers_help_commands_unsafe_architecture(parser: argparse.ArgumentParser) -> None:
"""
help-ommands-unsafe command must correctly parse architecture list
"""
args = parser.parse_args(["-a", "x86_64", "help-commands-unsafe"])
assert args.architecture == [""]
def test_subparsers_key_import(parser: argparse.ArgumentParser) -> None:
"""
key-import command must imply architecture list, lock and no-report

View File

@ -82,7 +82,7 @@ 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.root)
check_user_patch.assert_called_once_with(lock.root, False)
def test_check_user_exception(lock: Lock, mocker: MockerFixture) -> None:

View File

@ -19,7 +19,7 @@ def cleaner(configuration: Configuration, mocker: MockerFixture) -> Cleaner:
:return: cleaner test instance
"""
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
return Cleaner("x86_64", configuration, no_report=True)
return Cleaner("x86_64", configuration, no_report=True, unsafe=False)
@pytest.fixture
@ -36,7 +36,7 @@ def executor(configuration: Configuration, mocker: MockerFixture) -> Executor:
mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_manual")
mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_packages")
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
return Executor("x86_64", configuration, no_report=True)
return Executor("x86_64", configuration, no_report=True, unsafe=False)
@pytest.fixture
@ -48,7 +48,7 @@ def repository(configuration: Configuration, mocker: MockerFixture) -> Repositor
:return: repository test instance
"""
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
return Repository("x86_64", configuration, no_report=True)
return Repository("x86_64", configuration, no_report=True, unsafe=False)
@pytest.fixture
@ -58,7 +58,7 @@ def properties(configuration: Configuration) -> Properties:
:param configuration: configuration fixture
:return: properties test instance
"""
return Properties("x86_64", configuration, no_report=True)
return Properties("x86_64", configuration, no_report=True, unsafe=False)
@pytest.fixture
@ -75,4 +75,4 @@ def update_handler(configuration: Configuration, mocker: MockerFixture) -> Updat
mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_manual")
mocker.patch("ahriman.core.repository.cleaner.Cleaner.clear_packages")
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
return UpdateHandler("x86_64", configuration, no_report=True)
return UpdateHandler("x86_64", configuration, no_report=True, unsafe=False)

View File

@ -12,7 +12,7 @@ def test_create_tree_on_load(configuration: Configuration, mocker: MockerFixture
"""
mocker.patch("ahriman.core.repository.properties.check_user")
tree_create_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
Properties("x86_64", configuration, True)
Properties("x86_64", configuration, True, False)
tree_create_mock.assert_called_once_with()
@ -23,7 +23,7 @@ def test_create_tree_on_load_unsafe(configuration: Configuration, mocker: Mocker
"""
mocker.patch("ahriman.core.repository.properties.check_user", side_effect=UnsafeRun(0, 1))
tree_create_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
Properties("x86_64", configuration, True)
Properties("x86_64", configuration, True, False)
tree_create_mock.assert_not_called()
@ -34,7 +34,7 @@ def test_create_dummy_report_client(configuration: Configuration, mocker: Mocker
"""
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
load_mock = mocker.patch("ahriman.core.status.client.Client.load")
properties = Properties("x86_64", configuration, True)
properties = Properties("x86_64", configuration, True, False)
load_mock.assert_not_called()
assert not isinstance(properties.reporter, WebClient)
@ -46,6 +46,6 @@ def test_create_full_report_client(configuration: Configuration, mocker: MockerF
"""
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
load_mock = mocker.patch("ahriman.core.status.client.Client.load")
Properties("x86_64", configuration, False)
Properties("x86_64", configuration, False, False)
load_mock.assert_called_once_with(configuration)

View File

@ -58,7 +58,7 @@ def test_check_user(mocker: MockerFixture) -> None:
"""
cwd = Path.cwd()
mocker.patch("os.getuid", return_value=cwd.stat().st_uid)
check_user(cwd)
check_user(cwd, False)
def test_check_user_no_directory(mocker: MockerFixture) -> None:
@ -66,7 +66,7 @@ def test_check_user_no_directory(mocker: MockerFixture) -> None:
must not fail in case if no directory found
"""
mocker.patch("pathlib.Path.exists", return_value=False)
check_user(Path.cwd())
check_user(Path.cwd(), False)
def test_check_user_exception(mocker: MockerFixture) -> None:
@ -77,7 +77,16 @@ def test_check_user_exception(mocker: MockerFixture) -> None:
mocker.patch("os.getuid", return_value=cwd.stat().st_uid + 1)
with pytest.raises(UnsafeRun):
check_user(cwd)
check_user(cwd, False)
def test_check_unsafe(mocker: MockerFixture) -> None:
"""
must skip check if unsafe flag is set
"""
cwd = Path.cwd()
mocker.patch("os.getuid", return_value=cwd.stat().st_uid + 1)
check_user(cwd, True)
def test_filter_json(package_ahriman: Package) -> None: