mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-04-24 23:37:18 +00:00
* add config validator subcommand * add --exit-code flag * docs & faq update
164 lines
3.8 KiB
Python
164 lines
3.8 KiB
Python
import pytest
|
|
|
|
from ahriman.core.formatters import AurPrinter, ConfigurationPrinter, PackagePrinter, PatchPrinter, StatusPrinter, \
|
|
StringPrinter, TreePrinter, UpdatePrinter, UserPrinter, ValidationPrinter, VersionPrinter
|
|
from ahriman.models.aur_package import AURPackage
|
|
from ahriman.models.build_status import BuildStatus
|
|
from ahriman.models.package import Package
|
|
from ahriman.models.pkgbuild_patch import PkgbuildPatch
|
|
from ahriman.models.user import User
|
|
|
|
|
|
@pytest.fixture
|
|
def aur_package_ahriman_printer(aur_package_ahriman: AURPackage) -> AurPrinter:
|
|
"""
|
|
fixture for AUR package printer
|
|
|
|
Args:
|
|
aur_package_ahriman(AURPackage): AUR package fixture
|
|
|
|
Returns:
|
|
AurPrinter: AUR package printer test instance
|
|
"""
|
|
return AurPrinter(aur_package_ahriman)
|
|
|
|
|
|
@pytest.fixture
|
|
def configuration_printer() -> ConfigurationPrinter:
|
|
"""
|
|
fixture for configuration printer
|
|
|
|
Returns:
|
|
ConfigurationPrinter: configuration printer test instance
|
|
"""
|
|
return ConfigurationPrinter("section", {"key_one": "value_one", "key_two": "value_two"})
|
|
|
|
|
|
@pytest.fixture
|
|
def package_ahriman_printer(package_ahriman: Package) -> PackagePrinter:
|
|
"""
|
|
fixture for package printer
|
|
|
|
Args:
|
|
package_ahriman(Package): package fixture
|
|
|
|
Returns:
|
|
PackagePrinter: package printer test instance
|
|
"""
|
|
return PackagePrinter(package_ahriman, BuildStatus())
|
|
|
|
|
|
@pytest.fixture
|
|
def patch_printer(package_ahriman: Package) -> PatchPrinter:
|
|
"""
|
|
fixture for patch printer
|
|
|
|
Args:
|
|
package_ahriman(Package): package fixture
|
|
|
|
Returns:
|
|
PatchPrinter: patch printer test instance
|
|
"""
|
|
return PatchPrinter(package_ahriman.base, [PkgbuildPatch("key", "value")])
|
|
|
|
|
|
@pytest.fixture
|
|
def status_printer() -> StatusPrinter:
|
|
"""
|
|
fixture for build status printer
|
|
|
|
Returns:
|
|
StatusPrinter: build status printer test instance
|
|
"""
|
|
return StatusPrinter(BuildStatus())
|
|
|
|
|
|
@pytest.fixture
|
|
def string_printer() -> StringPrinter:
|
|
"""
|
|
fixture for any string printer
|
|
|
|
Returns:
|
|
StringPrinter: any string printer test instance
|
|
"""
|
|
return StringPrinter("hello, world")
|
|
|
|
|
|
@pytest.fixture
|
|
def tree_printer(package_ahriman: Package) -> TreePrinter:
|
|
"""
|
|
fixture for tree printer
|
|
|
|
Args:
|
|
package_ahriman(Package): package fixture
|
|
|
|
Returns:
|
|
TreePrinter: tree printer test instance
|
|
"""
|
|
return TreePrinter(0, [package_ahriman])
|
|
|
|
|
|
@pytest.fixture
|
|
def update_printer(package_ahriman: Package) -> UpdatePrinter:
|
|
"""
|
|
fixture for update printer
|
|
|
|
Args:
|
|
package_ahriman(Package): package fixture
|
|
|
|
Returns:
|
|
UpdatePrinter: udpate printer test instance
|
|
"""
|
|
return UpdatePrinter(package_ahriman, None)
|
|
|
|
|
|
@pytest.fixture
|
|
def user_printer(user: User) -> UserPrinter:
|
|
"""
|
|
fixture for user printer
|
|
|
|
Args:
|
|
user(User): user fixture
|
|
|
|
Returns:
|
|
UserPrinter: user printer test instance
|
|
"""
|
|
return UserPrinter(user)
|
|
|
|
|
|
@pytest.fixture
|
|
def validation_printer() -> ValidationPrinter:
|
|
"""
|
|
fixture for validation printer
|
|
|
|
Returns:
|
|
ValidationPrinter: validation printer test instance
|
|
"""
|
|
return ValidationPrinter("root", [
|
|
"root error",
|
|
{
|
|
"child": [
|
|
"child error",
|
|
{
|
|
"grandchild": [
|
|
"grandchild error",
|
|
],
|
|
},
|
|
],
|
|
},
|
|
])
|
|
|
|
|
|
@pytest.fixture
|
|
def version_printer(package_ahriman: Package) -> VersionPrinter:
|
|
"""
|
|
fixture for version printer
|
|
|
|
Args:
|
|
package_ahriman(Package): package fixture
|
|
|
|
Returns:
|
|
VersionPrinter: version printer test instance
|
|
"""
|
|
return VersionPrinter("package", {package_ahriman.base: package_ahriman.version})
|