tests: conf test message, small rq test
Change-Id: I41a9a145e24ac8bba8ee7975957468558a5dd10a
This commit is contained in:
parent
5ff2ea57c9
commit
722e747d07
@ -22,6 +22,7 @@ from timmy import conf
|
||||
|
||||
class ConfTest(unittest.TestCase):
|
||||
def test_param_presence_and_types(self):
|
||||
type_error = 'config key %s has incorrect type %s, should be %s'
|
||||
param_types = {
|
||||
'hard_filter': dict,
|
||||
'soft_filter': dict,
|
||||
@ -56,7 +57,9 @@ class ConfTest(unittest.TestCase):
|
||||
}
|
||||
config = conf.load_conf(None)
|
||||
for key in param_types:
|
||||
self.assertEqual(type(config[key]), param_types[key])
|
||||
self.assertEqual(type(config[key]), param_types[key],
|
||||
type_error % (key, type(config[key]),
|
||||
param_types[key]))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
53
timmy/tests/test_rq.py
Normal file
53
timmy/tests/test_rq.py
Normal file
@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env python2
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2015 Mirantis, 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
|
||||
import unittest
|
||||
from timmy import conf, tools
|
||||
|
||||
|
||||
class RQDefault(unittest.TestCase):
|
||||
def test_filelists(self):
|
||||
def iter_dict(d):
|
||||
for el in d.values():
|
||||
if type(el) is dict:
|
||||
iter_dict(el)
|
||||
elif type(el) is str:
|
||||
self.assertEqual(os.path.sep in el, False, sep_error % el)
|
||||
else:
|
||||
for sub in el:
|
||||
self.assertEqual(os.path.sep in sub, False,
|
||||
sep_error % el)
|
||||
|
||||
sep_error = ('default filelist value %s has path separator(s) - this '
|
||||
'will cause NodeManager to search the file by full path '
|
||||
'instead of looking in the default rq/filelists path.')
|
||||
config = conf.load_conf(None)
|
||||
for rqfile in config['rqfile']:
|
||||
f = rqfile['file']
|
||||
if os.path.sep in f:
|
||||
src = tools.load_yaml_file(f)
|
||||
else:
|
||||
f = os.path.join(self.rqdir, f)
|
||||
src = tools.load_yaml_file(f)
|
||||
filelists = src['filelists']
|
||||
iter_dict(filelists)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Loading…
x
Reference in New Issue
Block a user