mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-04-24 23:37:18 +00:00
* Allow to use single web instance for any repository * some improvements * drop includes from user home directory, introduce new variables to docker The old solution didn't actually work as expected, because devtools configuration belongs to filesystem (as well as sudo one), so it was still required to run setup command. In order to handle additional repositories, the POSTSETUP and PRESETUP commands variables have been introduced. FAQ has been updated as well * raise 404 in case if repository is unknown
69 lines
2.6 KiB
Python
69 lines
2.6 KiB
Python
import argparse
|
|
import pytest
|
|
|
|
from pytest_mock import MockerFixture
|
|
|
|
from ahriman import __version__
|
|
from ahriman.application.handlers import ServiceUpdates
|
|
from ahriman.core.configuration import Configuration
|
|
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.exit_code = False
|
|
return args
|
|
|
|
|
|
def test_run(args: argparse.Namespace, configuration: Configuration, repository: Repository,
|
|
package_ahriman: Package, mocker: MockerFixture) -> None:
|
|
"""
|
|
must run command
|
|
"""
|
|
package_ahriman.version = "0.0.0-1"
|
|
args = _default_args(args)
|
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
|
package_mock = mocker.patch("ahriman.models.package.Package.from_aur", return_value=package_ahriman)
|
|
application_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
|
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
|
|
|
|
_, repository_id = configuration.check_loaded()
|
|
ServiceUpdates.run(args, repository_id, configuration, report=False)
|
|
package_mock.assert_called_once_with(package_ahriman.base, None)
|
|
application_mock.assert_called_once_with(verbose=True, log_fn=pytest.helpers.anyvar(int), separator=" -> ")
|
|
check_mock.assert_called_once_with(args.exit_code, True)
|
|
|
|
|
|
def test_run_skip(args: argparse.Namespace, configuration: Configuration, repository: Repository,
|
|
package_ahriman: Package, mocker: MockerFixture) -> None:
|
|
"""
|
|
must do not perform any actions if package is up-to-date
|
|
"""
|
|
package_ahriman.version = f"{__version__}-1"
|
|
args = _default_args(args)
|
|
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
|
|
mocker.patch("ahriman.models.package.Package.from_aur", return_value=package_ahriman)
|
|
application_mock = mocker.patch("ahriman.core.formatters.Printer.print")
|
|
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
|
|
|
|
_, repository_id = configuration.check_loaded()
|
|
ServiceUpdates.run(args, repository_id, configuration, report=False)
|
|
application_mock.assert_not_called()
|
|
check_mock.assert_not_called()
|
|
|
|
|
|
def test_disallow_multi_architecture_run() -> None:
|
|
"""
|
|
must not allow multi architecture run
|
|
"""
|
|
assert not ServiceUpdates.ALLOW_MULTI_ARCHITECTURE_RUN
|