mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-04-24 07:17:17 +00:00
allow packages without package function
This commit is contained in:
parent
e553d96d33
commit
e98b7ff4ab
@ -100,7 +100,7 @@ class Pkgbuild(Mapping[str, Any]):
|
||||
|
||||
def io(package_name: str) -> IO[str]:
|
||||
# try to read package specific function and fallback to default otherwise
|
||||
content = self.get(f"package_{package_name}") or self["package"]
|
||||
content = self.get(f"package_{package_name}") or self.get("package") or ""
|
||||
return StringIO(content)
|
||||
|
||||
return {package: self.from_io(io(package)) for package in packages}
|
||||
|
@ -66,14 +66,14 @@ def test_from_io_empty(pkgbuild_ahriman: Pkgbuild, mocker: MockerFixture) -> Non
|
||||
|
||||
def test_packages(pkgbuild_ahriman: Pkgbuild) -> None:
|
||||
"""
|
||||
must correctly generate load package function
|
||||
must correctly load package function
|
||||
"""
|
||||
assert pkgbuild_ahriman.packages() == {pkgbuild_ahriman["pkgbase"]: Pkgbuild({})}
|
||||
|
||||
|
||||
def test_packages_multi(resource_path_root: Path) -> None:
|
||||
"""
|
||||
must correctly generate load list of package functions
|
||||
must correctly load list of package functions
|
||||
"""
|
||||
pkgbuild = Pkgbuild.from_file(resource_path_root / "models" / "package_gcc10_pkgbuild")
|
||||
packages = pkgbuild.packages()
|
||||
@ -83,6 +83,14 @@ def test_packages_multi(resource_path_root: Path) -> None:
|
||||
assert all("depends" in package for package in packages.values())
|
||||
|
||||
|
||||
def test_packages_empty(pkgbuild_ahriman: Pkgbuild) -> None:
|
||||
"""
|
||||
must correctly load packages without package functionn
|
||||
"""
|
||||
del pkgbuild_ahriman.fields["package()"]
|
||||
assert pkgbuild_ahriman.packages() == {pkgbuild_ahriman["pkgbase"]: Pkgbuild({})}
|
||||
|
||||
|
||||
def test_getitem(pkgbuild_ahriman: Pkgbuild) -> None:
|
||||
"""
|
||||
must return element by key
|
||||
|
Loading…
Reference in New Issue
Block a user