mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-06-28 06:41:43 +00:00
fix: correctly serialize patches from database (#137)
If value is stored as array in database it is serialized as json, but read as normal string, which lead to innability to use list patches This fix also removes any postprocessing (unquoting) for functions
This commit is contained in:
@ -15,6 +15,22 @@ def test_patches_get_insert(database: SQLite, package_ahriman: Package, package_
|
||||
]
|
||||
|
||||
|
||||
def test_patches_get_insert_array(database: SQLite, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must insert array patch to database
|
||||
"""
|
||||
database.patches_insert(package_ahriman.base, [PkgbuildPatch("array", ["array", "value"])])
|
||||
assert database.patches_get(package_ahriman.base) == [PkgbuildPatch("array", ["array", "value"])]
|
||||
|
||||
|
||||
def test_patches_get_insert_function(database: SQLite, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must insert function patch to database
|
||||
"""
|
||||
database.patches_insert(package_ahriman.base, [PkgbuildPatch("function()", "{ function body' }")])
|
||||
assert database.patches_get(package_ahriman.base) == [PkgbuildPatch("function()", "{ function body' }")]
|
||||
|
||||
|
||||
def test_patches_list(database: SQLite, package_ahriman: Package, package_python_schedule: Package) -> None:
|
||||
"""
|
||||
must list all patches
|
||||
|
@ -1,3 +1,4 @@
|
||||
import json
|
||||
import pytest
|
||||
import shlex
|
||||
|
||||
@ -63,9 +64,11 @@ def test_parse() -> None:
|
||||
"""
|
||||
must parse string correctly
|
||||
"""
|
||||
assert PkgbuildPatch.parse("VALUE") == "VALUE"
|
||||
assert PkgbuildPatch.parse("(ARRAY VALUE)") == ["ARRAY", "VALUE"]
|
||||
assert PkgbuildPatch.parse("""("QU'OUTED" ARRAY VALUE)""") == ["QU'OUTED", "ARRAY", "VALUE"]
|
||||
assert PkgbuildPatch.parse("key", "VALUE").value == "VALUE"
|
||||
assert PkgbuildPatch.parse("key", "(ARRAY VALUE)").value == ["ARRAY", "VALUE"]
|
||||
assert PkgbuildPatch.parse("key", """("QU'OUTED" ARRAY VALUE)""").value == ["QU'OUTED", "ARRAY", "VALUE"]
|
||||
assert PkgbuildPatch.parse("key()", """{ function with " quotes }""").value == """{ function with " quotes }"""
|
||||
assert PkgbuildPatch.parse("key", json.dumps(["array", "value"])).value == ["array", "value"]
|
||||
|
||||
|
||||
def test_unquote() -> None:
|
||||
|
Reference in New Issue
Block a user