mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-08-30 21:39:56 +00:00
implement single-function patches (#69)
This commit is contained in:
@ -0,0 +1,8 @@
|
||||
from ahriman.core.database.migrations.m003_patch_variables import steps
|
||||
|
||||
|
||||
def test_migration_package_source() -> None:
|
||||
"""
|
||||
migration must not be empty
|
||||
"""
|
||||
assert steps
|
@ -1,55 +1,96 @@
|
||||
from ahriman.core.database import SQLite
|
||||
from ahriman.models.package import Package
|
||||
from ahriman.models.pkgbuild_patch import PkgbuildPatch
|
||||
|
||||
|
||||
def test_patches_get_insert(database: SQLite, package_ahriman: Package, package_python_schedule: Package) -> None:
|
||||
"""
|
||||
must insert patch to database
|
||||
"""
|
||||
database.patches_insert(package_ahriman.base, "patch_1")
|
||||
database.patches_insert(package_python_schedule.base, "patch_2")
|
||||
assert database.patches_get(package_ahriman.base) == "patch_1"
|
||||
assert not database.build_queue_get()
|
||||
database.patches_insert(package_ahriman.base, PkgbuildPatch(None, "patch_1"))
|
||||
database.patches_insert(package_ahriman.base, PkgbuildPatch("key", "patch_3"))
|
||||
database.patches_insert(package_python_schedule.base, PkgbuildPatch(None, "patch_2"))
|
||||
assert database.patches_get(package_ahriman.base) == [
|
||||
PkgbuildPatch(None, "patch_1"), PkgbuildPatch("key", "patch_3")
|
||||
]
|
||||
|
||||
|
||||
def test_patches_list(database: SQLite, package_ahriman: Package, package_python_schedule: Package) -> None:
|
||||
"""
|
||||
must list all patches
|
||||
"""
|
||||
database.patches_insert(package_ahriman.base, "patch1")
|
||||
database.patches_insert(package_python_schedule.base, "patch2")
|
||||
assert database.patches_list(None) == {package_ahriman.base: "patch1", package_python_schedule.base: "patch2"}
|
||||
database.patches_insert(package_ahriman.base, PkgbuildPatch(None, "patch1"))
|
||||
database.patches_insert(package_ahriman.base, PkgbuildPatch("key", "patch3"))
|
||||
database.patches_insert(package_python_schedule.base, PkgbuildPatch(None, "patch2"))
|
||||
assert database.patches_list(None, []) == {
|
||||
package_ahriman.base: [PkgbuildPatch(None, "patch1"), PkgbuildPatch("key", "patch3")],
|
||||
package_python_schedule.base: [PkgbuildPatch(None, "patch2")],
|
||||
}
|
||||
|
||||
|
||||
def test_patches_list_filter(database: SQLite, package_ahriman: Package, package_python_schedule: Package) -> None:
|
||||
"""
|
||||
must list all patches filtered by package name (same as get)
|
||||
"""
|
||||
database.patches_insert(package_ahriman.base, "patch1")
|
||||
database.patches_insert(package_python_schedule.base, "patch2")
|
||||
database.patches_insert(package_ahriman.base, PkgbuildPatch(None, "patch1"))
|
||||
database.patches_insert(package_python_schedule.base, PkgbuildPatch(None, "patch2"))
|
||||
|
||||
assert database.patches_list(package_ahriman.base) == {package_ahriman.base: "patch1"}
|
||||
assert database.patches_list(package_python_schedule.base) == {package_python_schedule.base: "patch2"}
|
||||
assert database.patches_list(package_ahriman.base, []) == {package_ahriman.base: [PkgbuildPatch(None, "patch1")]}
|
||||
assert database.patches_list(package_python_schedule.base, []) == {
|
||||
package_python_schedule.base: [PkgbuildPatch(None, "patch2")],
|
||||
}
|
||||
|
||||
|
||||
def test_patches_list_filter_by_variable(database: SQLite, package_ahriman: Package,
|
||||
package_python_schedule: Package) -> None:
|
||||
"""
|
||||
must list all patches filtered by package name (same as get)
|
||||
"""
|
||||
database.patches_insert(package_ahriman.base, PkgbuildPatch(None, "patch1"))
|
||||
database.patches_insert(package_ahriman.base, PkgbuildPatch("key", "patch2"))
|
||||
database.patches_insert(package_python_schedule.base, PkgbuildPatch(None, "patch3"))
|
||||
|
||||
assert database.patches_list(None, []) == {
|
||||
package_ahriman.base: [PkgbuildPatch(None, "patch1"), PkgbuildPatch("key", "patch2")],
|
||||
package_python_schedule.base: [PkgbuildPatch(None, "patch3")],
|
||||
}
|
||||
assert database.patches_list(None, ["key"]) == {
|
||||
package_ahriman.base: [PkgbuildPatch("key", "patch2")],
|
||||
}
|
||||
|
||||
|
||||
def test_patches_insert_remove(database: SQLite, package_ahriman: Package, package_python_schedule: Package) -> None:
|
||||
"""
|
||||
must remove patch from database
|
||||
"""
|
||||
database.patches_insert(package_ahriman.base, "patch_1")
|
||||
database.patches_insert(package_python_schedule.base, "patch_2")
|
||||
database.patches_remove(package_ahriman.base)
|
||||
database.patches_insert(package_ahriman.base, PkgbuildPatch(None, "patch1"))
|
||||
database.patches_insert(package_python_schedule.base, PkgbuildPatch(None, "patch2"))
|
||||
database.patches_remove(package_ahriman.base, [])
|
||||
|
||||
assert database.patches_get(package_ahriman.base) is None
|
||||
database.patches_insert(package_python_schedule.base, "patch_2")
|
||||
assert database.patches_get(package_ahriman.base) == []
|
||||
assert database.patches_get(package_python_schedule.base) == [PkgbuildPatch(None, "patch2")]
|
||||
|
||||
|
||||
def test_patches_insert_remove_by_variable(database: SQLite, package_ahriman: Package,
|
||||
package_python_schedule: Package) -> None:
|
||||
"""
|
||||
must remove patch from database by variable
|
||||
"""
|
||||
database.patches_insert(package_ahriman.base, PkgbuildPatch(None, "patch1"))
|
||||
database.patches_insert(package_ahriman.base, PkgbuildPatch("key", "patch3"))
|
||||
database.patches_insert(package_python_schedule.base, PkgbuildPatch(None, "patch2"))
|
||||
database.patches_remove(package_ahriman.base, ["key"])
|
||||
|
||||
assert database.patches_get(package_ahriman.base) == [PkgbuildPatch(None, "patch1")]
|
||||
assert database.patches_get(package_python_schedule.base) == [PkgbuildPatch(None, "patch2")]
|
||||
|
||||
|
||||
def test_patches_insert_insert(database: SQLite, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must update patch in database
|
||||
"""
|
||||
database.patches_insert(package_ahriman.base, "patch_1")
|
||||
assert database.patches_get(package_ahriman.base) == "patch_1"
|
||||
database.patches_insert(package_ahriman.base, PkgbuildPatch(None, "patch1"))
|
||||
assert database.patches_get(package_ahriman.base) == [PkgbuildPatch(None, "patch1")]
|
||||
|
||||
database.patches_insert(package_ahriman.base, "patch_2")
|
||||
assert database.patches_get(package_ahriman.base) == "patch_2"
|
||||
database.patches_insert(package_ahriman.base, PkgbuildPatch(None, "patch2"))
|
||||
assert database.patches_get(package_ahriman.base) == [PkgbuildPatch(None, "patch2")]
|
||||
|
Reference in New Issue
Block a user