File: test_query.py

package info (click to toggle)
knot-resolver 6.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 16,392 kB
  • sloc: javascript: 42,732; ansic: 40,312; python: 12,616; cpp: 2,121; sh: 1,997; xml: 193; makefile: 181
file content (18 lines) | stat: -rw-r--r-- 524 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from pytest import raises

from knot_resolver.utils.modeling.query import query


def test_example_from_spec():
    # source of the example: https://jsonpatch.com/
    original = {"baz": "qux", "foo": "bar"}
    patch = [
        {"op": "replace", "path": "/baz", "value": "boo"},
        {"op": "add", "path": "/hello", "value": ["world"]},
        {"op": "remove", "path": "/foo"},
    ]
    expected = {"baz": "boo", "hello": ["world"]}

    result, _ = query(original, "patch", "", patch)

    assert result == expected