Ejemplo n.º 1
0
def test_select_eq_int(fixture_list):
    result = query(".[] | select(.count == 20)", fixture_list)
    assert 2 == len(result)
    assert 20 == result[0]["count"]
    assert "Python" == result[0]["name"]
    assert 20 == result[1]["count"]
    assert "Scala" == result[1]["name"]
Ejemplo n.º 2
0
def test_get_first_level_child_as_dict(fixture_dict):
    result = query(".first_level_dict", fixture_dict)
    assert result == fixture_dict["first_level_dict"]
Ejemplo n.º 3
0
def test_get_root(fixture_dict):
    result = query(".", fixture_dict)
    assert result == fixture_dict
Ejemplo n.º 4
0
def test_get_second_level_child_list_dict_field(fixture_dict):
    result = query(".first_level_list_dict[].number", fixture_dict)
    assert result == [
        x["number"] for x in fixture_dict["first_level_list_dict"]
    ]
Ejemplo n.º 5
0
def test_get_second_level_child_list(fixture_dict):
    result = query(".first_level_list_int[]", fixture_dict)
    assert result == fixture_dict["first_level_list_int"]
Ejemplo n.º 6
0
def test_get_second_level_child(fixture_dict):
    result = query(".first_level_dict.key_1", fixture_dict)
    assert result == "value_1"
Ejemplo n.º 7
0
def test_get_first_level_child_none(fixture_dict):
    result = query(".missing_one", fixture_dict)
    assert result is None
Ejemplo n.º 8
0
def test_select_eq_str(fixture_list):
    result = query('.[] | select(.name == "Python")', fixture_list)
    assert 1 == len(result)
    assert "Python" == result[0]["name"]
Ejemplo n.º 9
0
def test_iterate_list(fixture_list):
    result = query(".[].name", fixture_list)
    assert [e["name"] for e in fixture_list] == result
Ejemplo n.º 10
0
def test_get_root_as_list(fixture_list):
    result = query(".[]", fixture_list)
    assert result == fixture_list
Ejemplo n.º 11
0
def test_list_flatten(fixture_list):
    result = query(".[].numbers[]", fixture_list)
    assert [y for x in fixture_list for y in x["numbers"]] == result