Added nested_delete and config_delete
This commit is contained in:
@@ -2,7 +2,7 @@ from typing import Any, Dict, List
|
||||
|
||||
import pytest
|
||||
|
||||
from libbot import sync
|
||||
from libbot.sync._nested import nested_delete, nested_set
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -33,9 +33,7 @@ def test_nested_set_valid(
|
||||
create_missing: bool,
|
||||
expected: Any,
|
||||
):
|
||||
assert (
|
||||
sync.nested_set(target, value, *path, create_missing=create_missing)
|
||||
) == expected
|
||||
assert (nested_set(target, value, *path, create_missing=create_missing)) == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@@ -59,5 +57,25 @@ def test_nested_set_invalid(
|
||||
):
|
||||
with pytest.raises(expected):
|
||||
assert (
|
||||
sync.nested_set(target, value, *path, create_missing=create_missing)
|
||||
nested_set(target, value, *path, create_missing=create_missing)
|
||||
) == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"target, path, expected",
|
||||
[
|
||||
({"foo": "bar"}, ["foo"], {}),
|
||||
({"foo": "bar", "bar": "foo"}, ["bar"], {"foo": "bar"}),
|
||||
(
|
||||
{"foo": {"bar": {}}},
|
||||
["foo", "bar"],
|
||||
{"foo": {}},
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_nested_delete(
|
||||
target: Dict[str, Any],
|
||||
path: List[str],
|
||||
expected: Any,
|
||||
):
|
||||
assert (nested_delete(target, *path)) == expected
|
||||
|
Reference in New Issue
Block a user