# -*- coding: utf-8 -*-
# Copyright (C) 2018 Matthias Luescher
#
# Authors:
#  Matthias Luescher
#
# This file is part of edi.
#
# edi is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# edi is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with edi.  If not, see <http://www.gnu.org/licenses/>.

import pytest
from edi.lib.helpers import FatalError
from edi.lib.yamlhelpers import annotated_yaml_load


def test_annotated_yaml_load():
    parsed_yaml = annotated_yaml_load('bingo: bongo', "foo.yaml")
    assert parsed_yaml['bingo'] == 'bongo'

    with pytest.raises(FatalError) as error:
        annotated_yaml_load(':', "foo.yaml")
    assert 'foo.yaml' in error.value.message
    assert 'Invalid yaml configuration' in error.value.message
