# Path: n_utils/aws_infra_util.py
# def yaml_to_dict(yaml_file_to_convert, merge=[]):
#     data = OrderedDict()
#     with open(yaml_file_to_convert) as yaml_file:
#         data = yaml_load(yaml_file)
#     if merge:
#         for i in range(0, len(merge)):
#             with open(merge[i]) as yaml_file:
#                 merge[i] = yaml_load(yaml_file)
#         merge.append(data)
#         merge_data = OrderedDict()
#         merge_data['Fn::Merge'] = merge
#         data = merge_data
#     data = import_scripts(data, yaml_file_to_convert)
#     _patch_launchconf(data)
#     return data


from n_utils.aws_infra_util import yaml_to_dict

def test_merge_import(mocker):
    result = yaml_to_dict('n_utils/tests/templates/test.yaml')
    assert result['Parameters']['paramTest']['Default'] == 'test2'
    assert result['Parameters']['paramTest3']['Default'] == 'test2'
    assert result['Parameters']['paramTest4']['Default'] == 'test2'
    assert result['Parameters']['paramTestA']['Default'] == 'test2'
    assert result['Parameters']['paramTest5']['Default'] == 'TEST2'
    assert result['Parameters']['paramTest6']['Default'] == 'TEST2'
    assert result['Parameters']['paramTest7']['Default'] == 'tEST2'
    assert result['Parameters']['paramTest2']['Default'] == 'TEST2'
    assert result['Parameters']['paramTest8']['Default'] == 'aaabbbST2'
    assert result['Parameters']['paramTest9']['Default'] == 'aabbbST2'
    assert result['Parameters']['paramTest10']['Default'] == 'b/c/d/e/f'
    assert result['Parameters']['paramTest11']['Default'] == 'f'
    assert result['Parameters']['paramTest12']['Default'] == 'a/b/c/d/e'
    assert result['Parameters']['paramTest13']['Default'] == 'a'
    assert result['Parameters']['paramTest14']['Default'] == 'a/b/c/d/e/f'
    assert result['Parameters']['paramTest15']['Default'] == 'b/c/'
    assert result['Parameters']['paramTest16']['Default'] == 'foo'
    assert result['Parameters']['paramTest17']['Default'] == 'foo'
    assert result['Parameters']['paramTest18']['Default'] == 'bar'

def test_just_import(mocker):

# Path: n_utils/aws_infra_util.py
# def yaml_to_dict(yaml_file_to_convert, merge=[]):
#     data = OrderedDict()
#     with open(yaml_file_to_convert) as yaml_file:
#         data = yaml_load(yaml_file)
#     if merge:
#         for i in range(0, len(merge)):
#             with open(merge[i]) as yaml_file:
#                 merge[i] = yaml_load(yaml_file)
#         merge.append(data)
#         merge_data = OrderedDict()
#         merge_data['Fn::Merge'] = merge
#         data = merge_data
#     data = import_scripts(data, yaml_file_to_convert)
#     _patch_launchconf(data)
#     return data


# Path: n_utils/tests/aws_infra_util_test.py
from n_utils.aws_infra_util import yaml_to_dict


def test_merge_import(mocker):
    result = yaml_to_dict('n_utils/tests/templates/test.yaml')
    assert result['Parameters']['paramTest']['Default'] == 'test2'
    assert result['Parameters']['paramTest3']['Default'] == 'test2'
    assert result['Parameters']['paramTest4']['Default'] == 'test2'
    assert result['Parameters']['paramTestA']['Default'] == 'test2'
    assert result['Parameters']['paramTest5']['Default'] == 'TEST2'
    assert result['Parameters']['paramTest6']['Default'] == 'TEST2'
    assert result['Parameters']['paramTest7']['Default'] == 'tEST2'
    assert result['Parameters']['paramTest2']['Default'] == 'TEST2'
    assert result['Parameters']['paramTest8']['Default'] == 'aaabbbST2'
    assert result['Parameters']['paramTest9']['Default'] == 'aabbbST2'
    assert result['Parameters']['paramTest10']['Default'] == 'b/c/d/e/f'
    assert result['Parameters']['paramTest11']['Default'] == 'f'
    assert result['Parameters']['paramTest12']['Default'] == 'a/b/c/d/e'
    assert result['Parameters']['paramTest13']['Default'] == 'a'
    assert result['Parameters']['paramTest14']['Default'] == 'a/b/c/d/e/f'
    assert result['Parameters']['paramTest15']['Default'] == 'b/c/'
    assert result['Parameters']['paramTest16']['Default'] == 'foo'
    assert result['Parameters']['paramTest17']['Default'] == 'foo'
    assert result['Parameters']['paramTest18']['Default'] == 'bar'

def test_just_import(mocker):

    result = yaml_to_dict('n_utils/tests/templates/test-param-import.yaml')