diff --git a/setup.py b/setup.py index fe3fd181..abbf7581 100644 --- a/setup.py +++ b/setup.py @@ -36,6 +36,7 @@ setup( ], tests_require=[ "pytest", + "pytest-helpers-namespace", "pytest-mock", "pytest-pspec", "pytest-resource-path", @@ -69,7 +70,7 @@ setup( extras_require={ "html-templates": ["Jinja2"], - "test": ["coverage", "pytest", "pytest-mock", "pytest-pspec", "pytest-resource-path"], + "test": ["coverage", "pytest", "pytest-helpers-namespace", "pytest-mock", "pytest-pspec", "pytest-resource-path"], "web": ["Jinja2", "aiohttp", "aiohttp_jinja2", "requests"], }, ) diff --git a/src/ahriman/core/configuration.py b/src/ahriman/core/configuration.py index ab804cb1..e5c6b618 100644 --- a/src/ahriman/core/configuration.py +++ b/src/ahriman/core/configuration.py @@ -125,7 +125,7 @@ class Configuration(configparser.RawConfigParser): load configuration includes """ try: - for path in sorted(self.include.glob(".ini")): + for path in sorted(self.include.glob("*.ini")): self.read(path) except (FileNotFoundError, configparser.NoOptionError): pass diff --git a/src/ahriman/models/package.py b/src/ahriman/models/package.py index 333122ca..3b6780d0 100644 --- a/src/ahriman/models/package.py +++ b/src/ahriman/models/package.py @@ -149,6 +149,12 @@ class Package: :param path: path to package sources directory :return: list of package dependencies including makedepends array, but excluding packages from this base """ + # additional function to remove versions from dependencies + def trim_version(name: str) -> str: + for symbol in ('<', '=', '>'): + name = name.split(symbol)[0] + return name + srcinfo, errors = parse_srcinfo((path / ".SRCINFO").read_text()) if errors: raise InvalidPackageInfo(errors) @@ -159,7 +165,8 @@ class Package: depends.extend(package.get("depends", [])) # we are not interested in dependencies inside pkgbase packages = set(srcinfo["packages"].keys()) - return set(depends + makedepends) - packages + full_list = set(depends + makedepends) - packages + return {trim_version(package_name) for package_name in full_list} @staticmethod def full_version(epoch: Optional[str], pkgver: str, pkgrel: str) -> str: diff --git a/tests/ahriman/conftest.py b/tests/ahriman/conftest.py new file mode 100644 index 00000000..e30bc3b5 --- /dev/null +++ b/tests/ahriman/conftest.py @@ -0,0 +1,14 @@ +import pytest + +from typing import Any, Type, TypeVar + +T = TypeVar("T") + + +# https://stackoverflow.com/a/21611963 +@pytest.helpers.register +def anyvar(cls: Type[T], strict: bool = False) -> T: + class AnyVar(cls): + def __eq__(self, other: Any) -> bool: + return not strict or isinstance(other, cls) + return AnyVar() diff --git a/tests/ahriman/models/test_package.py b/tests/ahriman/models/test_package.py index 0cd3a463..8ed18472 100644 --- a/tests/ahriman/models/test_package.py +++ b/tests/ahriman/models/test_package.py @@ -71,6 +71,17 @@ def test_from_json_view_3(package_tpacpi_bat_git: Package) -> None: assert Package.from_json(package_tpacpi_bat_git.view()) == package_tpacpi_bat_git +def test_dependencies_with_version(mocker: MockerFixture, resource_path_root: Path) -> None: + """ + must load correct list of dependencies with version + """ + srcinfo = (resource_path_root / "models" / "package_yay_srcinfo").read_text() + + mocker.patch("pathlib.Path.read_text", return_value=srcinfo) + + assert Package.dependencies(Path("path")) == {"git", "go", "pacman"} + + def test_actual_version(package_ahriman: Package, repository_paths: RepositoryPaths) -> None: """ must return same actual_version as version is diff --git a/tests/testresources/models/package_tpacpi-bat-git_srcinfo b/tests/testresources/models/package_tpacpi-bat-git_srcinfo index ce6b2426..58fddf92 100644 --- a/tests/testresources/models/package_tpacpi-bat-git_srcinfo +++ b/tests/testresources/models/package_tpacpi-bat-git_srcinfo @@ -14,4 +14,4 @@ pkgbase = tpacpi-bat-git source = git+https://github.com/teleshoes/tpacpi-bat.git b2sums = SKIP -pkgname = tpacpi-bat-git \ No newline at end of file +pkgname = tpacpi-bat-git diff --git a/tests/testresources/models/package_yay_srcinfo b/tests/testresources/models/package_yay_srcinfo new file mode 100644 index 00000000..9d87b70b --- /dev/null +++ b/tests/testresources/models/package_yay_srcinfo @@ -0,0 +1,21 @@ +pkgbase = yay + pkgdesc = Yet another yogurt. Pacman wrapper and AUR helper written in go. + pkgver = 10.2.0 + pkgrel = 1 + url = https://github.com/Jguer/yay + arch = i686 + arch = pentium4 + arch = x86_64 + arch = arm + arch = armv7h + arch = armv6h + arch = aarch64 + license = GPL3 + makedepends = go + depends = pacman>5 + depends = git + optdepends = sudo + source = yay-10.2.0.tar.gz::https://github.com/Jguer/yay/archive/v10.2.0.tar.gz + sha256sums = 755d049ec09cc20bdcbb004b12ab4e35ba3bb94a7dce9dfa544d24f87deda8aa + +pkgname = yay