Merge "Add ability validate yaml files before run tests"

This commit is contained in:
Jenkins 2015-11-09 11:44:34 +00:00 committed by Gerrit Code Review
commit cda021a9c6
3 changed files with 21 additions and 0 deletions

View File

@ -61,6 +61,13 @@ section `How to write scenario files`_.
``tox -e scenario etc/scenario/sahara-ci`` will run tests from the test directory.
Also, you can validate your yaml-files using flag ``--validate`` via command:
.. sourcecode:: console
$ tox -e scenario -- --validate -V templatevars.ini etc/scenario/sahara-ci/credantials.yaml.mako etc/scenario/sahara-ci/vanilla-2.7.1.yaml.mako
..
Template variables
------------------

View File

@ -157,6 +157,8 @@ def main():
help='Path to the file with template variables')
parser.add_argument('--verbose', default=False, action='store_true',
help='Increase output verbosity')
parser.add_argument('--validate', default=False, action='store_true',
help='Validate yaml-files, tests will not be runned')
args = parser.parse_args()
scenario_arguments = args.scenario_arguments
@ -200,6 +202,9 @@ def main():
# validate config
validation.validate(config)
if args.validate:
return
set_defaults(config)
credentials = config['credentials']
network = config['network']

View File

@ -269,3 +269,12 @@ class RunnerUnitTest(testtools.TestCase):
'sahara/tests/scenario_unit/templatevars_complete.ini',
'sahara/tests/scenario_unit/vanilla2_7_1.yaml.mako']
runner.main()
@mock.patch('sys.exit', return_value=None)
def test_runner_validate(self, mock_sys):
sys.argv = ['sahara/tests/scenario/runner.py',
'--validate',
'-V',
'sahara/tests/scenario_unit/templatevars_complete.ini',
'sahara/tests/scenario_unit/vanilla2_7_1.yaml.mako']
runner.main()