3e3996d32a
Add support for local tags which are application specific to allow including of other yaml files or code from scripts. Allows for code to be maintained and tested as seperate files, as well as reduces duplication of yaml code that cannot be macro'ed or easily templated by including it from a common file. Adds support for the following tags: 'include' - load file as yaml code 'include-raw' - load file as data (for scripts) 'include-raw-escaped' - load file as data with escaping braces '{}' as default for use with job-templates Use configuration file options to provide a search path for the files. - Test behaviour of yaml tags independent of any XML generation by comparing json result of yaml parsing to verify that certain tags do/don't recall the yaml.load() method. - Add examples for the include tags via addition tests for YamlParser class Inspired by http://stackoverflow.com/questions/528281/how-can-i-include-an-yaml-file-inside-another Change-Id: Ib90a07043112d4739d6529ceddbc9817668bcec0
30 lines
1.0 KiB
Python
30 lines
1.0 KiB
Python
#!/usr/bin/env python
|
|
#
|
|
# Copyright 2013 Darragh Bailey
|
|
#
|
|
# 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 testtools import TestCase
|
|
from testscenarios.testcase import TestWithScenarios
|
|
from tests.base import get_scenarios, JsonTestCase
|
|
|
|
|
|
class TestCaseLocalYamlInclude(TestWithScenarios, TestCase, JsonTestCase):
|
|
"""
|
|
Verify application specific tags independently of any changes to
|
|
modules XML parsing behaviour
|
|
"""
|
|
fixtures_path = os.path.join(os.path.dirname(__file__), 'fixtures')
|
|
scenarios = get_scenarios(fixtures_path, 'yaml', 'json')
|