def test_get_compund_object_unsupported_format(): dictionary = {'key1': ['value1', 'value2']} patcher = Patcher(dictionary) with pytest.raises(exceptions.UnsupportedFormatException): patcher.get('key1', fmt='unsupported')
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')
def test_get_compund_object_unsupported_format(): dictionary = { 'key1': ['value1', 'value2'] } patcher = Patcher(dictionary) with pytest.raises(exceptions.UnsupportedFormatException): patcher.get('key1', fmt='unsupported')
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')
def test_get_float(): dictionary = {'key1': 5.5} expected_value = '5.5' patcher = Patcher(dictionary) value = patcher.get('key1') assert expected_value == value
def test_get_integer(): dictionary = {'key1': 5} expected_value = '5' patcher = Patcher(dictionary) value = patcher.get('key1') assert expected_value == value
def test_get_string(): dictionary = {'key1': 'value1'} expected_value = 'value1' patcher = Patcher(dictionary) value = patcher.get('key1') assert expected_value == value
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
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
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
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
def test_get_float(): dictionary = { 'key1': 5.5 } expected_value = '5.5' patcher = Patcher(dictionary) value = patcher.get('key1') assert expected_value == value
def test_get_integer(): dictionary = { 'key1': 5 } expected_value = '5' patcher = Patcher(dictionary) value = patcher.get('key1') assert expected_value == value
def test_get_string(): dictionary = { 'key1': 'value1' } expected_value = 'value1' patcher = Patcher(dictionary) value = patcher.get('key1') assert expected_value == value
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
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
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
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
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
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
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
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