mirror of
				https://github.com/arcan1s/ahriman.git
				synced 2025-11-03 23:33:41 +00:00 
			
		
		
		
	add sign tests
This commit is contained in:
		@ -1,7 +1,6 @@
 | 
			
		||||
from pathlib import Path
 | 
			
		||||
from unittest import mock
 | 
			
		||||
 | 
			
		||||
from pytest_mock import MockerFixture
 | 
			
		||||
from unittest import mock
 | 
			
		||||
 | 
			
		||||
from ahriman.core.repository.executor import Executor
 | 
			
		||||
from ahriman.models.package import Package
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,4 @@
 | 
			
		||||
from pathlib import Path
 | 
			
		||||
 | 
			
		||||
from pytest_mock import MockerFixture
 | 
			
		||||
 | 
			
		||||
from ahriman.core.repository.repository import Repository
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										9
									
								
								tests/ahriman/core/sign/conftest.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								tests/ahriman/core/sign/conftest.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,9 @@
 | 
			
		||||
import pytest
 | 
			
		||||
 | 
			
		||||
from ahriman.core.configuration import Configuration
 | 
			
		||||
from ahriman.core.sign.gpg import GPG
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@pytest.fixture
 | 
			
		||||
def gpg(configuration: Configuration) -> GPG:
 | 
			
		||||
    return GPG("x86_64", configuration)
 | 
			
		||||
							
								
								
									
										61
									
								
								tests/ahriman/core/sign/gpg.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										61
									
								
								tests/ahriman/core/sign/gpg.py
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,61 @@
 | 
			
		||||
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()
 | 
			
		||||
							
								
								
									
										0
									
								
								tests/ahriman/core/upload/test_rsync.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								tests/ahriman/core/upload/test_rsync.py
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										0
									
								
								tests/ahriman/core/upload/test_s3.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								tests/ahriman/core/upload/test_s3.py
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										0
									
								
								tests/ahriman/core/upload/test_uploader.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								tests/ahriman/core/upload/test_uploader.py
									
									
									
									
									
										Normal file
									
								
							
		Reference in New Issue
	
	Block a user