blob: 2c36a3b6fdc77d894161013649706067150c7d55 [file] [log] [blame]
Lianhao Lu4e3368b2018-08-09 16:45:49 +08001# Copyright (c) 2018 Intel Corp. All rights reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14#
15
16import os
17
18from ruamel import yaml
19import pytest
20
21from vnfsdk_pkgtools.validator import utils
22
23CONTENT = "---\n1"
24
25BAD_CONTENT = "---\na: b\n- d"
26
27def test_load_definition(tmpdir):
28 p = tmpdir.join("test_definition.yaml")
29 p.write(CONTENT)
30 assert 1 == utils.load_definitions(str(p))
31
32
33def test_load_bad_definition(tmpdir):
34 p = tmpdir.join("test_definition.yaml")
35 p.write(BAD_CONTENT)
36 with pytest.raises(yaml.YAMLError):
37 utils.load_definitions(str(p))
38
39
40def test_load_defualt_definition(tmpdir):
41 p = tmpdir.join("non_exist")
42 assert 1 == utils.load_definitions(str(p),defaults=1)