mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-06-28 06:41:43 +00:00
improve repo-setup command
* Move devtools executable to ahriman home, because we don't really need to use executable inside root * Use named sudoers file instead of single file. It will allow easily to remove file as well as use setup command for several repositories/architectures
This commit is contained in:
@ -33,7 +33,8 @@ def _default_args(args: argparse.Namespace) -> argparse.Namespace:
|
||||
return args
|
||||
|
||||
|
||||
def test_run(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
def test_run(args: argparse.Namespace, configuration: Configuration, repository_paths: RepositoryPaths,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must run command
|
||||
"""
|
||||
@ -45,15 +46,15 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
||||
sudo_configuration_mock = mocker.patch("ahriman.application.handlers.Setup.configuration_create_sudo")
|
||||
executable_mock = mocker.patch("ahriman.application.handlers.Setup.executable_create")
|
||||
init_mock = mocker.patch("ahriman.core.alpm.repo.Repo.init")
|
||||
paths = RepositoryPaths(configuration.getpath("repository", "root"), "x86_64")
|
||||
|
||||
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)
|
||||
makepkg_configuration_mock.assert_called_once_with(args.packager, paths)
|
||||
sudo_configuration_mock.assert_called_once_with(args.build_command, "x86_64")
|
||||
executable_mock.assert_called_once_with(args.build_command, "x86_64")
|
||||
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)
|
||||
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")
|
||||
init_mock.assert_called_once()
|
||||
|
||||
|
||||
@ -62,11 +63,15 @@ def test_build_command(args: argparse.Namespace) -> None:
|
||||
must generate correct build command name
|
||||
"""
|
||||
args = _default_args(args)
|
||||
assert Setup.build_command(args.build_command, "x86_64").name == f"{args.build_command}-x86_64-build"
|
||||
path = Path("local")
|
||||
|
||||
build_command = Setup.build_command(path, args.build_command, "x86_64")
|
||||
assert build_command.name == f"{args.build_command}-x86_64-build"
|
||||
assert build_command.parent == path
|
||||
|
||||
|
||||
def test_configuration_create_ahriman(args: argparse.Namespace, configuration: Configuration,
|
||||
mocker: MockerFixture) -> None:
|
||||
repository_paths: RepositoryPaths, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must create configuration for the service
|
||||
"""
|
||||
@ -74,9 +79,9 @@ def test_configuration_create_ahriman(args: argparse.Namespace, configuration: C
|
||||
mocker.patch("pathlib.Path.open")
|
||||
set_option_mock = mocker.patch("ahriman.core.configuration.Configuration.set_option")
|
||||
write_mock = mocker.patch("ahriman.core.configuration.Configuration.write")
|
||||
command = Setup.build_command(repository_paths.root, args.build_command, "x86_64")
|
||||
|
||||
command = Setup.build_command(args.build_command, "x86_64")
|
||||
Setup.configuration_create_ahriman(args, "x86_64", args.repository, configuration.include)
|
||||
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),
|
||||
@ -136,7 +141,8 @@ def test_configuration_create_makepkg(args: argparse.Namespace, repository_paths
|
||||
write_text_mock.assert_called_once_with(pytest.helpers.anyvar(str, True), encoding="utf8")
|
||||
|
||||
|
||||
def test_configuration_create_sudo(args: argparse.Namespace, mocker: MockerFixture) -> None:
|
||||
def test_configuration_create_sudo(args: argparse.Namespace, repository_paths: RepositoryPaths,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must create sudo configuration
|
||||
"""
|
||||
@ -144,22 +150,24 @@ def test_configuration_create_sudo(args: argparse.Namespace, mocker: MockerFixtu
|
||||
chmod_text_mock = mocker.patch("pathlib.Path.chmod")
|
||||
write_text_mock = mocker.patch("pathlib.Path.write_text")
|
||||
|
||||
Setup.configuration_create_sudo(args.build_command, "x86_64")
|
||||
Setup.configuration_create_sudo(repository_paths, args.build_command, "x86_64")
|
||||
chmod_text_mock.assert_called_once_with(0o400)
|
||||
write_text_mock.assert_called_once_with(pytest.helpers.anyvar(str, True), encoding="utf8")
|
||||
|
||||
|
||||
def test_executable_create(args: argparse.Namespace, mocker: MockerFixture) -> None:
|
||||
def test_executable_create(args: argparse.Namespace, repository_paths: RepositoryPaths, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must create executable
|
||||
"""
|
||||
args = _default_args(args)
|
||||
symlink_text_mock = mocker.patch("pathlib.Path.symlink_to")
|
||||
unlink_text_mock = mocker.patch("pathlib.Path.unlink")
|
||||
chown_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.chown")
|
||||
symlink_mock = mocker.patch("pathlib.Path.symlink_to")
|
||||
unlink_mock = mocker.patch("pathlib.Path.unlink")
|
||||
|
||||
Setup.executable_create(args.build_command, "x86_64")
|
||||
symlink_text_mock.assert_called_once_with(Setup.ARCHBUILD_COMMAND_PATH)
|
||||
unlink_text_mock.assert_called_once_with(missing_ok=True)
|
||||
Setup.executable_create(repository_paths, args.build_command, "x86_64")
|
||||
chown_mock.assert_called_once_with(Setup.build_command(repository_paths.root, args.build_command, "x86_64"))
|
||||
symlink_mock.assert_called_once_with(Setup.ARCHBUILD_COMMAND_PATH)
|
||||
unlink_mock.assert_called_once_with(missing_ok=True)
|
||||
|
||||
|
||||
def test_disallow_auto_architecture_run() -> None:
|
||||
|
Reference in New Issue
Block a user