コード例 #1
0
def test_complex_yaml_yaml(complex_yaml_old, complex_yaml_new, complex_result_yaml):
    format_diff = gendiff.formatters.yaml.format_diff
    old_map, new_map = parse_yaml(complex_yaml_old), parse_yaml(complex_yaml_new)
    test_diff = yaml.load(format_diff(generate_diff(old_map, new_map)), 
                          Loader=yaml.SafeLoader)
    ethalon_diff = yaml.load(complex_result_yaml, Loader=yaml.SafeLoader)
    assert test_diff == ethalon_diff
コード例 #2
0
def test_yaml_parse():
    yaml_data = """
        host: hexlet.io
        timeout: 50
        proxy: "123.234.53.22"
"""
    expected = {
        'host': 'hexlet.io',
        'timeout': 50,
        'proxy': '123.234.53.22',
    }

    assert parsers.parse_yaml(yaml_data) == expected
コード例 #3
0
def test_plain_yaml(plain_yaml_old, plain_yaml_new, plain_result_plain):
    format_diff = gendiff.formatters.plain.format_diff
    old_map, new_map = parse_yaml(plain_yaml_old), parse_yaml(plain_yaml_new)
    test_diff = format_diff(generate_diff(old_map, new_map))
    ethalon_diff = plain_result_plain.read()
    assert test_diff == ethalon_diff
コード例 #4
0
def test_complex_yaml_tree(complex_yaml_old, complex_yaml_new, complex_result_tree):
    format_diff = gendiff.formatters.tree.format_diff
    old_map, new_map = parse_yaml(complex_yaml_old), parse_yaml(complex_yaml_new)
    test_diff = format_diff(generate_diff(old_map, new_map))
    ethalon_diff = complex_result_tree.read()
    assert test_diff == ethalon_diff
コード例 #5
0
def get_parsed(file):
    _, ext = splitext(file.name)
    if ext in ['.json']:
        return parse_json(file)
    elif ext in ['.yaml', 'yml']:
        return parse_yaml(file)