Exemplo n.º 1
0
def test_set_not_string():

    dictionary = {'key1': 'value1'}

    patcher = Patcher(dictionary)
    with pytest.raises(exceptions.InvalidValueTypeException):
        patcher.set('key1', 5).finish()
Exemplo n.º 2
0
def test_set_not_string():

    dictionary = {'key1': 'value1'}

    patcher = Patcher(dictionary)
    with pytest.raises(exceptions.InvalidValueTypeException):
        patcher.set('key1', 5).finish()
Exemplo n.º 3
0
def test_set_unicode():

    dictionary = {'key1': 'value1'}

    expected_dictionary = {'key1': 'value2'}

    patcher = Patcher(dictionary)
    dictionary = patcher.set('key1', u'value2').finish()

    assert expected_dictionary == dictionary
Exemplo n.º 4
0
def test_set_list():

    dictionary = {'key1': 'value1'}

    expected_dictionary = {'key1': ['value1', 'value2']}

    patcher = Patcher(dictionary)
    dictionary = patcher.set('key1', '["value1", "value2"]').finish()

    assert expected_dictionary == dictionary
Exemplo n.º 5
0
def test_set_dict():

    dictionary = {'key1': 'value1'}

    expected_dictionary = {'key1': {'key2': 'value2'}}

    patcher = Patcher(dictionary)
    dictionary = patcher.set('key1', '{"key2":"value2"}').finish()

    assert expected_dictionary == dictionary
Exemplo n.º 6
0
def test_set_unicode():

    dictionary = {'key1': 'value1'}

    expected_dictionary = {'key1': 'value2'}

    patcher = Patcher(dictionary)
    dictionary = patcher.set('key1', u'value2').finish()

    assert expected_dictionary == dictionary
Exemplo n.º 7
0
def test_set_existing_two_level_complex_key():

    dictionary = {'key1': {'key2': {'key3': 'value1'}}}

    expected_dictionary = {'key1': {'key2': {'key3': 'value2'}}}

    patcher = Patcher(dictionary)
    dictionary = patcher.set('key1:key2:key3', 'value2').finish()

    assert expected_dictionary == dictionary
Exemplo n.º 8
0
def test_set_complex_key_compound_value():

    dictionary = {'key1': {'key2': 'value1'}}

    expected_dictionary = {'key1': {'key2': {'key3': 'value2'}}}

    patcher = Patcher(dictionary)
    dictionary = patcher.set('key1:key2', '{"key3":"value2"}').finish()

    assert expected_dictionary == dictionary
Exemplo n.º 9
0
def test_set_float():

    dictionary = {'key1': 'value1'}

    expected_dictionary = {'key1': 5.5}

    patcher = Patcher(dictionary)
    dictionary = patcher.set('key1', '5.5').finish()

    assert expected_dictionary == dictionary
Exemplo n.º 10
0
def test_set_float():

    dictionary = {'key1': 'value1'}

    expected_dictionary = {
        'key1': 5.5
    }

    patcher = Patcher(dictionary)
    dictionary = patcher.set('key1', '5.5').finish()

    assert expected_dictionary == dictionary
Exemplo n.º 11
0
def test_set_list():

    dictionary = {'key1': 'value1'}

    expected_dictionary = {
        'key1': ['value1', 'value2']
    }

    patcher = Patcher(dictionary)
    dictionary = patcher.set('key1', '["value1", "value2"]').finish()

    assert expected_dictionary == dictionary
Exemplo n.º 12
0
def test_set_dict():

    dictionary = {'key1': 'value1'}

    expected_dictionary = {
        'key1': {
            'key2': 'value2'
        }}

    patcher = Patcher(dictionary)
    dictionary = patcher.set('key1', '{"key2":"value2"}').finish()

    assert expected_dictionary == dictionary
Exemplo n.º 13
0
def test_set_existing_one_level_complex_key():

    dictionary = {
        'key1': {
            'key2': 'value1'
        }
    }

    expected_dictionary = {
        'key1': {
            'key2': 'value2'
        }
    }

    patcher = Patcher(dictionary)
    dictionary = patcher.set('key1:key2', 'value2').finish()

    assert expected_dictionary == dictionary
Exemplo n.º 14
0
def test_set_complex_key_compound_value():

    dictionary = {
        'key1': {
            'key2': 'value1'
        }
    }

    expected_dictionary = {
        'key1': {
            'key2': {
                'key3': 'value2'
            }
        }}

    patcher = Patcher(dictionary)
    dictionary = patcher.set('key1:key2', '{"key3":"value2"}').finish()

    assert expected_dictionary == dictionary