Compare commits

...

7 Commits

Author SHA1 Message Date
b412966f86 Release 2.15.1 2024-09-24 11:18:38 +03:00
1119a8d04e feat: enable changes calculation in unit 2024-09-24 11:01:37 +03:00
9b3d294992 refactor: rename Handler.check_if_empty to check_status 2024-09-24 01:36:33 +03:00
517337144c fix: bump pkgrel if the local version is newer than remote
In case of VCS packages, if PKGBUILD contains older version, the pkgrel
remains the same during the rebuild process. This fix bumps pkgrel in
any case if the local version is newer than the remote
2024-09-23 16:30:33 +03:00
db89ad46b7 build: reduce docker image size 2024-09-23 14:37:36 +03:00
9fc1c53c3d docs: update web preview picture 2024-09-23 14:03:12 +03:00
cd61ab3e5b fix: allow colon in options interpolation 2024-09-23 13:52:49 +03:00
36 changed files with 111 additions and 94 deletions

View File

@ -54,7 +54,6 @@ RUN pacman -S --noconfirm --asdeps \
python-cerberus \
python-cryptography \
python-jinja \
python-matplotlib \
python-systemd \
rsync \
&& \

View File

@ -1,7 +1,7 @@
# Maintainer: Evgeniy Alekseev
pkgname='ahriman'
pkgver=2.15.0
pkgver=2.15.1
pkgrel=1
pkgdesc="ArcH linux ReposItory MANager"
arch=('any')

View File

@ -3,7 +3,7 @@ Description=ArcH linux ReposItory MANager (%i)
[Service]
Type=simple
ExecStart=/usr/bin/ahriman --repository-id "%I" repo-daemon --no-changes --refresh
ExecStart=/usr/bin/ahriman --repository-id "%I" repo-daemon --refresh
User=ahriman
Group=ahriman

View File

@ -2,6 +2,6 @@
Description=ArcH linux ReposItory MANager (%i)
[Service]
ExecStart=/usr/bin/ahriman --repository-id "%I" repo-update --no-changes --refresh
ExecStart=/usr/bin/ahriman --repository-id "%I" repo-update --refresh
User=ahriman
Group=ahriman

View File

@ -1,4 +1,4 @@
.TH AHRIMAN "1" "2024\-09\-23" "ahriman" "Generated Python Manual"
.TH AHRIMAN "1" "2024\-09\-24" "ahriman" "Generated Python Manual"
.SH NAME
ahriman
.SH SYNOPSIS

View File

@ -17,4 +17,4 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
__version__ = "2.15.0"
__version__ = "2.15.1"

View File

@ -65,4 +65,4 @@ class Add(Handler):
application.print_updates(packages, log_fn=application.logger.info)
result = application.update(packages, packagers, bump_pkgrel=args.increment)
Add.check_if_empty(args.exit_code, result.is_empty)
Add.check_status(args.exit_code, not result.is_empty)

View File

@ -54,6 +54,6 @@ class Change(Handler):
case Action.List:
changes = client.package_changes_get(args.package)
ChangesPrinter(changes)(verbose=True, separator="")
Change.check_if_empty(args.exit_code, changes.is_empty)
Change.check_status(args.exit_code, not changes.is_empty)
case Action.Remove:
client.package_changes_update(args.package, Changes())

View File

@ -20,7 +20,7 @@
import argparse
import logging
from collections.abc import Iterable
from collections.abc import Callable, Iterable
from multiprocessing import Pool
from ahriman.application.lock import Lock
@ -124,19 +124,26 @@ class Handler:
raise NotImplementedError
@staticmethod
def check_if_empty(enabled: bool, predicate: bool) -> None:
def check_status(enabled: bool, status: bool | Callable[[], bool]) -> None:
"""
check condition and flag and raise ExitCode exception in case if it is enabled and condition match
Args:
enabled(bool): if ``False`` no check will be performed
predicate(bool): indicates condition on which exception should be thrown
status(bool | Callable[[], bool]): return status or function to check. ``True`` means success and vice versa
Raises:
ExitCode: if result is empty and check is enabled
"""
if enabled and predicate:
raise ExitCode
if not enabled:
return
match status:
case False:
raise ExitCode
# https://github.com/python/mypy/issues/14014
case Callable() if not status(): # type: ignore[misc]
raise ExitCode
@staticmethod
def repositories_extract(args: argparse.Namespace) -> list[RepositoryId]:

View File

@ -136,7 +136,7 @@ class Patch(Handler):
for patch in application.reporter.package_patches_get(package_base, None)
if variables is None or patch.key in variables
]
Patch.check_if_empty(exit_code, not patches)
Patch.check_status(exit_code, bool(patches))
PatchPrinter(package_base, patches)(verbose=True, separator=" = ")

View File

@ -49,15 +49,15 @@ class Rebuild(Handler):
application.on_start()
packages = Rebuild.extract_packages(application, args.status, from_database=args.from_database)
updates = application.repository.packages_depend_on(packages, args.depends_on)
packages = application.repository.packages_depend_on(packages, args.depends_on)
Rebuild.check_if_empty(args.exit_code, not updates)
Rebuild.check_status(args.exit_code, bool(packages))
if args.dry_run:
application.print_updates(updates, log_fn=print)
application.print_updates(packages, log_fn=print)
return
result = application.update(updates, Packagers(args.username), bump_pkgrel=args.increment)
Rebuild.check_if_empty(args.exit_code, result.is_empty)
result = application.update(packages, Packagers(args.username), bump_pkgrel=args.increment)
Rebuild.check_status(args.exit_code, not result.is_empty)
@staticmethod
def extract_packages(application: Application, status: BuildStatusEnum | None, *,

View File

@ -47,7 +47,7 @@ class Run(Handler):
parser = args.parser()
for command in args.command:
status = Run.run_command(shlex.split(command), parser)
Run.check_if_empty(True, not status)
Run.check_status(True, status)
@staticmethod
def run_command(command: list[str], parser: argparse.ArgumentParser) -> bool:

View File

@ -60,7 +60,8 @@ class Search(Handler):
"""
official_packages_list = Official.multisearch(*args.search)
aur_packages_list = AUR.multisearch(*args.search)
Search.check_if_empty(args.exit_code, not official_packages_list and not aur_packages_list)
non_empty = bool(official_packages_list or aur_packages_list)
Search.check_status(args.exit_code, non_empty)
for packages_list in (official_packages_list, aur_packages_list):
# keep sorting by packages source

View File

@ -57,4 +57,4 @@ class ServiceUpdates(Handler):
return
UpdatePrinter(remote, local_version)(verbose=True, separator=" -> ")
ServiceUpdates.check_if_empty(args.exit_code, not same_version)
ServiceUpdates.check_status(args.exit_code, same_version)

View File

@ -61,7 +61,7 @@ class Status(Handler):
else:
packages = client.package_get(None)
Status.check_if_empty(args.exit_code, not packages)
Status.check_status(args.exit_code, bool(packages))
comparator: Callable[[tuple[Package, BuildStatus]], str] = lambda item: item[0].base
filter_fn: Callable[[tuple[Package, BuildStatus]], bool] =\

View File

@ -63,7 +63,7 @@ class UnsafeCommands(Handler):
parser(argparse.ArgumentParser): generated argument parser
"""
args = parser.parse_args(command)
UnsafeCommands.check_if_empty(True, args.command in unsafe_commands)
UnsafeCommands.check_status(True, args.command not in unsafe_commands)
@staticmethod
def get_unsafe_commands(parser: argparse.ArgumentParser) -> list[str]:

View File

@ -54,7 +54,7 @@ class Update(Handler):
application.changes(packages)
if args.dry_run: # exit from application if no build requested
Update.check_if_empty(args.exit_code, not packages) # status code check
Update.check_status(args.exit_code, bool(packages)) # status code check
return
packages = application.with_dependencies(packages, process_dependencies=args.dependencies)
@ -62,7 +62,7 @@ class Update(Handler):
application.print_updates(packages, log_fn=application.logger.info)
result = application.update(packages, packagers, bump_pkgrel=args.increment)
Update.check_if_empty(args.exit_code, result.is_empty)
Update.check_status(args.exit_code, not result.is_empty)
@staticmethod
def log_fn(application: Application, dry_run: bool) -> Callable[[str], None]:

View File

@ -59,9 +59,9 @@ class Users(Handler):
database.user_update(user.hash_password(salt))
case Action.List:
users = database.user_list(args.username, args.role)
Users.check_if_empty(args.exit_code, not users)
for user in users:
UserPrinter(user)(verbose=True)
Users.check_status(args.exit_code, bool(users))
case Action.Remove:
database.user_remove(args.username)

View File

@ -61,7 +61,7 @@ class Validate(Handler):
ValidationPrinter(node, errors)(verbose=True)
# as we reach this part it means that we always have errors
Validate.check_if_empty(args.exit_code, True)
Validate.check_status(args.exit_code, False)
@staticmethod
def schema(repository_id: RepositoryId, configuration: Configuration) -> ConfigurationSchema:

View File

@ -52,7 +52,7 @@ class ShellInterpolator(configparser.Interpolation):
def identifiers() -> Generator[tuple[str | None, str], None, None]:
# extract all found identifiers and parse them
for identifier in ShellTemplate(value).get_identifiers():
match identifier.split(":"):
match identifier.rsplit(":", maxsplit=1):
case [lookup_option]: # single option from the same section
yield None, lookup_option
case [lookup_section, lookup_option]: # reference to another section

View File

@ -538,14 +538,10 @@ class Package(LazyLogging):
if local_version is None:
return None # local version not found, keep upstream pkgrel
epoch, pkgver, _ = parse_version(self.version)
local_epoch, local_pkgver, local_pkgrel = parse_version(local_version)
if epoch != local_epoch or pkgver != local_pkgver:
return None # epoch or pkgver are different, keep upstream pkgrel
if vercmp(self.version, local_version) > 0:
return None # upstream version is newer than local one, keep upstream pkgrel
*_, local_pkgrel = parse_version(local_version)
if "." in local_pkgrel:
major, minor = local_pkgrel.rsplit(".", maxsplit=1)
else:

View File

@ -120,15 +120,21 @@ def test_run(args: argparse.Namespace, configuration: Configuration) -> None:
Handler.run(args, repository_id, configuration, report=True)
def test_check_if_empty() -> None:
def test_check_status() -> None:
"""
must raise exception in case if predicate is True and enabled
"""
Handler.check_if_empty(False, False)
Handler.check_if_empty(True, False)
Handler.check_if_empty(False, True)
Handler.check_status(False, True)
Handler.check_status(False, False)
Handler.check_status(False, lambda: True)
Handler.check_status(False, lambda: False)
Handler.check_status(True, True)
with pytest.raises(ExitCode):
Handler.check_if_empty(True, True)
Handler.check_status(True, False)
Handler.check_status(True, lambda: True)
with pytest.raises(ExitCode):
Handler.check_status(True, lambda: False)
def test_repositories_extract(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:

View File

@ -82,7 +82,7 @@ def test_run_with_updates(args: argparse.Namespace, configuration: Configuration
mocker.patch("ahriman.application.application.Application.add")
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
application_mock = mocker.patch("ahriman.application.application.Application.update", return_value=result)
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
changes_mock = mocker.patch("ahriman.application.application.Application.changes")
updates_mock = mocker.patch("ahriman.application.application.Application.updates", return_value=[package_ahriman])
dependencies_mock = mocker.patch("ahriman.application.application.Application.with_dependencies",
@ -98,7 +98,7 @@ def test_run_with_updates(args: argparse.Namespace, configuration: Configuration
Packagers(args.username, {package_ahriman.base: "packager"}),
bump_pkgrel=args.increment)
dependencies_mock.assert_called_once_with([package_ahriman], process_dependencies=args.dependencies)
check_mock.assert_called_once_with(False, False)
check_mock.assert_called_once_with(False, True)
print_mock.assert_called_once_with([package_ahriman], log_fn=pytest.helpers.anyvar(int))
@ -113,7 +113,7 @@ def test_run_no_changes(args: argparse.Namespace, configuration: Configuration,
mocker.patch("ahriman.application.application.Application.add")
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
mocker.patch("ahriman.application.application.Application.update")
mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
mocker.patch("ahriman.application.handlers.Handler.check_status")
mocker.patch("ahriman.application.application.Application.updates")
mocker.patch("ahriman.application.application.Application.with_dependencies")
mocker.patch("ahriman.application.application.Application.print_updates")
@ -138,8 +138,8 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat
mocker.patch("ahriman.application.application.Application.with_dependencies")
mocker.patch("ahriman.application.application.Application.updates")
mocker.patch("ahriman.application.application.Application.print_updates")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
_, repository_id = configuration.check_loaded()
Add.run(args, repository_id, configuration, report=False)
check_mock.assert_called_once_with(True, True)
check_mock.assert_called_once_with(True, False)

View File

@ -36,13 +36,13 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
application_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_changes_get",
return_value=Changes("sha", "change"))
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
_, repository_id = configuration.check_loaded()
Change.run(args, repository_id, configuration, report=False)
application_mock.assert_called_once_with(args.package)
check_mock.assert_called_once_with(False, False)
check_mock.assert_called_once_with(False, True)
print_mock.assert_called_once_with(verbose=True, log_fn=pytest.helpers.anyvar(int), separator="")
@ -55,11 +55,11 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat
args.exit_code = True
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
mocker.patch("ahriman.core.status.local_client.LocalClient.package_changes_get", return_value=Changes())
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
_, repository_id = configuration.check_loaded()
Change.run(args, repository_id, configuration, report=False)
check_mock.assert_called_once_with(True, True)
check_mock.assert_called_once_with(True, False)
def test_run_remove(args: argparse.Namespace, configuration: Configuration, repository: Repository,

View File

@ -163,12 +163,12 @@ def test_patch_set_list(application: Application, mocker: MockerFixture) -> None
get_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_patches_get",
return_value=[PkgbuildPatch(None, "patch"), PkgbuildPatch("version", "value")])
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
Patch.patch_set_list(application, "ahriman", ["version"], False)
get_mock.assert_called_once_with("ahriman", None)
print_mock.assert_called_once_with(verbose=True, log_fn=pytest.helpers.anyvar(int), separator=" = ")
check_mock.assert_called_once_with(False, False)
check_mock.assert_called_once_with(False, True)
def test_patch_set_list_all(application: Application, mocker: MockerFixture) -> None:
@ -178,12 +178,12 @@ def test_patch_set_list_all(application: Application, mocker: MockerFixture) ->
get_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_patches_get",
return_value=[PkgbuildPatch(None, "patch")])
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
Patch.patch_set_list(application, "ahriman", None, False)
get_mock.assert_called_once_with("ahriman", None)
print_mock.assert_called_once_with(verbose=True, log_fn=pytest.helpers.anyvar(int), separator=" = ")
check_mock.assert_called_once_with(False, False)
check_mock.assert_called_once_with(False, True)
def test_patch_set_list_empty_exception(application: Application, mocker: MockerFixture) -> None:
@ -191,10 +191,10 @@ def test_patch_set_list_empty_exception(application: Application, mocker: Mocker
must raise ExitCode exception on empty patch list
"""
mocker.patch("ahriman.core.status.local_client.LocalClient.package_patches_get", return_value={})
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
Patch.patch_set_list(application, "ahriman", [], True)
check_mock.assert_called_once_with(True, True)
check_mock.assert_called_once_with(True, False)
def test_patch_set_create(application: Application, package_ahriman: Package, mocker: MockerFixture) -> None:

View File

@ -47,7 +47,7 @@ def test_run(args: argparse.Namespace, package_ahriman: Package, configuration:
application_packages_mock = mocker.patch("ahriman.core.repository.repository.Repository.packages_depend_on",
return_value=[package_ahriman])
application_mock = mocker.patch("ahriman.application.application.Application.update", return_value=result)
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
on_start_mock = mocker.patch("ahriman.application.application.Application.on_start")
_, repository_id = configuration.check_loaded()
@ -55,7 +55,7 @@ def test_run(args: argparse.Namespace, package_ahriman: Package, configuration:
extract_mock.assert_called_once_with(pytest.helpers.anyvar(int), args.status, from_database=args.from_database)
application_packages_mock.assert_called_once_with([package_ahriman], None)
application_mock.assert_called_once_with([package_ahriman], Packagers(args.username), bump_pkgrel=args.increment)
check_mock.assert_has_calls([MockCall(False, False), MockCall(False, False)])
check_mock.assert_has_calls([MockCall(False, True), MockCall(False, True)])
on_start_mock.assert_called_once_with()
@ -87,13 +87,13 @@ def test_run_dry_run(args: argparse.Namespace, configuration: Configuration, rep
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
mocker.patch("ahriman.application.handlers.Rebuild.extract_packages", return_value=[package_ahriman])
application_mock = mocker.patch("ahriman.application.application.Application.update")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
print_mock = mocker.patch("ahriman.application.application.Application.print_updates")
_, repository_id = configuration.check_loaded()
Rebuild.run(args, repository_id, configuration, report=False)
application_mock.assert_not_called()
check_mock.assert_called_once_with(False, False)
check_mock.assert_called_once_with(False, True)
print_mock.assert_called_once_with([package_ahriman], log_fn=pytest.helpers.anyvar(int))
@ -142,11 +142,11 @@ def test_run_update_empty_exception(args: argparse.Namespace, configuration: Con
mocker.patch("ahriman.application.handlers.Rebuild.extract_packages")
mocker.patch("ahriman.core.repository.repository.Repository.packages_depend_on", return_value=[])
mocker.patch("ahriman.application.application.Application.print_updates")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
_, repository_id = configuration.check_loaded()
Rebuild.run(args, repository_id, configuration, report=False)
check_mock.assert_called_once_with(True, True)
check_mock.assert_called_once_with(True, False)
def test_run_build_empty_exception(args: argparse.Namespace, configuration: Configuration, repository: Repository,
@ -160,11 +160,11 @@ def test_run_build_empty_exception(args: argparse.Namespace, configuration: Conf
mocker.patch("ahriman.application.handlers.Rebuild.extract_packages")
mocker.patch("ahriman.core.repository.repository.Repository.packages_depend_on", return_value=[package_ahriman])
mocker.patch("ahriman.application.application.Application.update", return_value=Result())
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
_, repository_id = configuration.check_loaded()
Rebuild.run(args, repository_id, configuration, report=False)
check_mock.assert_has_calls([MockCall(True, False), MockCall(True, True)])
check_mock.assert_has_calls([MockCall(True, True), MockCall(True, False)])
def test_extract_packages(application: Application, mocker: MockerFixture) -> None:

View File

@ -39,14 +39,14 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
aur_search_mock = mocker.patch("ahriman.core.alpm.remote.AUR.multisearch", return_value=[aur_package_ahriman])
official_search_mock = mocker.patch("ahriman.core.alpm.remote.Official.multisearch",
return_value=[aur_package_ahriman])
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
_, repository_id = configuration.check_loaded()
Search.run(args, repository_id, configuration, report=False)
aur_search_mock.assert_called_once_with("ahriman")
official_search_mock.assert_called_once_with("ahriman")
check_mock.assert_called_once_with(False, False)
check_mock.assert_called_once_with(False, True)
print_mock.assert_has_calls([
MockCall(verbose=False, log_fn=pytest.helpers.anyvar(int), separator=": "),
MockCall(verbose=False, log_fn=pytest.helpers.anyvar(int), separator=": "),
@ -64,11 +64,11 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat
mocker.patch("ahriman.core.alpm.remote.Official.multisearch", return_value=[])
mocker.patch("ahriman.core.formatters.Printer.print")
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
_, repository_id = configuration.check_loaded()
Search.run(args, repository_id, configuration, report=False)
check_mock.assert_called_once_with(True, True)
check_mock.assert_called_once_with(True, False)
def test_run_sort(args: argparse.Namespace, configuration: Configuration, repository: Repository,

View File

@ -34,13 +34,13 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
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")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
_, 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)
check_mock.assert_called_once_with(args.exit_code, False)
def test_run_skip(args: argparse.Namespace, configuration: Configuration, repository: Repository,
@ -53,7 +53,7 @@ def test_run_skip(args: argparse.Namespace, configuration: Configuration, reposi
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")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
_, repository_id = configuration.check_loaded()
ServiceUpdates.run(args, repository_id, configuration, report=False)

View File

@ -41,14 +41,14 @@ def test_run(args: argparse.Namespace, configuration: Configuration, repository:
packages_mock = mocker.patch("ahriman.core.status.local_client.LocalClient.package_get",
return_value=[(package_ahriman, BuildStatus(BuildStatusEnum.Success)),
(package_python_schedule, BuildStatus(BuildStatusEnum.Failed))])
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
print_mock = mocker.patch("ahriman.core.formatters.Printer.print")
_, repository_id = configuration.check_loaded()
Status.run(args, repository_id, configuration, report=False)
application_mock.assert_called_once_with()
packages_mock.assert_called_once_with(None)
check_mock.assert_called_once_with(False, False)
check_mock.assert_called_once_with(False, True)
print_mock.assert_has_calls([
MockCall(verbose=False, log_fn=pytest.helpers.anyvar(int), separator=": ")
for _ in range(3)
@ -65,11 +65,11 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
mocker.patch("ahriman.core.status.Client.status_get")
mocker.patch("ahriman.core.status.local_client.LocalClient.package_get", return_value=[])
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
_, repository_id = configuration.check_loaded()
Status.run(args, repository_id, configuration, report=False)
check_mock.assert_called_once_with(True, True)
check_mock.assert_called_once_with(True, False)
def test_run_verbose(args: argparse.Namespace, configuration: Configuration, repository: Repository,

View File

@ -58,18 +58,18 @@ def test_check_unsafe(mocker: MockerFixture) -> None:
"""
must check if command is unsafe
"""
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
UnsafeCommands.check_unsafe(["service-clean"], ["service-clean"], _parser())
check_mock.assert_called_once_with(True, True)
check_mock.assert_called_once_with(True, False)
def test_check_unsafe_safe(mocker: MockerFixture) -> None:
"""
must check if command is safe
"""
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
UnsafeCommands.check_unsafe(["package-status"], ["service-clean"], _parser())
check_mock.assert_called_once_with(True, False)
check_mock.assert_called_once_with(True, True)
def test_get_unsafe_commands() -> None:

View File

@ -49,7 +49,7 @@ def test_run(args: argparse.Namespace, package_ahriman: Package, configuration:
result.add_updated(package_ahriman)
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
application_mock = mocker.patch("ahriman.application.application.Application.update", return_value=result)
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
dependencies_mock = mocker.patch("ahriman.application.application.Application.with_dependencies",
return_value=[package_ahriman])
updates_mock = mocker.patch("ahriman.application.application.Application.updates", return_value=[package_ahriman])
@ -66,7 +66,7 @@ def test_run(args: argparse.Namespace, package_ahriman: Package, configuration:
args.package, aur=args.aur, local=args.local, manual=args.manual, vcs=args.vcs, check_files=args.check_files)
changes_mock.assert_called_once_with([package_ahriman])
dependencies_mock.assert_called_once_with([package_ahriman], process_dependencies=args.dependencies)
check_mock.assert_called_once_with(False, False)
check_mock.assert_called_once_with(False, True)
on_start_mock.assert_called_once_with()
print_mock.assert_called_once_with([package_ahriman], log_fn=pytest.helpers.anyvar(int))
@ -81,11 +81,11 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat
args.dry_run = True
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
mocker.patch("ahriman.application.application.Application.updates", return_value=[])
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
_, repository_id = configuration.check_loaded()
Update.run(args, repository_id, configuration, report=False)
check_mock.assert_called_once_with(True, True)
check_mock.assert_called_once_with(True, False)
def test_run_update_empty_exception(args: argparse.Namespace, package_ahriman: Package, configuration: Configuration,
@ -101,11 +101,11 @@ def test_run_update_empty_exception(args: argparse.Namespace, package_ahriman: P
mocker.patch("ahriman.application.application.Application.with_dependencies", return_value=[package_ahriman])
mocker.patch("ahriman.application.application.Application.print_updates")
mocker.patch("ahriman.application.application.Application.changes")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
_, repository_id = configuration.check_loaded()
Update.run(args, repository_id, configuration, report=False)
check_mock.assert_called_once_with(True, True)
check_mock.assert_called_once_with(True, False)
def test_run_dry_run(args: argparse.Namespace, package_ahriman: Package, configuration: Configuration,
@ -117,7 +117,7 @@ def test_run_dry_run(args: argparse.Namespace, package_ahriman: Package, configu
args.dry_run = True
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
application_mock = mocker.patch("ahriman.application.application.Application.update")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
updates_mock = mocker.patch("ahriman.application.application.Application.updates", return_value=[package_ahriman])
changes_mock = mocker.patch("ahriman.application.application.Application.changes")
@ -127,7 +127,7 @@ def test_run_dry_run(args: argparse.Namespace, package_ahriman: Package, configu
args.package, aur=args.aur, local=args.local, manual=args.manual, vcs=args.vcs, check_files=args.check_files)
application_mock.assert_not_called()
changes_mock.assert_called_once_with([package_ahriman])
check_mock.assert_called_once_with(False, pytest.helpers.anyvar(int))
check_mock.assert_called_once_with(False, True)
def test_run_no_changes(args: argparse.Namespace, configuration: Configuration, repository: Repository,
@ -140,7 +140,7 @@ def test_run_no_changes(args: argparse.Namespace, configuration: Configuration,
args.changes = False
mocker.patch("ahriman.core.repository.Repository.load", return_value=repository)
mocker.patch("ahriman.application.application.Application.update")
mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
mocker.patch("ahriman.application.handlers.Handler.check_status")
mocker.patch("ahriman.application.application.Application.updates")
changes_mock = mocker.patch("ahriman.application.application.Application.changes")

View File

@ -97,13 +97,13 @@ def test_run_list(args: argparse.Namespace, configuration: Configuration, databa
args = _default_args(args)
args.action = Action.List
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
list_mock = mocker.patch("ahriman.core.database.SQLite.user_list", return_value=[user])
_, repository_id = configuration.check_loaded()
Users.run(args, repository_id, configuration, report=False)
list_mock.assert_called_once_with("user", args.role)
check_mock.assert_called_once_with(False, False)
check_mock.assert_called_once_with(False, True)
def test_run_empty_exception(args: argparse.Namespace, configuration: Configuration, database: SQLite,
@ -116,11 +116,11 @@ def test_run_empty_exception(args: argparse.Namespace, configuration: Configurat
args.exit_code = True
mocker.patch("ahriman.core.database.SQLite.load", return_value=database)
mocker.patch("ahriman.core.database.SQLite.user_list", return_value=[])
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_if_empty")
check_mock = mocker.patch("ahriman.application.handlers.Handler.check_status")
_, repository_id = configuration.check_loaded()
Users.run(args, repository_id, configuration, report=False)
check_mock.assert_called_once_with(True, True)
check_mock.assert_called_once_with(True, False)
def test_run_remove(args: argparse.Namespace, configuration: Configuration, database: SQLite,

View File

@ -134,9 +134,10 @@ def test_init_bump_pkgrel_skip(task_ahriman: Task, mocker: MockerFixture) -> Non
"""
must keep pkgrel if version is different from provided
"""
task_ahriman.package.version = "2.0.0-1"
mocker.patch("ahriman.models.package.Package.from_build", return_value=task_ahriman.package)
mocker.patch("ahriman.core.build_tools.sources.Sources.load", return_value="sha")
write_mock = mocker.patch("ahriman.models.pkgbuild_patch.PkgbuildPatch.write")
assert task_ahriman.init(Path("ahriman"), [], f"2:{task_ahriman.package.version}") == "sha"
assert task_ahriman.init(Path("ahriman"), [], "1.0.0-1") == "sha"
write_mock.assert_not_called()

View File

@ -24,6 +24,9 @@ def _parser() -> dict[str, dict[str, str]]:
"key3": "${section1:home}",
"key5": "${section1:key4}",
},
"section4:suffix": {
"key6": "value6"
},
}
@ -45,6 +48,10 @@ def test_extract_variables() -> None:
assert not dict(ShellInterpolator._extract_variables(parser, "${section4:key1}", parser["section1"]))
assert dict(ShellInterpolator._extract_variables(parser, "${section4:suffix:key6}", parser["section1"])) == {
"section4:suffix:key6": "value6",
}
def test_environment() -> None:
"""

View File

@ -474,11 +474,11 @@ def test_next_pkgrel(package_ahriman: Package) -> None:
assert package_ahriman.next_pkgrel(package_ahriman.version) == "1.2.2"
package_ahriman.version = "1:1.0.0-1"
assert package_ahriman.next_pkgrel("1:1.0.1-1") is None
assert package_ahriman.next_pkgrel("2:1.0.0-1") is None
assert package_ahriman.next_pkgrel("1:1.0.1-1") == "1.1"
assert package_ahriman.next_pkgrel("2:1.0.0-1") == "1.1"
package_ahriman.version = "1.0.0-1.1"
assert package_ahriman.next_pkgrel("1.0.1-2") is None
assert package_ahriman.next_pkgrel("1.0.1-2") == "2.1"
assert package_ahriman.next_pkgrel("1.0.0-2") == "2.1"
package_ahriman.version = "1.0.0-2"

BIN
web.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 224 KiB

After

Width:  |  Height:  |  Size: 370 KiB