Esempio n. 1
0
def test_map_leafs_iterator():
    from bigchaindb import config_utils

    mapping = {
        'a': {'b': {'c': 1},
              'd': {'z': 44}},
        'b': {'d': 2},
        'c': 3
    }

    result = config_utils.map_leafs(lambda x, path: x * 2, mapping)
    assert result == {
        'a': {'b': {'c': 2},
              'd': {'z': 88}},
        'b': {'d': 4},
        'c': 6
    }

    result = config_utils.map_leafs(lambda x, path: path, mapping)
    assert result == {
        'a': {'b': {'c': ['a', 'b', 'c']},
              'd': {'z': ['a', 'd', 'z']}},
        'b': {'d': ['b', 'd']},
        'c': ['c']
    }
def test_map_leafs_iterator():
    from bigchaindb import config_utils

    mapping = {'a': {'b': {'c': 1}, 'd': {'z': 44}}, 'b': {'d': 2}, 'c': 3}

    result = config_utils.map_leafs(lambda x, path: x * 2, mapping)
    assert result == {
        'a': {
            'b': {
                'c': 2
            },
            'd': {
                'z': 88
            }
        },
        'b': {
            'd': 4
        },
        'c': 6
    }

    result = config_utils.map_leafs(lambda x, path: path, mapping)
    assert result == {
        'a': {
            'b': {
                'c': ['a', 'b', 'c']
            },
            'd': {
                'z': ['a', 'd', 'z']
            }
        },
        'b': {
            'd': ['b', 'd']
        },
        'c': ['c']
    }