mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-07-16 07:19:57 +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:
@ -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