Пример #1
0
def test_ref_converts_to_leaf_value_specified_by_relative_wildcarded_up_path(example_path):
    example_path.refs.monkey.here_is_a_reference = "foo.bar.baz"
    example_path.monkey.lover = sentinel.monkeylover
    
    r = ref(up(1).refs['%i'].here_is_a_reference)
    
    assert r._convert(example_path['%i'].lover._match()[0]) == sentinel.foobarbaz
Пример #2
0
from treebeard._rel import rel, up
from mock import sentinel
import pytest


@pytest.mark.parametrize("relative_path, expected_value", [(rel.baz, sentinel.foobarbaz),
                                                           (up(1).lar.baz, sentinel.foolarbaz),
                                                           (up(2).moo.bar.baz, sentinel.moobarbaz)])
def test_relative_path_converts_to_value(relative_path, expected_value, example_path, example_context):
    assert relative_path._convert(example_context) == expected_value
Пример #3
0
def test_as_dic_with_relative_patht_converts_to_dict_of_values_two_wildcards(example_wildcarded_context):
    a = as_dict(up(2)["%i"].bar["%j"])
    result = a._convert(example_wildcarded_context)
    assert isinstance(result, dict)
    assert result == dict(bang=sentinel.foobarbang, baz=sentinel.foobarbaz)
Пример #4
0
def test_as_list_with_relative_path_converts_to_list_of_values(example_context):
    a = as_list(up(2)["%i"].bar["%j"])
    result = a._convert(example_context)
    assert isinstance(result, list)
    assert sorted(result) == sorted([sentinel.foobarbaz, sentinel.moobarbaz, sentinel.foobarbang])
Пример #5
0
def test_as_set_with_relative_path_converts_to_set_of_values(example_context):
    a = as_set(up(2)["%i"].bar["%j"])
    result = a._convert(example_context)
    assert isinstance(result, set)
    assert result == {sentinel.foobarbaz, sentinel.moobarbaz, sentinel.foobarbang}