mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-06-27 22:31:43 +00:00
* add models tests (#1) also replace single quote to double one to confort PEP docstring + move _check_output to class properties to make it available for mocking * alpm tests implementation * try to replace os with pathlib * update tests for pathlib * fix includes glob and trim version from dependencies * build_tools package tests * repository component tests * add sign tests * complete status tests * handle exceptions in actual_version calls * complete core tests * move configuration to root conftest * application tests * complete application tests * change copyright to more generic one * base web tests * complete web tests * complete testkit also add argument parsers test
62 lines
1.9 KiB
Python
62 lines
1.9 KiB
Python
from pathlib import Path
|
|
from pytest_mock import MockerFixture
|
|
|
|
from ahriman.core.sign.gpg import GPG
|
|
from ahriman.models.sign_settings import SignSettings
|
|
|
|
|
|
def test_repository_sign_args(gpg: GPG) -> None:
|
|
"""
|
|
must generate correct sign args
|
|
"""
|
|
gpg.target = {SignSettings.SignRepository}
|
|
assert gpg.repository_sign_args
|
|
|
|
|
|
def test_sign_package(gpg: GPG, mocker: MockerFixture) -> None:
|
|
"""
|
|
must sign package
|
|
"""
|
|
result = [Path("a"), Path("a.sig")]
|
|
process_mock = mocker.patch("ahriman.core.sign.gpg.process", return_value=result)
|
|
|
|
for target in ({SignSettings.SignPackages}, {SignSettings.SignPackages, SignSettings.SignRepository}):
|
|
gpg.target = target
|
|
assert gpg.sign_package(Path("a"), "a") == result
|
|
process_mock.assert_called_once()
|
|
|
|
|
|
def test_sign_package_skip(gpg: GPG, mocker: MockerFixture) -> None:
|
|
"""
|
|
must not sign package if it is not set
|
|
"""
|
|
process_mock = mocker.patch("ahriman.core.sign.gpg.process")
|
|
|
|
for target in ({}, {SignSettings.SignRepository}):
|
|
gpg.target = target
|
|
process_mock.assert_not_called()
|
|
|
|
|
|
def test_sign_repository(gpg: GPG, mocker: MockerFixture) -> None:
|
|
"""
|
|
must sign repository
|
|
"""
|
|
result = [Path("a"), Path("a.sig")]
|
|
process_mock = mocker.patch("ahriman.core.sign.gpg.process", return_value=result)
|
|
|
|
for target in ({SignSettings.SignRepository}, {SignSettings.SignPackages, SignSettings.SignRepository}):
|
|
gpg.target = target
|
|
assert gpg.sign_repository(Path("a")) == result
|
|
process_mock.assert_called_once()
|
|
|
|
|
|
def test_sign_repository_skip(gpg: GPG, mocker: MockerFixture) -> None:
|
|
"""
|
|
must not sign repository if it is not set
|
|
"""
|
|
process_mock = mocker.patch("ahriman.core.sign.gpg.process")
|
|
|
|
for target in ({}, {SignSettings.SignPackages}):
|
|
gpg.target = target
|
|
process_mock.assert_not_called()
|