fix: catch some StopIteration exceptions

This commit is contained in:
2026-03-06 17:04:19 +02:00
parent 88ac3d82a0
commit 10661f3127
7 changed files with 58 additions and 7 deletions

View File

@@ -183,6 +183,15 @@ def test_sync_files_local(pacman_database: PacmanDatabase, mocker: MockerFixture
copy_mock.assert_called_once_with(Path("/var/core.files.tar.gz"), pytest.helpers.anyvar(int))
def test_sync_files_no_servers(pacman_database: PacmanDatabase) -> None:
"""
must raise PacmanError if no servers are configured
"""
pacman_database.database.servers = []
with pytest.raises(PacmanError):
pacman_database.sync_files(force=False)
def test_sync_files_unknown_source(pacman_database: PacmanDatabase) -> None:
"""
must raise an exception in case if server scheme is unsupported

View File

@@ -5,6 +5,7 @@ from pathlib import Path
from pytest_mock import MockerFixture
from ahriman.core.configuration import Configuration
from ahriman.core.exceptions import GPGError
from ahriman.core.sign.gpg import GPG
from ahriman.models.sign_settings import SignSettings
@@ -113,6 +114,15 @@ fpr:::::::::43A663569A07EE1E4ECC55CC7E3A4240CE3C45C2:""")
check_output_mock.assert_called_once_with("gpg", "--with-colons", "--fingerprint", key, logger=gpg.logger)
def test_key_fingerprint_invalid(gpg: GPG, mocker: MockerFixture) -> None:
"""
must raise GPGError if no fingerprint found in output
"""
mocker.patch("ahriman.core.sign.gpg.check_output", return_value="no fingerprint here")
with pytest.raises(GPGError):
gpg.key_fingerprint("0xCE3C45C2")
def test_key_import(gpg: GPG, mocker: MockerFixture) -> None:
"""
must import PGP key from the server

View File

@@ -12,6 +12,8 @@ def test_algo() -> None:
"""
assert User(username="user", password=None, access=UserAccess.Read).algo is None
assert User(username="user", password="", access=UserAccess.Read).algo is None
assert User(username="user", password="$$$", access=UserAccess.Read).algo is None
assert User(
username="user",
password="$6$rounds=656000$mWBiecMPrHAL1VgX$oU4Y5HH8HzlvMaxwkNEJjK13ozElyU1wAHBoO/WW5dAaE4YEfnB0X3FxbynKMl4FBdC3Ovap0jINz4LPkNADg0",