예제 #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