mirror of
				https://github.com/arcan1s/ahriman.git
				synced 2025-11-04 07:43:42 +00:00 
			
		
		
		
	change method spelling
in order to sort method correctly we are going to use the following
namiing schema:
{subject}_{action}_{details}
This schema still have some exceptions, e.g. single word methods, bool
methods (is_) and getters in case if they are singular (i.e. there is
no any other method with this subject)
			
			
This commit is contained in:
		@ -9,6 +9,48 @@ from ahriman.core.configuration import Configuration
 | 
			
		||||
from ahriman.core.exceptions import MissingArchitecture, MultipleArchitecture
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_architectures_extract(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must generate list of available architectures
 | 
			
		||||
    """
 | 
			
		||||
    args.configuration = configuration.path
 | 
			
		||||
    known_architectures_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_architectures")
 | 
			
		||||
 | 
			
		||||
    Handler.architectures_extract(args)
 | 
			
		||||
    known_architectures_mock.assert_called_once()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_architectures_extract_empty(args: argparse.Namespace, configuration: Configuration,
 | 
			
		||||
                                     mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must raise exception if no available architectures found
 | 
			
		||||
    """
 | 
			
		||||
    args.command = "config"
 | 
			
		||||
    args.configuration = configuration.path
 | 
			
		||||
    mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_architectures", return_value=set())
 | 
			
		||||
 | 
			
		||||
    with pytest.raises(MissingArchitecture):
 | 
			
		||||
        Handler.architectures_extract(args)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_architectures_extract_exception(args: argparse.Namespace, mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must raise exception on missing architectures
 | 
			
		||||
    """
 | 
			
		||||
    args.command = "config"
 | 
			
		||||
    mocker.patch.object(Handler, "ALLOW_AUTO_ARCHITECTURE_RUN", False)
 | 
			
		||||
    with pytest.raises(MissingArchitecture):
 | 
			
		||||
        Handler.architectures_extract(args)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_architectures_extract_specified(args: argparse.Namespace) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must return architecture list if it has been specified
 | 
			
		||||
    """
 | 
			
		||||
    architectures = args.architecture = ["i686", "x86_64"]
 | 
			
		||||
    assert Handler.architectures_extract(args) == set(architectures)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_call(args: argparse.Namespace, mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must call inside lock
 | 
			
		||||
@ -67,48 +109,6 @@ def test_execute_single(args: argparse.Namespace, mocker: MockerFixture) -> None
 | 
			
		||||
    starmap_mock.assert_not_called()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_extract_architectures(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must generate list of available architectures
 | 
			
		||||
    """
 | 
			
		||||
    args.configuration = configuration.path
 | 
			
		||||
    known_architectures_mock = mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_architectures")
 | 
			
		||||
 | 
			
		||||
    Handler.extract_architectures(args)
 | 
			
		||||
    known_architectures_mock.assert_called_once()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_extract_architectures_empty(args: argparse.Namespace, configuration: Configuration,
 | 
			
		||||
                                     mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must raise exception if no available architectures found
 | 
			
		||||
    """
 | 
			
		||||
    args.command = "config"
 | 
			
		||||
    args.configuration = configuration.path
 | 
			
		||||
    mocker.patch("ahriman.models.repository_paths.RepositoryPaths.known_architectures", return_value=set())
 | 
			
		||||
 | 
			
		||||
    with pytest.raises(MissingArchitecture):
 | 
			
		||||
        Handler.extract_architectures(args)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_extract_architectures_exception(args: argparse.Namespace, mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must raise exception on missing architectures
 | 
			
		||||
    """
 | 
			
		||||
    args.command = "config"
 | 
			
		||||
    mocker.patch.object(Handler, "ALLOW_AUTO_ARCHITECTURE_RUN", False)
 | 
			
		||||
    with pytest.raises(MissingArchitecture):
 | 
			
		||||
        Handler.extract_architectures(args)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_extract_architectures_specified(args: argparse.Namespace) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must return architecture list if it has been specified
 | 
			
		||||
    """
 | 
			
		||||
    architectures = args.architecture = ["i686", "x86_64"]
 | 
			
		||||
    assert Handler.extract_architectures(args) == set(architectures)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_run(args: argparse.Namespace, configuration: Configuration) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must raise NotImplemented for missing method
 | 
			
		||||
 | 
			
		||||
@ -23,7 +23,7 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
 | 
			
		||||
    """
 | 
			
		||||
    args = _default_args(args)
 | 
			
		||||
    mocker.patch("pathlib.Path.mkdir")
 | 
			
		||||
    application_mock = mocker.patch("ahriman.core.sign.gpg.GPG.import_key")
 | 
			
		||||
    application_mock = mocker.patch("ahriman.core.sign.gpg.GPG.key_import")
 | 
			
		||||
 | 
			
		||||
    KeyImport.run(args, "x86_64", configuration, True)
 | 
			
		||||
    application_mock.assert_called_once()
 | 
			
		||||
 | 
			
		||||
@ -33,11 +33,11 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
 | 
			
		||||
    """
 | 
			
		||||
    args = _default_args(args)
 | 
			
		||||
    mocker.patch("pathlib.Path.mkdir")
 | 
			
		||||
    ahriman_configuration_mock = mocker.patch("ahriman.application.handlers.setup.Setup.create_ahriman_configuration")
 | 
			
		||||
    devtools_configuration_mock = mocker.patch("ahriman.application.handlers.setup.Setup.create_devtools_configuration")
 | 
			
		||||
    makepkg_configuration_mock = mocker.patch("ahriman.application.handlers.setup.Setup.create_makepkg_configuration")
 | 
			
		||||
    sudo_configuration_mock = mocker.patch("ahriman.application.handlers.setup.Setup.create_sudo_configuration")
 | 
			
		||||
    executable_mock = mocker.patch("ahriman.application.handlers.setup.Setup.create_executable")
 | 
			
		||||
    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")
 | 
			
		||||
    sudo_configuration_mock = mocker.patch("ahriman.application.handlers.setup.Setup.configuration_create_sudo")
 | 
			
		||||
    executable_mock = mocker.patch("ahriman.application.handlers.setup.Setup.executable_create")
 | 
			
		||||
 | 
			
		||||
    Setup.run(args, "x86_64", configuration, True)
 | 
			
		||||
    ahriman_configuration_mock.assert_called_once()
 | 
			
		||||
@ -55,7 +55,7 @@ def test_build_command(args: argparse.Namespace) -> None:
 | 
			
		||||
    assert Setup.build_command(args.build_command, "x86_64").name == f"{args.build_command}-x86_64-build"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_create_ahriman_configuration(args: argparse.Namespace, configuration: Configuration,
 | 
			
		||||
def test_configuration_create_ahriman(args: argparse.Namespace, configuration: Configuration,
 | 
			
		||||
                                      mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must create configuration for the service
 | 
			
		||||
@ -66,7 +66,7 @@ def test_create_ahriman_configuration(args: argparse.Namespace, configuration: C
 | 
			
		||||
    write_mock = mocker.patch("ahriman.core.configuration.Configuration.write")
 | 
			
		||||
 | 
			
		||||
    command = Setup.build_command(args.build_command, "x86_64")
 | 
			
		||||
    Setup.create_ahriman_configuration(args, "x86_64", args.repository, configuration.include)
 | 
			
		||||
    Setup.configuration_create_ahriman(args, "x86_64", args.repository, configuration.include)
 | 
			
		||||
    set_option_mock.assert_has_calls([
 | 
			
		||||
        mock.call(Configuration.section_name("build", "x86_64"), "build_command", str(command)),
 | 
			
		||||
        mock.call("repository", "name", args.repository),
 | 
			
		||||
@ -78,7 +78,7 @@ def test_create_ahriman_configuration(args: argparse.Namespace, configuration: C
 | 
			
		||||
    write_mock.assert_called_once()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_create_devtools_configuration(args: argparse.Namespace, repository_paths: RepositoryPaths,
 | 
			
		||||
def test_configuration_create_devtools(args: argparse.Namespace, repository_paths: RepositoryPaths,
 | 
			
		||||
                                       mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must create configuration for the devtools
 | 
			
		||||
@ -89,7 +89,7 @@ def test_create_devtools_configuration(args: argparse.Namespace, repository_path
 | 
			
		||||
    add_section_mock = mocker.patch("ahriman.core.configuration.Configuration.add_section")
 | 
			
		||||
    write_mock = mocker.patch("ahriman.core.configuration.Configuration.write")
 | 
			
		||||
 | 
			
		||||
    Setup.create_devtools_configuration(args.build_command, "x86_64", args.from_configuration,
 | 
			
		||||
    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"),
 | 
			
		||||
@ -98,7 +98,7 @@ def test_create_devtools_configuration(args: argparse.Namespace, repository_path
 | 
			
		||||
    write_mock.assert_called_once()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_create_devtools_configuration_no_multilib(args: argparse.Namespace, repository_paths: RepositoryPaths,
 | 
			
		||||
def test_configuration_create_devtools_no_multilib(args: argparse.Namespace, repository_paths: RepositoryPaths,
 | 
			
		||||
                                                   mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must create configuration for the devtools without multilib
 | 
			
		||||
@ -108,12 +108,12 @@ def test_create_devtools_configuration_no_multilib(args: argparse.Namespace, rep
 | 
			
		||||
    mocker.patch("ahriman.core.configuration.Configuration.set")
 | 
			
		||||
    write_mock = mocker.patch("ahriman.core.configuration.Configuration.write")
 | 
			
		||||
 | 
			
		||||
    Setup.create_devtools_configuration(args.build_command, "x86_64", args.from_configuration,
 | 
			
		||||
    Setup.configuration_create_devtools(args.build_command, "x86_64", args.from_configuration,
 | 
			
		||||
                                        True, args.repository, repository_paths)
 | 
			
		||||
    write_mock.assert_called_once()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_create_makepkg_configuration(args: argparse.Namespace, repository_paths: RepositoryPaths,
 | 
			
		||||
def test_configuration_create_makepkg(args: argparse.Namespace, repository_paths: RepositoryPaths,
 | 
			
		||||
                                      mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must create makepkg configuration
 | 
			
		||||
@ -121,11 +121,11 @@ def test_create_makepkg_configuration(args: argparse.Namespace, repository_paths
 | 
			
		||||
    args = _default_args(args)
 | 
			
		||||
    write_text_mock = mocker.patch("pathlib.Path.write_text")
 | 
			
		||||
 | 
			
		||||
    Setup.create_makepkg_configuration(args.packager, repository_paths)
 | 
			
		||||
    Setup.configuration_create_makepkg(args.packager, repository_paths)
 | 
			
		||||
    write_text_mock.assert_called_once()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_create_sudo_configuration(args: argparse.Namespace, mocker: MockerFixture) -> None:
 | 
			
		||||
def test_configuration_create_sudo(args: argparse.Namespace, mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must create sudo configuration
 | 
			
		||||
    """
 | 
			
		||||
@ -133,12 +133,12 @@ def test_create_sudo_configuration(args: argparse.Namespace, mocker: MockerFixtu
 | 
			
		||||
    chmod_text_mock = mocker.patch("pathlib.Path.chmod")
 | 
			
		||||
    write_text_mock = mocker.patch("pathlib.Path.write_text")
 | 
			
		||||
 | 
			
		||||
    Setup.create_sudo_configuration(args.build_command, "x86_64")
 | 
			
		||||
    Setup.configuration_create_sudo(args.build_command, "x86_64")
 | 
			
		||||
    chmod_text_mock.assert_called_once_with(0o400)
 | 
			
		||||
    write_text_mock.assert_called_once()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_create_executable(args: argparse.Namespace, mocker: MockerFixture) -> None:
 | 
			
		||||
def test_executable_create(args: argparse.Namespace, mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must create executable
 | 
			
		||||
    """
 | 
			
		||||
@ -146,7 +146,7 @@ def test_create_executable(args: argparse.Namespace, mocker: MockerFixture) -> N
 | 
			
		||||
    symlink_text_mock = mocker.patch("pathlib.Path.symlink_to")
 | 
			
		||||
    unlink_text_mock = mocker.patch("pathlib.Path.unlink")
 | 
			
		||||
 | 
			
		||||
    Setup.create_executable(args.build_command, "x86_64")
 | 
			
		||||
    Setup.executable_create(args.build_command, "x86_64")
 | 
			
		||||
    symlink_text_mock.assert_called_once()
 | 
			
		||||
    unlink_text_mock.assert_called_once()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -34,17 +34,17 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
 | 
			
		||||
    """
 | 
			
		||||
    args = _default_args(args)
 | 
			
		||||
    mocker.patch("pathlib.Path.mkdir")
 | 
			
		||||
    get_auth_configuration_mock = mocker.patch("ahriman.application.handlers.User.get_auth_configuration")
 | 
			
		||||
    create_configuration_mock = mocker.patch("ahriman.application.handlers.User.create_configuration")
 | 
			
		||||
    write_configuration_mock = mocker.patch("ahriman.application.handlers.User.write_configuration")
 | 
			
		||||
    create_user = mocker.patch("ahriman.application.handlers.User.create_user")
 | 
			
		||||
    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")
 | 
			
		||||
    create_user_mock = mocker.patch("ahriman.application.handlers.User.user_create")
 | 
			
		||||
    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)
 | 
			
		||||
    get_auth_configuration_mock.assert_called_once()
 | 
			
		||||
    create_configuration_mock.assert_called_once()
 | 
			
		||||
    create_user.assert_called_once()
 | 
			
		||||
    create_user_mock.assert_called_once()
 | 
			
		||||
    get_salt_mock.assert_called_once()
 | 
			
		||||
    write_configuration_mock.assert_called_once()
 | 
			
		||||
    reload_mock.assert_called_once()
 | 
			
		||||
@ -57,9 +57,9 @@ def test_run_remove(args: argparse.Namespace, configuration: Configuration, mock
 | 
			
		||||
    args = _default_args(args)
 | 
			
		||||
    args.action = Action.Remove
 | 
			
		||||
    mocker.patch("pathlib.Path.mkdir")
 | 
			
		||||
    get_auth_configuration_mock = mocker.patch("ahriman.application.handlers.User.get_auth_configuration")
 | 
			
		||||
    create_configuration_mock = mocker.patch("ahriman.application.handlers.User.create_configuration")
 | 
			
		||||
    write_configuration_mock = mocker.patch("ahriman.application.handlers.User.write_configuration")
 | 
			
		||||
    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")
 | 
			
		||||
    reload_mock = mocker.patch("ahriman.core.status.client.Client.reload_auth")
 | 
			
		||||
 | 
			
		||||
    User.run(args, "x86_64", configuration, True)
 | 
			
		||||
@ -75,41 +75,16 @@ def test_run_no_reload(args: argparse.Namespace, configuration: Configuration, m
 | 
			
		||||
    """
 | 
			
		||||
    args = _default_args(args)
 | 
			
		||||
    args.no_reload = True
 | 
			
		||||
    mocker.patch("ahriman.application.handlers.User.get_auth_configuration")
 | 
			
		||||
    mocker.patch("ahriman.application.handlers.User.create_configuration")
 | 
			
		||||
    mocker.patch("ahriman.application.handlers.User.write_configuration")
 | 
			
		||||
    mocker.patch("ahriman.application.handlers.User.configuration_get")
 | 
			
		||||
    mocker.patch("ahriman.application.handlers.User.configuration_create")
 | 
			
		||||
    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)
 | 
			
		||||
    reload_mock.assert_not_called()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_clear_user(configuration: Configuration, user: MUser) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must clear user from configuration
 | 
			
		||||
    """
 | 
			
		||||
    section = Configuration.section_name("auth", user.access.value)
 | 
			
		||||
    configuration.set_option(section, user.username, user.password)
 | 
			
		||||
 | 
			
		||||
    User.clear_user(configuration, user)
 | 
			
		||||
    assert configuration.get(section, user.username, fallback=None) is None
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_clear_user_multiple_sections(configuration: Configuration, user: MUser) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must clear user from configuration from all sections
 | 
			
		||||
    """
 | 
			
		||||
    for role in UserAccess:
 | 
			
		||||
        section = Configuration.section_name("auth", role.value)
 | 
			
		||||
        configuration.set_option(section, user.username, user.password)
 | 
			
		||||
 | 
			
		||||
    User.clear_user(configuration, user)
 | 
			
		||||
    for role in UserAccess:
 | 
			
		||||
        section = Configuration.section_name("auth", role.value)
 | 
			
		||||
        assert configuration.get(section, user.username, fallback=None) is None
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_create_configuration(configuration: Configuration, user: MUser, mocker: MockerFixture) -> None:
 | 
			
		||||
def test_configuration_create(configuration: Configuration, user: MUser, mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must correctly create configuration file
 | 
			
		||||
    """
 | 
			
		||||
@ -117,14 +92,14 @@ def test_create_configuration(configuration: Configuration, user: MUser, mocker:
 | 
			
		||||
    mocker.patch("pathlib.Path.open")
 | 
			
		||||
    set_mock = mocker.patch("ahriman.core.configuration.Configuration.set_option")
 | 
			
		||||
 | 
			
		||||
    User.create_configuration(configuration, user, "salt", False)
 | 
			
		||||
    User.configuration_create(configuration, user, "salt", False)
 | 
			
		||||
    set_mock.assert_has_calls([
 | 
			
		||||
        mock.call("auth", "salt", pytest.helpers.anyvar(str)),
 | 
			
		||||
        mock.call(section, user.username, pytest.helpers.anyvar(str))
 | 
			
		||||
    ])
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_create_configuration_user_exists(configuration: Configuration, user: MUser, mocker: MockerFixture) -> None:
 | 
			
		||||
def test_configuration_create_user_exists(configuration: Configuration, user: MUser, mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must correctly update configuration file if user already exists
 | 
			
		||||
    """
 | 
			
		||||
@ -132,12 +107,12 @@ def test_create_configuration_user_exists(configuration: Configuration, user: MU
 | 
			
		||||
    configuration.set_option(section, user.username, "")
 | 
			
		||||
    mocker.patch("pathlib.Path.open")
 | 
			
		||||
 | 
			
		||||
    User.create_configuration(configuration, user, "salt", False)
 | 
			
		||||
    User.configuration_create(configuration, user, "salt", False)
 | 
			
		||||
    generated = MUser.from_option(user.username, configuration.get(section, user.username))
 | 
			
		||||
    assert generated.check_credentials(user.password, configuration.get("auth", "salt"))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_create_configuration_with_plain_password(
 | 
			
		||||
def test_configuration_create_with_plain_password(
 | 
			
		||||
        configuration: Configuration,
 | 
			
		||||
        user: MUser,
 | 
			
		||||
        mocker: MockerFixture) -> None:
 | 
			
		||||
@ -147,7 +122,7 @@ def test_create_configuration_with_plain_password(
 | 
			
		||||
    section = Configuration.section_name("auth", user.access.value)
 | 
			
		||||
    mocker.patch("pathlib.Path.open")
 | 
			
		||||
 | 
			
		||||
    User.create_configuration(configuration, user, "salt", True)
 | 
			
		||||
    User.configuration_create(configuration, user, "salt", True)
 | 
			
		||||
 | 
			
		||||
    generated = MUser.from_option(user.username, configuration.get(section, user.username))
 | 
			
		||||
    service = MUser.from_option(configuration.get("web", "username"), configuration.get("web", "password"))
 | 
			
		||||
@ -155,28 +130,67 @@ def test_create_configuration_with_plain_password(
 | 
			
		||||
    assert generated.check_credentials(service.password, configuration.get("auth", "salt"))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_create_user(args: argparse.Namespace, user: MUser) -> None:
 | 
			
		||||
def test_configuration_get_exists(mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must create user
 | 
			
		||||
    must load configuration from filesystem
 | 
			
		||||
    """
 | 
			
		||||
    args = _default_args(args)
 | 
			
		||||
    generated = User.create_user(args)
 | 
			
		||||
    assert generated.username == user.username
 | 
			
		||||
    assert generated.access == user.access
 | 
			
		||||
    mocker.patch("pathlib.Path.open")
 | 
			
		||||
    mocker.patch("pathlib.Path.is_file", return_value=True)
 | 
			
		||||
    read_mock = mocker.patch("ahriman.core.configuration.Configuration.read")
 | 
			
		||||
 | 
			
		||||
    assert User.configuration_get(Path("path"))
 | 
			
		||||
    read_mock.assert_called_once()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_create_user_getpass(args: argparse.Namespace, mocker: MockerFixture) -> None:
 | 
			
		||||
def test_configuration_get_not_exists(mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must create user and get password from command line
 | 
			
		||||
    must try to load configuration from filesystem
 | 
			
		||||
    """
 | 
			
		||||
    args = _default_args(args)
 | 
			
		||||
    args.password = None
 | 
			
		||||
    mocker.patch("pathlib.Path.open")
 | 
			
		||||
    mocker.patch("pathlib.Path.is_file", return_value=False)
 | 
			
		||||
    read_mock = mocker.patch("ahriman.core.configuration.Configuration.read")
 | 
			
		||||
 | 
			
		||||
    getpass_mock = mocker.patch("getpass.getpass", return_value="password")
 | 
			
		||||
    generated = User.create_user(args)
 | 
			
		||||
    assert User.configuration_get(Path("path"))
 | 
			
		||||
    read_mock.assert_called_once()
 | 
			
		||||
 | 
			
		||||
    getpass_mock.assert_called_once()
 | 
			
		||||
    assert generated.password == "password"
 | 
			
		||||
 | 
			
		||||
def test_configuration_write(configuration: Configuration, mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must write configuration
 | 
			
		||||
    """
 | 
			
		||||
    mocker.patch("pathlib.Path.open")
 | 
			
		||||
    write_mock = mocker.patch("ahriman.core.configuration.Configuration.write")
 | 
			
		||||
    chmod_mock = mocker.patch("pathlib.Path.chmod")
 | 
			
		||||
 | 
			
		||||
    User.configuration_write(configuration, secure=True)
 | 
			
		||||
    write_mock.assert_called_once()
 | 
			
		||||
    chmod_mock.assert_called_once()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_configuration_write_insecure(configuration: Configuration, mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must write configuration without setting file permissions
 | 
			
		||||
    """
 | 
			
		||||
    mocker.patch("pathlib.Path.open")
 | 
			
		||||
    mocker.patch("ahriman.core.configuration.Configuration.write")
 | 
			
		||||
    chmod_mock = mocker.patch("pathlib.Path.chmod")
 | 
			
		||||
 | 
			
		||||
    User.configuration_write(configuration, secure=False)
 | 
			
		||||
    chmod_mock.assert_not_called()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_configuration_write_not_loaded(configuration: Configuration, mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must do nothing in case if configuration is not loaded
 | 
			
		||||
    """
 | 
			
		||||
    configuration.path = None
 | 
			
		||||
    mocker.patch("pathlib.Path.open")
 | 
			
		||||
    write_mock = mocker.patch("ahriman.core.configuration.Configuration.write")
 | 
			
		||||
    chmod_mock = mocker.patch("pathlib.Path.chmod")
 | 
			
		||||
 | 
			
		||||
    User.configuration_write(configuration, secure=True)
 | 
			
		||||
    write_mock.assert_not_called()
 | 
			
		||||
    chmod_mock.assert_not_called()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_get_salt_read(configuration: Configuration) -> None:
 | 
			
		||||
@ -197,67 +211,53 @@ def test_get_salt_generate(configuration: Configuration) -> None:
 | 
			
		||||
    assert len(salt) == 16
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_get_auth_configuration_exists(mocker: MockerFixture) -> None:
 | 
			
		||||
def test_user_clear(configuration: Configuration, user: MUser) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must load configuration from filesystem
 | 
			
		||||
    must clear user from configuration
 | 
			
		||||
    """
 | 
			
		||||
    mocker.patch("pathlib.Path.open")
 | 
			
		||||
    mocker.patch("pathlib.Path.is_file", return_value=True)
 | 
			
		||||
    read_mock = mocker.patch("ahriman.core.configuration.Configuration.read")
 | 
			
		||||
    section = Configuration.section_name("auth", user.access.value)
 | 
			
		||||
    configuration.set_option(section, user.username, user.password)
 | 
			
		||||
 | 
			
		||||
    assert User.get_auth_configuration(Path("path"))
 | 
			
		||||
    read_mock.assert_called_once()
 | 
			
		||||
    User.user_clear(configuration, user)
 | 
			
		||||
    assert configuration.get(section, user.username, fallback=None) is None
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_get_auth_configuration_not_exists(mocker: MockerFixture) -> None:
 | 
			
		||||
def test_user_clear_multiple_sections(configuration: Configuration, user: MUser) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must try to load configuration from filesystem
 | 
			
		||||
    must clear user from configuration from all sections
 | 
			
		||||
    """
 | 
			
		||||
    mocker.patch("pathlib.Path.open")
 | 
			
		||||
    mocker.patch("pathlib.Path.is_file", return_value=False)
 | 
			
		||||
    read_mock = mocker.patch("ahriman.core.configuration.Configuration.read")
 | 
			
		||||
    for role in UserAccess:
 | 
			
		||||
        section = Configuration.section_name("auth", role.value)
 | 
			
		||||
        configuration.set_option(section, user.username, user.password)
 | 
			
		||||
 | 
			
		||||
    assert User.get_auth_configuration(Path("path"))
 | 
			
		||||
    read_mock.assert_called_once()
 | 
			
		||||
    User.user_clear(configuration, user)
 | 
			
		||||
    for role in UserAccess:
 | 
			
		||||
        section = Configuration.section_name("auth", role.value)
 | 
			
		||||
        assert configuration.get(section, user.username, fallback=None) is None
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_write_configuration(configuration: Configuration, mocker: MockerFixture) -> None:
 | 
			
		||||
def test_user_create(args: argparse.Namespace, user: MUser) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must write configuration
 | 
			
		||||
    must create user
 | 
			
		||||
    """
 | 
			
		||||
    mocker.patch("pathlib.Path.open")
 | 
			
		||||
    write_mock = mocker.patch("ahriman.core.configuration.Configuration.write")
 | 
			
		||||
    chmod_mock = mocker.patch("pathlib.Path.chmod")
 | 
			
		||||
 | 
			
		||||
    User.write_configuration(configuration, secure=True)
 | 
			
		||||
    write_mock.assert_called_once()
 | 
			
		||||
    chmod_mock.assert_called_once()
 | 
			
		||||
    args = _default_args(args)
 | 
			
		||||
    generated = User.user_create(args)
 | 
			
		||||
    assert generated.username == user.username
 | 
			
		||||
    assert generated.access == user.access
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_write_configuration_insecure(configuration: Configuration, mocker: MockerFixture) -> None:
 | 
			
		||||
def test_user_create_getpass(args: argparse.Namespace, mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must write configuration without setting file permissions
 | 
			
		||||
    must create user and get password from command line
 | 
			
		||||
    """
 | 
			
		||||
    mocker.patch("pathlib.Path.open")
 | 
			
		||||
    mocker.patch("ahriman.core.configuration.Configuration.write")
 | 
			
		||||
    chmod_mock = mocker.patch("pathlib.Path.chmod")
 | 
			
		||||
    args = _default_args(args)
 | 
			
		||||
    args.password = None
 | 
			
		||||
 | 
			
		||||
    User.write_configuration(configuration, secure=False)
 | 
			
		||||
    chmod_mock.assert_not_called()
 | 
			
		||||
    getpass_mock = mocker.patch("getpass.getpass", return_value="password")
 | 
			
		||||
    generated = User.user_create(args)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_write_configuration_not_loaded(configuration: Configuration, mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must do nothing in case if configuration is not loaded
 | 
			
		||||
    """
 | 
			
		||||
    configuration.path = None
 | 
			
		||||
    mocker.patch("pathlib.Path.open")
 | 
			
		||||
    write_mock = mocker.patch("ahriman.core.configuration.Configuration.write")
 | 
			
		||||
    chmod_mock = mocker.patch("pathlib.Path.chmod")
 | 
			
		||||
 | 
			
		||||
    User.write_configuration(configuration, secure=True)
 | 
			
		||||
    write_mock.assert_not_called()
 | 
			
		||||
    chmod_mock.assert_not_called()
 | 
			
		||||
    getpass_mock.assert_called_once()
 | 
			
		||||
    assert generated.password == "password"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_disallow_auto_architecture_run() -> None:
 | 
			
		||||
 | 
			
		||||
@ -263,7 +263,7 @@ def test_sign(application: Application, package_ahriman: Package, package_python
 | 
			
		||||
                 return_value=[package_ahriman, package_python_schedule])
 | 
			
		||||
    copy_mock = mocker.patch("shutil.copy")
 | 
			
		||||
    update_mock = mocker.patch("ahriman.application.application.Application.update")
 | 
			
		||||
    sign_repository_mock = mocker.patch("ahriman.core.sign.gpg.GPG.sign_repository")
 | 
			
		||||
    sign_repository_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process_sign_repository")
 | 
			
		||||
    finalize_mock = mocker.patch("ahriman.application.application.Application._finalize")
 | 
			
		||||
 | 
			
		||||
    application.sign([])
 | 
			
		||||
@ -296,7 +296,7 @@ def test_sign_specific(application: Application, package_ahriman: Package, packa
 | 
			
		||||
                 return_value=[package_ahriman, package_python_schedule])
 | 
			
		||||
    copy_mock = mocker.patch("shutil.copy")
 | 
			
		||||
    update_mock = mocker.patch("ahriman.application.application.Application.update")
 | 
			
		||||
    sign_repository_mock = mocker.patch("ahriman.core.sign.gpg.GPG.sign_repository")
 | 
			
		||||
    sign_repository_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process_sign_repository")
 | 
			
		||||
    finalize_mock = mocker.patch("ahriman.application.application.Application._finalize")
 | 
			
		||||
 | 
			
		||||
    application.sign([package_ahriman.base])
 | 
			
		||||
 | 
			
		||||
@ -185,7 +185,7 @@ def test_process_update(executor: Executor, package_ahriman: Package, mocker: Mo
 | 
			
		||||
    mocker.patch("ahriman.models.package.Package.load", return_value=package_ahriman)
 | 
			
		||||
    move_mock = mocker.patch("shutil.move")
 | 
			
		||||
    repo_add_mock = mocker.patch("ahriman.core.alpm.repo.Repo.add")
 | 
			
		||||
    sign_package_mock = mocker.patch("ahriman.core.sign.gpg.GPG.sign_package", side_effect=lambda fn, _: [fn])
 | 
			
		||||
    sign_package_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process_sign_package", side_effect=lambda fn, _: [fn])
 | 
			
		||||
    status_client_mock = mocker.patch("ahriman.core.status.client.Client.set_success")
 | 
			
		||||
 | 
			
		||||
    # must return complete
 | 
			
		||||
 | 
			
		||||
@ -64,32 +64,32 @@ def test_sign_command(gpg_with_key: GPG) -> None:
 | 
			
		||||
    assert gpg_with_key.sign_command(Path("a"), gpg_with_key.default_key)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_download_key(gpg: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
def test_key_download(gpg: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must download the key from public server
 | 
			
		||||
    """
 | 
			
		||||
    requests_mock = mocker.patch("requests.get")
 | 
			
		||||
    gpg.download_key("pgp.mit.edu", "0xE989490C")
 | 
			
		||||
    gpg.key_download("pgp.mit.edu", "0xE989490C")
 | 
			
		||||
    requests_mock.assert_called_once()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_download_key_failure(gpg: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
def test_key_download_failure(gpg: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must download the key from public server and log error if any (and raise it again)
 | 
			
		||||
    """
 | 
			
		||||
    mocker.patch("requests.get", side_effect=requests.exceptions.HTTPError())
 | 
			
		||||
    with pytest.raises(requests.exceptions.HTTPError):
 | 
			
		||||
        gpg.download_key("pgp.mit.edu", "0xE989490C")
 | 
			
		||||
        gpg.key_download("pgp.mit.edu", "0xE989490C")
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_import_key(gpg: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
def test_key_import(gpg: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must import PGP key from the server
 | 
			
		||||
    """
 | 
			
		||||
    mocker.patch("ahriman.core.sign.gpg.GPG.download_key", return_value="key")
 | 
			
		||||
    mocker.patch("ahriman.core.sign.gpg.GPG.key_download", return_value="key")
 | 
			
		||||
    check_output_mock = mocker.patch("ahriman.core.sign.gpg.GPG._check_output")
 | 
			
		||||
 | 
			
		||||
    gpg.import_key("pgp.mit.edu", "0xE989490C")
 | 
			
		||||
    gpg.key_import("pgp.mit.edu", "0xE989490C")
 | 
			
		||||
    check_output_mock.assert_has_calls([
 | 
			
		||||
        mock.call("gpg", "--import", input_data="key", exception=None, logger=pytest.helpers.anyvar(int)),
 | 
			
		||||
        mock.call("gpg", "--quick-lsign-key", "0xE989490C", exception=None, logger=pytest.helpers.anyvar(int))
 | 
			
		||||
@ -107,7 +107,7 @@ def test_process(gpg_with_key: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
    check_output_mock.assert_called()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_sign_package_1(gpg_with_key: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
def test_process_sign_package_1(gpg_with_key: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must sign package
 | 
			
		||||
    """
 | 
			
		||||
@ -115,11 +115,11 @@ def test_sign_package_1(gpg_with_key: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
    process_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process", return_value=result)
 | 
			
		||||
 | 
			
		||||
    gpg_with_key.targets = {SignSettings.Packages}
 | 
			
		||||
    assert gpg_with_key.sign_package(Path("a"), "a") == result
 | 
			
		||||
    assert gpg_with_key.process_sign_package(Path("a"), "a") == result
 | 
			
		||||
    process_mock.assert_called_once()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_sign_package_2(gpg_with_key: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
def test_process_sign_package_2(gpg_with_key: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must sign package
 | 
			
		||||
    """
 | 
			
		||||
@ -127,51 +127,51 @@ def test_sign_package_2(gpg_with_key: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
    process_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process", return_value=result)
 | 
			
		||||
 | 
			
		||||
    gpg_with_key.targets = {SignSettings.Packages, SignSettings.Repository}
 | 
			
		||||
    assert gpg_with_key.sign_package(Path("a"), "a") == result
 | 
			
		||||
    assert gpg_with_key.process_sign_package(Path("a"), "a") == result
 | 
			
		||||
    process_mock.assert_called_once()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_sign_package_skip_1(gpg_with_key: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
def test_process_sign_package_skip_1(gpg_with_key: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must not sign package if it is not set
 | 
			
		||||
    """
 | 
			
		||||
    process_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process")
 | 
			
		||||
    gpg_with_key.targets = {}
 | 
			
		||||
    gpg_with_key.sign_package(Path("a"), "a")
 | 
			
		||||
    gpg_with_key.process_sign_package(Path("a"), "a")
 | 
			
		||||
    process_mock.assert_not_called()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_sign_package_skip_2(gpg_with_key: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
def test_process_sign_package_skip_2(gpg_with_key: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must not sign package if it is not set
 | 
			
		||||
    """
 | 
			
		||||
    process_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process")
 | 
			
		||||
    gpg_with_key.targets = {SignSettings.Repository}
 | 
			
		||||
    gpg_with_key.sign_package(Path("a"), "a")
 | 
			
		||||
    gpg_with_key.process_sign_package(Path("a"), "a")
 | 
			
		||||
    process_mock.assert_not_called()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_sign_package_skip_3(gpg: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
def test_process_sign_package_skip_3(gpg: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must not sign package if it is not set
 | 
			
		||||
    """
 | 
			
		||||
    process_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process")
 | 
			
		||||
    gpg.targets = {SignSettings.Packages}
 | 
			
		||||
    gpg.sign_package(Path("a"), "a")
 | 
			
		||||
    gpg.process_sign_package(Path("a"), "a")
 | 
			
		||||
    process_mock.assert_not_called()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_sign_package_skip_4(gpg: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
def test_process_sign_package_skip_4(gpg: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must not sign package if it is not set
 | 
			
		||||
    """
 | 
			
		||||
    process_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process")
 | 
			
		||||
    gpg.targets = {SignSettings.Packages, SignSettings.Repository}
 | 
			
		||||
    gpg.sign_package(Path("a"), "a")
 | 
			
		||||
    gpg.process_sign_package(Path("a"), "a")
 | 
			
		||||
    process_mock.assert_not_called()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_sign_repository_1(gpg_with_key: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
def test_process_sign_repository_1(gpg_with_key: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must sign repository
 | 
			
		||||
    """
 | 
			
		||||
@ -179,11 +179,11 @@ def test_sign_repository_1(gpg_with_key: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
    process_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process", return_value=result)
 | 
			
		||||
 | 
			
		||||
    gpg_with_key.targets = {SignSettings.Repository}
 | 
			
		||||
    assert gpg_with_key.sign_repository(Path("a")) == result
 | 
			
		||||
    assert gpg_with_key.process_sign_repository(Path("a")) == result
 | 
			
		||||
    process_mock.assert_called_once()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_sign_repository_2(gpg_with_key: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
def test_process_sign_repository_2(gpg_with_key: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must sign repository
 | 
			
		||||
    """
 | 
			
		||||
@ -191,45 +191,45 @@ def test_sign_repository_2(gpg_with_key: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
    process_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process", return_value=result)
 | 
			
		||||
 | 
			
		||||
    gpg_with_key.targets = {SignSettings.Packages, SignSettings.Repository}
 | 
			
		||||
    assert gpg_with_key.sign_repository(Path("a")) == result
 | 
			
		||||
    assert gpg_with_key.process_sign_repository(Path("a")) == result
 | 
			
		||||
    process_mock.assert_called_once()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_sign_repository_skip_1(gpg_with_key: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
def test_process_sign_repository_skip_1(gpg_with_key: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must not sign repository if it is not set
 | 
			
		||||
    """
 | 
			
		||||
    process_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process")
 | 
			
		||||
    gpg_with_key.targets = {}
 | 
			
		||||
    gpg_with_key.sign_repository(Path("a"))
 | 
			
		||||
    gpg_with_key.process_sign_repository(Path("a"))
 | 
			
		||||
    process_mock.assert_not_called()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_sign_repository_skip_2(gpg_with_key: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
def test_process_sign_repository_skip_2(gpg_with_key: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must not sign repository if it is not set
 | 
			
		||||
    """
 | 
			
		||||
    process_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process")
 | 
			
		||||
    gpg_with_key.targets = {SignSettings.Packages}
 | 
			
		||||
    gpg_with_key.sign_repository(Path("a"))
 | 
			
		||||
    gpg_with_key.process_sign_repository(Path("a"))
 | 
			
		||||
    process_mock.assert_not_called()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_sign_repository_skip_3(gpg: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
def test_process_sign_repository_skip_3(gpg: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must not sign repository if it is not set
 | 
			
		||||
    """
 | 
			
		||||
    process_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process")
 | 
			
		||||
    gpg.targets = {SignSettings.Repository}
 | 
			
		||||
    gpg.sign_repository(Path("a"))
 | 
			
		||||
    gpg.process_sign_repository(Path("a"))
 | 
			
		||||
    process_mock.assert_not_called()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_sign_repository_skip_4(gpg: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
def test_process_sign_repository_skip_4(gpg: GPG, mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must not sign repository if it is not set
 | 
			
		||||
    """
 | 
			
		||||
    process_mock = mocker.patch("ahriman.core.sign.gpg.GPG.process")
 | 
			
		||||
    gpg.targets = {SignSettings.Packages, SignSettings.Repository}
 | 
			
		||||
    gpg.sign_repository(Path("a"))
 | 
			
		||||
    gpg.process_sign_repository(Path("a"))
 | 
			
		||||
    process_mock.assert_not_called()
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user