def test_set_not_string(): dictionary = {'key1': 'value1'} patcher = Patcher(dictionary) with pytest.raises(exceptions.InvalidValueTypeException): patcher.set('key1', 5).finish()
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
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
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
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
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
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
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
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
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
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
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