mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-07-29 13:49:57 +00:00
add ability to specify package source explicitly during the addition
This commit is contained in:
47
tests/ahriman/models/test_package_source.py
Normal file
47
tests/ahriman/models/test_package_source.py
Normal file
@ -0,0 +1,47 @@
|
||||
from pytest_mock import MockerFixture
|
||||
|
||||
from ahriman.models.package_source import PackageSource
|
||||
|
||||
|
||||
def test_resolve_non_auto() -> None:
|
||||
"""
|
||||
must resolve non auto type to itself
|
||||
"""
|
||||
for source in filter(lambda src: src != PackageSource.Auto, PackageSource):
|
||||
assert source.resolve("") == source
|
||||
|
||||
|
||||
def test_resolve_archive(mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must resolve auto type into the archive
|
||||
"""
|
||||
mocker.patch("pathlib.Path.is_dir", return_value=False)
|
||||
mocker.patch("pathlib.Path.is_file", return_value=True)
|
||||
assert PackageSource.Auto.resolve("linux-5.14.2.arch1-2-x86_64.pkg.tar.zst") == PackageSource.Archive
|
||||
|
||||
|
||||
def test_resolve_directory(mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must resolve auto type into the directory
|
||||
"""
|
||||
mocker.patch("pathlib.Path.is_dir", return_value=True)
|
||||
mocker.patch("pathlib.Path.is_file", return_value=False)
|
||||
assert PackageSource.Auto.resolve("path") == PackageSource.Directory
|
||||
|
||||
|
||||
def test_resolve_aur(mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must resolve auto type into the AUR package
|
||||
"""
|
||||
mocker.patch("pathlib.Path.is_dir", return_value=False)
|
||||
mocker.patch("pathlib.Path.is_file", return_value=False)
|
||||
assert PackageSource.Auto.resolve("package") == PackageSource.AUR
|
||||
|
||||
|
||||
def test_resolve_aur_not_package_like(mocker: MockerFixture) -> None:
|
||||
"""
|
||||
must resolve auto type into the AUR package if it is file, but does not look like a package archive
|
||||
"""
|
||||
mocker.patch("pathlib.Path.is_dir", return_value=False)
|
||||
mocker.patch("pathlib.Path.is_file", return_value=True)
|
||||
assert PackageSource.Auto.resolve("package") == PackageSource.AUR
|
Reference in New Issue
Block a user