add ability to partition tree before calculationn

This commit is contained in:
2023-08-27 01:12:12 +03:00
parent f6081507c0
commit a1db4dc8b8
13 changed files with 393 additions and 45 deletions

View File

@ -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: