mirror of
https://github.com/arcan1s/ahriman.git
synced 2025-06-28 06:41:43 +00:00
fix: process list patch values in http requests
This commit parses values from post request as well as always serializes values for the web interface
This commit is contained in:
@ -61,6 +61,7 @@ def test_parse() -> None:
|
||||
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"]
|
||||
assert PkgbuildPatch.parse("key", ["array", "value"]).value == ["array", "value"]
|
||||
|
||||
|
||||
def test_quote() -> None:
|
||||
|
@ -82,6 +82,25 @@ async def test_post_full_diff(client: TestClient, package_ahriman: Package) -> N
|
||||
assert patches == [payload]
|
||||
|
||||
|
||||
async def test_post_array(client: TestClient, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must create patch from list variable
|
||||
"""
|
||||
await client.post(f"/api/v1/packages/{package_ahriman.base}",
|
||||
json={"status": BuildStatusEnum.Success.value, "package": package_ahriman.view()})
|
||||
request_schema = pytest.helpers.schema_request(PatchesView.post)
|
||||
|
||||
payload = {"key": "k", "value": "(array value)"}
|
||||
assert not request_schema.validate(payload)
|
||||
response = await client.post(f"/api/v1/packages/{package_ahriman.base}/patches", json=payload)
|
||||
assert response.status == 204
|
||||
|
||||
response = await client.get(f"/api/v1/packages/{package_ahriman.base}/patches")
|
||||
patches = await response.json()
|
||||
parsed = [PkgbuildPatch(patch["key"], patch["value"]) for patch in patches]
|
||||
assert parsed == [PkgbuildPatch("k", ["array", "value"])]
|
||||
|
||||
|
||||
async def test_post_exception(client: TestClient, package_ahriman: Package) -> None:
|
||||
"""
|
||||
must raise exception on invalid payload
|
||||
|
Reference in New Issue
Block a user