mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-08-31 05:49:56 +00:00
add ability to run only speicifed triggers from command line
This commit also restores repo-report and repo-sync subcommands
This commit is contained in:
@ -4,15 +4,48 @@ from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.application.handlers import Triggers
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.models.package import Package
|
||||
from ahriman.models.result import Result
|
||||
|
||||
|
||||
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.trigger = []
|
||||
return args
|
||||
|
||||
|
||||
def test_run(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must run command
|
||||
"""
|
||||
args = _default_args(args)
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
application_mock = mocker.patch("ahriman.core.repository.Repository.process_triggers")
|
||||
|
||||
Triggers.run(args, "x86_64", configuration, True, False)
|
||||
application_mock.assert_called_once_with(Result())
|
||||
|
||||
|
||||
def test_run_trigger(args: argparse.Namespace, configuration: Configuration, package_ahriman: Package,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must run triggers specified by command line
|
||||
"""
|
||||
args = _default_args(args)
|
||||
args.trigger = ["ahriman.core.report.ReportTrigger"]
|
||||
mocker.patch("ahriman.core.repository.Repository.packages", return_value=[package_ahriman])
|
||||
mocker.patch("ahriman.models.repository_paths.RepositoryPaths.tree_create")
|
||||
report_mock = mocker.patch("ahriman.core.report.ReportTrigger.run")
|
||||
upload_mock = mocker.patch("ahriman.core.upload.UploadTrigger.run")
|
||||
|
||||
Triggers.run(args, "x86_64", configuration, True, False)
|
||||
report_mock.assert_called_once_with(Result(), [package_ahriman])
|
||||
upload_mock.assert_not_called()
|
||||
|
@ -348,6 +348,24 @@ def test_subparsers_repo_remove_unknown_architecture(parser: argparse.ArgumentPa
|
||||
assert args.architecture == ["x86_64"]
|
||||
|
||||
|
||||
def test_subparsers_repo_report(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
repo-report command must imply trigger
|
||||
"""
|
||||
args = parser.parse_args(["repo-report"])
|
||||
assert args.trigger == ["ahriman.core.report.ReportTrigger"]
|
||||
|
||||
|
||||
def test_subparsers_repo_report_architecture(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
repo-report command must correctly parse architecture list
|
||||
"""
|
||||
args = parser.parse_args(["repo-report"])
|
||||
assert args.architecture is None
|
||||
args = parser.parse_args(["-a", "x86_64", "repo-report"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
|
||||
|
||||
def test_subparsers_repo_restore(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
repo-restore command must imply architecture list, lock, no-report and unsafe
|
||||
@ -436,6 +454,24 @@ def test_subparsers_repo_status_update_option_status(parser: argparse.ArgumentPa
|
||||
assert isinstance(args.status, BuildStatusEnum)
|
||||
|
||||
|
||||
def test_subparsers_repo_sync(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
repo-sync command must imply trigger
|
||||
"""
|
||||
args = parser.parse_args(["repo-sync"])
|
||||
assert args.trigger == ["ahriman.core.upload.UploadTrigger"]
|
||||
|
||||
|
||||
def test_subparsers_repo_sync_architecture(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
repo-sync command must correctly parse architecture list
|
||||
"""
|
||||
args = parser.parse_args(["repo-report"])
|
||||
assert args.architecture is None
|
||||
args = parser.parse_args(["-a", "x86_64", "repo-report"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
|
||||
|
||||
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