mirror of
				https://github.com/arcan1s/ahriman.git
				synced 2025-11-04 07:43:42 +00:00 
			
		
		
		
	add ability to partition tree before calculationn
This commit is contained in:
		@ -1,6 +1,7 @@
 | 
			
		||||
import argparse
 | 
			
		||||
 | 
			
		||||
from pytest_mock import MockerFixture
 | 
			
		||||
from unittest.mock import call as MockCall
 | 
			
		||||
 | 
			
		||||
from ahriman.application.handlers import Structure
 | 
			
		||||
from ahriman.core.configuration import Configuration
 | 
			
		||||
@ -8,19 +9,40 @@ from ahriman.core.repository import Repository
 | 
			
		||||
from ahriman.models.package import Package
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def _default_args(args: argparse.Namespace) -> argparse.Namespace:
 | 
			
		||||
    """
 | 
			
		||||
    default arguments for these test cases
 | 
			
		||||
 | 
			
		||||
    Args:
 | 
			
		||||
        args(argparse.Namespace): command line arguments fixture
 | 
			
		||||
 | 
			
		||||
    Returns:
 | 
			
		||||
        argparse.Namespace: generated arguments for these test cases
 | 
			
		||||
    """
 | 
			
		||||
    args.partitions = 1
 | 
			
		||||
    return args
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_run(args: argparse.Namespace, configuration: Configuration, repository: Repository,
 | 
			
		||||
             package_ahriman: Package, mocker: MockerFixture) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must run command
 | 
			
		||||
    """
 | 
			
		||||
    args = _default_args(args)
 | 
			
		||||
    mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
 | 
			
		||||
    mocker.patch("ahriman.core.repository.Repository.packages", return_value=[package_ahriman])
 | 
			
		||||
    packages_mock = mocker.patch("ahriman.core.tree.Tree.partition", return_value=[[package_ahriman]])
 | 
			
		||||
    application_mock = mocker.patch("ahriman.core.tree.Tree.resolve", return_value=[[package_ahriman]])
 | 
			
		||||
    print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
 | 
			
		||||
 | 
			
		||||
    Structure.run(args, "x86_64", configuration, report=False)
 | 
			
		||||
    packages_mock.assert_called_once_with([package_ahriman], count=args.partitions)
 | 
			
		||||
    application_mock.assert_called_once_with([package_ahriman])
 | 
			
		||||
    print_mock.assert_called_once_with(verbose=True, separator=" ")
 | 
			
		||||
    print_mock.assert_has_calls([
 | 
			
		||||
        MockCall(verbose=False),
 | 
			
		||||
        MockCall(verbose=True, separator=" "),
 | 
			
		||||
        MockCall(verbose=False),
 | 
			
		||||
    ])
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_disallow_auto_architecture_run() -> None:
 | 
			
		||||
 | 
			
		||||
@ -600,6 +600,16 @@ def test_subparsers_repo_tree_architecture(parser: argparse.ArgumentParser) -> N
 | 
			
		||||
    assert args.architecture == ["x86_64"]
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_subparsers_repo_tree_option_partitions(parser: argparse.ArgumentParser) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    must convert partitions option to int instance
 | 
			
		||||
    """
 | 
			
		||||
    args = parser.parse_args(["repo-tree"])
 | 
			
		||||
    assert isinstance(args.partitions, int)
 | 
			
		||||
    args = parser.parse_args(["repo-tree", "--partitions", "42"])
 | 
			
		||||
    assert isinstance(args.partitions, int)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_subparsers_repo_triggers_architecture(parser: argparse.ArgumentParser) -> None:
 | 
			
		||||
    """
 | 
			
		||||
    repo-triggers command must correctly parse architecture list
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user