mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-06-28 06:41:43 +00:00
add ability to fitler by dependency list
This commit is contained in:
@ -4,12 +4,19 @@ from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.application.handlers import Rebuild
|
||||
from ahriman.core.configuration import Configuration
|
||||
from ahriman.models.package import Package
|
||||
|
||||
|
||||
def _default_args(args: argparse.Namespace) -> argparse.Namespace:
|
||||
args.depends_on = None
|
||||
return args
|
||||
|
||||
|
||||
def test_run(args: argparse.Namespace, configuration: Configuration, mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must run command
|
||||
"""
|
||||
args = _default_args(args)
|
||||
mocker.patch("pathlib.Path.mkdir")
|
||||
application_packages_mock = mocker.patch("ahriman.core.repository.repository.Repository.packages")
|
||||
application_mock = mocker.patch("ahriman.application.application.Application.update")
|
||||
@ -17,3 +24,36 @@ def test_run(args: argparse.Namespace, configuration: Configuration, mocker: Moc
|
||||
Rebuild.run(args, "x86_64", configuration)
|
||||
application_packages_mock.assert_called_once()
|
||||
application_mock.assert_called_once()
|
||||
|
||||
|
||||
def test_run_filter(args: argparse.Namespace, configuration: Configuration,
|
||||
package_ahriman: Package, package_python_schedule: Package,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must run command with depends filter
|
||||
"""
|
||||
args = _default_args(args)
|
||||
args.depends_on = "python-aur"
|
||||
mocker.patch("pathlib.Path.mkdir")
|
||||
mocker.patch("ahriman.core.repository.repository.Repository.packages",
|
||||
return_value=[package_ahriman, package_python_schedule])
|
||||
application_mock = mocker.patch("ahriman.application.application.Application.update")
|
||||
|
||||
Rebuild.run(args, "x86_64", configuration)
|
||||
application_mock.assert_called_with([package_ahriman])
|
||||
|
||||
|
||||
def test_run_without_filter(args: argparse.Namespace, configuration: Configuration,
|
||||
package_ahriman: Package, package_python_schedule: Package,
|
||||
mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must run command for all packages if no filter supplied
|
||||
"""
|
||||
args = _default_args(args)
|
||||
mocker.patch("pathlib.Path.mkdir")
|
||||
mocker.patch("ahriman.core.repository.repository.Repository.packages",
|
||||
return_value=[package_ahriman, package_python_schedule])
|
||||
application_mock = mocker.patch("ahriman.application.application.Application.update")
|
||||
|
||||
Rebuild.run(args, "x86_64", configuration)
|
||||
application_mock.assert_called_with([package_ahriman, package_python_schedule])
|
||||
|
@ -61,6 +61,7 @@ def package_description_ahriman() -> PackageDescription:
|
||||
architecture="x86_64",
|
||||
archive_size=4200,
|
||||
build_date=42,
|
||||
depends=["devtools", "git", "pyalpm", "python-aur", "python-srcinfo"],
|
||||
description="ArcHlinux ReposItory MANager",
|
||||
filename="ahriman-0.12.1-1-any.pkg.tar.zst",
|
||||
groups=[],
|
||||
@ -75,6 +76,7 @@ def package_description_python_schedule() -> PackageDescription:
|
||||
architecture="x86_64",
|
||||
archive_size=4201,
|
||||
build_date=421,
|
||||
depends=["python"],
|
||||
description="Python job scheduling for humans.",
|
||||
filename="python-schedule-1.0.0-2-any.pkg.tar.zst",
|
||||
groups=[],
|
||||
@ -89,6 +91,7 @@ def package_description_python2_schedule() -> PackageDescription:
|
||||
architecture="x86_64",
|
||||
archive_size=4202,
|
||||
build_date=422,
|
||||
depends=["python2"],
|
||||
description="Python job scheduling for humans.",
|
||||
filename="python2-schedule-1.0.0-2-any.pkg.tar.zst",
|
||||
groups=[],
|
||||
|
@ -42,6 +42,7 @@ def pyalpm_package_description_ahriman(package_description_ahriman: PackageDescr
|
||||
mock = MagicMock()
|
||||
type(mock).arch = PropertyMock(return_value=package_description_ahriman.architecture)
|
||||
type(mock).builddate = PropertyMock(return_value=package_description_ahriman.build_date)
|
||||
type(mock).depends = PropertyMock(return_value=package_description_ahriman.depends)
|
||||
type(mock).desc = PropertyMock(return_value=package_description_ahriman.description)
|
||||
type(mock).groups = PropertyMock(return_value=package_description_ahriman.groups)
|
||||
type(mock).isize = PropertyMock(return_value=package_description_ahriman.installed_size)
|
||||
|
@ -9,6 +9,16 @@ from ahriman.models.package import Package
|
||||
from ahriman.models.repository_paths import RepositoryPaths
|
||||
|
||||
|
||||
def test_depends(package_python_schedule: Package) -> None:
|
||||
"""
|
||||
must return combined list of dependencies
|
||||
"""
|
||||
assert all(
|
||||
set(package_python_schedule.depends).intersection(package.depends)
|
||||
for package in package_python_schedule.packages.values()
|
||||
)
|
||||
|
||||
|
||||
def test_git_url(package_ahriman: Package) -> None:
|
||||
"""
|
||||
must generate valid git url
|
||||
|
Reference in New Issue
Block a user