summaryrefslogtreecommitdiffstats
path: root/tests/unit/config/test_schemas.py
blob: 7c7dab28df34702d887683529d3ba28ba478a8d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
##############################################################################
# Copyright (c) 2017 ZTE Corp and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
import os

import yaml
import pytest

from deploy.config.schemas import (
    deploy_schema_validate
)


@pytest.fixture(scope="session")
def conf_file_dir(data_root):
    return os.path.join(data_root, 'lab_conf')


@pytest.mark.parametrize('deploy_file_name', [
    ('deploy_virtual1.yml'),
    ('deploy_virtual_error.yml'),
    ('deploy_baremetal.yml')])
def test_deploy_schema_validate(conf_file_dir, deploy_file_name):
    data = yaml.safe_load(open(os.path.join(conf_file_dir, deploy_file_name), 'r'))
    errors = deploy_schema_validate(data)
    if deploy_file_name == 'deploy_virtual1.yml':
        assert errors == []
    elif deploy_file_name == 'deploy_virtual_error.yml':
        assert errors != []
    elif deploy_file_name == 'deploy_baremetal.yml':
        assert errors == []