Adding new test case to do heat yaml file validation

As we know the yaml file will change time to time, an validation test case
will help to reduce mistakes when changing yaml files.

Change-Id: Ie44e89b7661fb5d4f18a4e8544529975ce2e6071
Closes-Bug: #1504722
This commit is contained in:
Eli Qiao 2015-10-10 13:40:24 +08:00
parent 620ed2a66f
commit a371d4c848
2 changed files with 37 additions and 0 deletions

View File

View File

@ -0,0 +1,37 @@
# Copyright 2015 Intel, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import os
from glob import glob
from oslo_config import cfg
from yaml import load
from magnum.common import paths
from magnum.tests import base
cfg.CONF.register_opts([cfg.StrOpt('template_path',
default=paths.basedir_def('templates'),
help='Heat template path')])
class TestTemplate(base.TestCase):
def test_template_yaml(self):
for yml in [y for x in os.walk(cfg.CONF.template_path)
for y in glob(os.path.join(x[0], '*.yaml'))]:
with open(yml, 'r') as f:
yml_contents = f.read()
load(yml_contents)