Exemple #1
0
def test_invert_remove_via_update():
    r = dotted.update({'hello': {
        'there': 'me',
        'not': 'this'
    }}, '-hello.there', dotted.ANY)
    assert r == {'hello': {'not': 'this'}}
Exemple #2
0
def test_numeric_update():
    m = dotted.update({}, '07a', 8)
    assert m == {'07a': 8}
Exemple #3
0
def test_slice_upsert():
    m = dotted.update([], '[:]', ['hello'])
    assert m == ['hello']
Exemple #4
0
def test_slice_append():
    m = dotted.update(['hello', 'there'], '[+:]', ['bye'])
    assert m == ['hello', 'there', 'bye']
Exemple #5
0
def test_slice_prepend():
    m = dotted.update(['hello', 'there'], '[:0]', ['bye'])
    assert m == ['bye', 'hello', 'there']
Exemple #6
0
def test_slice_default():
    m = dotted.update({}, 'stuff[]', ['bye'])
    assert m == {'stuff': ['bye']}
Exemple #7
0
def test_appender_nested_if():
    m = dotted.update({}, 'hello[+?].name', 'Hello')
    assert m == {'hello': [{'name': 'Hello'}]}

    m = dotted.update(m, 'hello[+?].name', 'Hello')
    assert m == {'hello': [{'name': 'Hello'}]}
Exemple #8
0
def test_appender_flat_if():
    m = dotted.update({}, 'hello.there[+?]', 9)
    assert m == {'hello': {'there': [9]}}

    m = dotted.update(m, 'hello.there[+?]', 9)
    assert m == {'hello': {'there': [9]}}
Exemple #9
0
def test_appender_embedded():
    m = dotted.update({'hello': {'there': 7}}, 'hello.list[+]', 9)
    assert m == {'hello': {'there': 7, 'list': [9]}}
Exemple #10
0
def test_appender_nested_from_non_empty():
    m = dotted.update({'hello': [{'name': 'Hello'}]}, 'hello[+].name', 'Bye')
    assert m == {'hello': [{'name': 'Hello'}, {'name': 'Bye'}]}
Exemple #11
0
def test_appender_flat_str():
    m = dotted.update('', '[+]', '1')
    assert m == '1'