initial
This commit is contained in:
35
test/get_test.py
Normal file
35
test/get_test.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from manipulator import get
|
||||
|
||||
def test_id():
|
||||
x = {}
|
||||
assert get(x, "") == x
|
||||
|
||||
|
||||
def test_simple_id_query():
|
||||
x = [1]
|
||||
|
||||
assert get(x, "#0") == 1
|
||||
|
||||
|
||||
def test_simple_class_query():
|
||||
x = [{"k": "v"}, {"k": "v2"}]
|
||||
|
||||
assert get(x, ".k") == ["v", "v2"]
|
||||
|
||||
|
||||
def test_nested_id_query():
|
||||
x = [{"k": "v"}]
|
||||
|
||||
assert get(x, "#0 #k") == "v"
|
||||
|
||||
|
||||
def test_nested_class_query():
|
||||
x = [{"k": {"k2": "v"}}, {"k": {"k2": "v2"}}]
|
||||
|
||||
assert get(x, ".k .k2") == ["v", "v2"]
|
||||
|
||||
|
||||
def test_complex_query():
|
||||
x = [{"k": "v"}, {"k": {"a": [{"k": 10}, {"k": 11}]}}]
|
||||
|
||||
assert get(x, ".k #1 #a .k") == [10, 11]
|
Reference in New Issue
Block a user