implement single-function patches (#69)

This commit is contained in:
2022-10-30 03:11:03 +03:00
committed by GitHub
parent ad7cdb7d95
commit 649df81aa5
25 changed files with 632 additions and 163 deletions

View File

@ -5,6 +5,15 @@ from unittest.mock import MagicMock, call
from ahriman.models.pkgbuild_patch import PkgbuildPatch
def test_post_init() -> None:
"""
must remove empty keys
"""
assert PkgbuildPatch("", "value").key is None
assert PkgbuildPatch(None, "value").key is None
assert PkgbuildPatch("key", "value").key == "key"
def test_is_function() -> None:
"""
must correctly define key as function
@ -13,6 +22,14 @@ def test_is_function() -> None:
assert PkgbuildPatch("key()", "value").is_function
def test_is_plain_diff() -> None:
"""
must correctly define key as function
"""
assert not PkgbuildPatch("key", "value").is_plain_diff
assert PkgbuildPatch(None, "value").is_plain_diff
def test_quote() -> None:
"""
must quote strings if unsafe flag is not set
@ -32,6 +49,13 @@ def test_serialize() -> None:
assert PkgbuildPatch("key", "4'2", unsafe=True).serialize() == "key=4'2"
def test_serialize_plain_diff() -> None:
"""
must correctly serialize function values
"""
assert PkgbuildPatch(None, "{ value }").serialize() == "{ value }"
def test_serialize_function() -> None:
"""
must correctly serialize function values