mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-08-30 13:29:55 +00:00
triggers implementation (#62)
This commit is contained in:
@ -9,12 +9,10 @@ def test_finalize(application: Application, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must report and sync at the last
|
||||
"""
|
||||
report_mock = mocker.patch("ahriman.application.application.Application.report")
|
||||
sync_mock = mocker.patch("ahriman.application.application.Application.sync")
|
||||
triggers_mock = mocker.patch("ahriman.core.repository.Repository.process_triggers")
|
||||
|
||||
application._finalize(Result())
|
||||
report_mock.assert_called_once_with([], Result())
|
||||
sync_mock.assert_called_once_with([], [])
|
||||
triggers_mock.assert_called_once_with(Result())
|
||||
|
||||
|
||||
def test_known_packages(application: Application, package_ahriman: Package, mocker: MockerFixture) -> None:
|
||||
|
@ -53,15 +53,6 @@ def test_clean_packages(application_repository: ApplicationRepository, mocker: M
|
||||
clear_mock.assert_called_once_with()
|
||||
|
||||
|
||||
def test_report(application_repository: ApplicationRepository, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must generate report
|
||||
"""
|
||||
executor_mock = mocker.patch("ahriman.core.repository.executor.Executor.process_report")
|
||||
application_repository.report(["a"], Result())
|
||||
executor_mock.assert_called_once_with(["a"], Result())
|
||||
|
||||
|
||||
def test_sign(application_repository: ApplicationRepository, package_ahriman: Package, package_python_schedule: Package,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
@ -121,15 +112,6 @@ def test_sign_specific(application_repository: ApplicationRepository, package_ah
|
||||
finalize_mock.assert_called_once_with(Result())
|
||||
|
||||
|
||||
def test_sync(application_repository: ApplicationRepository, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must sync to remote
|
||||
"""
|
||||
executor_mock = mocker.patch("ahriman.core.repository.executor.Executor.process_sync")
|
||||
application_repository.sync(["a"], [])
|
||||
executor_mock.assert_called_once_with(["a"], [])
|
||||
|
||||
|
||||
def test_unknown_no_aur(application_repository: ApplicationRepository, package_ahriman: Package,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
|
@ -1,33 +0,0 @@
|
||||
import argparse
|
||||
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.application.handlers import Report
|
||||
from ahriman.core.configuration import Configuration
|
||||
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.target = []
|
||||
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.application.application.Application.report")
|
||||
|
||||
Report.run(args, "x86_64", configuration, True, False)
|
||||
application_mock.assert_called_once_with(args.target, Result())
|
@ -1,32 +0,0 @@
|
||||
import argparse
|
||||
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.application.handlers import Sync
|
||||
from ahriman.core.configuration import Configuration
|
||||
|
||||
|
||||
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.target = []
|
||||
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.application.application.Application.sync")
|
||||
|
||||
Sync.run(args, "x86_64", configuration, True, False)
|
||||
application_mock.assert_called_once_with(args.target, [])
|
18
tests/ahriman/application/handlers/test_handler_triggers.py
Normal file
18
tests/ahriman/application/handlers/test_handler_triggers.py
Normal file
@ -0,0 +1,18 @@
|
||||
import argparse
|
||||
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.application.handlers import Triggers
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.models.result import Result
|
||||
|
||||
|
||||
def test_run(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must run command
|
||||
"""
|
||||
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())
|
@ -348,16 +348,6 @@ def test_subparsers_repo_remove_unknown_architecture(parser: argparse.ArgumentPa
|
||||
assert args.architecture == ["x86_64"]
|
||||
|
||||
|
||||
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
|
||||
@ -446,13 +436,13 @@ def test_subparsers_repo_status_update_option_status(parser: argparse.ArgumentPa
|
||||
assert isinstance(args.status, BuildStatusEnum)
|
||||
|
||||
|
||||
def test_subparsers_repo_sync_architecture(parser: argparse.ArgumentParser) -> None:
|
||||
def test_subparsers_repo_triggers_architecture(parser: argparse.ArgumentParser) -> None:
|
||||
"""
|
||||
repo-sync command must correctly parse architecture list
|
||||
repo-triggers command must correctly parse architecture list
|
||||
"""
|
||||
args = parser.parse_args(["repo-sync"])
|
||||
args = parser.parse_args(["repo-triggers"])
|
||||
assert args.architecture is None
|
||||
args = parser.parse_args(["-a", "x86_64", "repo-sync"])
|
||||
args = parser.parse_args(["-a", "x86_64", "repo-triggers"])
|
||||
assert args.architecture == ["x86_64"]
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user