示例#1
0
def test_get_compund_object_unsupported_format():

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

    patcher = Patcher(dictionary)

    with pytest.raises(exceptions.UnsupportedFormatException):
        patcher.get('key1', fmt='unsupported')
示例#2
0
def test_get_non_existing_two_level_complex_key():

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

    patcher = Patcher(dictionary)

    with pytest.raises(exceptions.KeyNotFoundException):
        patcher.get('key1:key2:key4')
示例#3
0
def test_get_compund_object_unsupported_format():

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

    patcher = Patcher(dictionary)

    with pytest.raises(exceptions.UnsupportedFormatException):
        patcher.get('key1', fmt='unsupported')
示例#4
0
def test_get_non_existing_two_level_complex_key():

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

    patcher = Patcher(dictionary)

    with pytest.raises(exceptions.KeyNotFoundException):
        patcher.get('key1:key2:key4')
示例#5
0
def test_get_float():

    dictionary = {'key1': 5.5}

    expected_value = '5.5'

    patcher = Patcher(dictionary)
    value = patcher.get('key1')

    assert expected_value == value
示例#6
0
def test_get_integer():

    dictionary = {'key1': 5}

    expected_value = '5'

    patcher = Patcher(dictionary)
    value = patcher.get('key1')

    assert expected_value == value
示例#7
0
def test_get_string():

    dictionary = {'key1': 'value1'}

    expected_value = 'value1'

    patcher = Patcher(dictionary)
    value = patcher.get('key1')

    assert expected_value == value
示例#8
0
def test_get_existing_one_level_complex_key():

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

    expected_value = 'value1'

    patcher = Patcher(dictionary)
    value = patcher.get('key1:key2')

    assert expected_value == value
示例#9
0
def test_get_dict_as_yaml():

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

    expected_value = 'key2: value1\n'

    patcher = Patcher(dictionary)
    value = patcher.get('key1', fmt=constants.YAML)

    assert expected_value == value
示例#10
0
def test_get_ini_section():

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

    expected_value = writer.dumps(obj={'key1': 'key2'},
                                  fmt=constants.PROPERTIES)

    patcher = Patcher(dictionary)
    value = patcher.get('section', fmt=constants.INI)

    assert expected_value == value
示例#11
0
def test_get_list_as_yaml():

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

    expected_value = '''- value1
- value2\n'''

    patcher = Patcher(dictionary)
    value = patcher.get('key1', fmt=constants.YAML)

    assert expected_value == value
示例#12
0
def test_get_float():

    dictionary = {
        'key1': 5.5
    }

    expected_value = '5.5'

    patcher = Patcher(dictionary)
    value = patcher.get('key1')

    assert expected_value == value
示例#13
0
def test_get_integer():

    dictionary = {
        'key1': 5
    }

    expected_value = '5'

    patcher = Patcher(dictionary)
    value = patcher.get('key1')

    assert expected_value == value
示例#14
0
def test_get_string():

    dictionary = {
        'key1': 'value1'
    }

    expected_value = 'value1'

    patcher = Patcher(dictionary)
    value = patcher.get('key1')

    assert expected_value == value
示例#15
0
def test_get_dict_as_json():

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

    expected_value = '''{
  "key2": "value1"
}'''

    patcher = Patcher(dictionary)
    value = patcher.get('key1')

    assert expected_value == value
示例#16
0
def test_get_list_as_yaml():

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

    expected_value = '''- value1
- value2\n'''

    patcher = Patcher(dictionary)
    value = patcher.get('key1', fmt=constants.YAML)

    assert expected_value == value
示例#17
0
def test_get_existing_one_level_complex_key():

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

    expected_value = 'value1'

    patcher = Patcher(dictionary)
    value = patcher.get('key1:key2')

    assert expected_value == value
示例#18
0
def test_get_dict_as_yaml():

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

    expected_value = 'key2: value1\n'

    patcher = Patcher(dictionary)
    value = patcher.get('key1', fmt=constants.YAML)

    assert expected_value == value
示例#19
0
def test_get_ini_section():

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

    expected_value = writer.dumps(obj={'key1': 'key2'}, fmt=constants.PROPERTIES)

    patcher = Patcher(dictionary)
    value = patcher.get('section', fmt=constants.INI)

    assert expected_value == value
示例#20
0
def test_get_list_as_json():

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

    expected_value = '''[
"value1",
"value2"
]'''

    patcher = Patcher(dictionary)
    value = patcher.get('key1')

    actual = value.replace(' ', '')

    assert expected_value == actual
示例#21
0
def test_get_dict_as_json():

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

    expected_value = '''{
  "key2": "value1"
}'''

    patcher = Patcher(dictionary)
    value = patcher.get('key1')

    assert expected_value == value
示例#22
0
def test_get_list_as_json():

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

    expected_value = '''[
"value1",
"value2"
]'''

    patcher = Patcher(dictionary)
    value = patcher.get('key1')

    actual = value.replace(' ', '')

    assert expected_value == actual