right OrderedDict (for python2) and use fixture for test_tree_od_permissive

This commit is contained in:
Emmanuel Garette 2017-10-25 22:24:34 +02:00
parent 582b0c027c
commit 39348a14aa
1 changed files with 59 additions and 53 deletions

View File

@ -754,39 +754,39 @@ def make_api(options, multi):
DICT_PATHS = [
#test a config without optiondescription
OrderedDict({'first': 'first',
'second': 'second_disabled',
'third': 'third_hidden'}),
OrderedDict([('first', 'first'),
('second', 'second_disabled'),
('third', 'third_hidden')]),
#test a config with an optiondescription
OrderedDict({'subod.first': 'subod.first',
'subod.second': 'subod.second_disabled',
'subod.third': 'subod.third_hidden'}),
OrderedDict([('subod.first', 'subod.first'),
('subod.second', 'subod.second_disabled'),
('subod.third', 'subod.third_hidden')]),
#test a config with two optiondescription
OrderedDict({'subod.subsubod.first': 'subod.subsubod.first',
'subod.subsubod.second': 'subod.subsubod.second_disabled',
'subod.subsubod.third': 'subod.subsubod.third_hidden'}),
OrderedDict([('subod.subsubod.first', 'subod.subsubod.first'),
('subod.subsubod.second', 'subod.subsubod.second_disabled'),
('subod.subsubod.third', 'subod.subsubod.third_hidden')]),
#test a config with mix of different optiondescription
OrderedDict({'first': 'first',
'subod.second': 'subod.second_disabled',
'subod.subsubod.third': 'subod.subsubod.third_hidden'}),
OrderedDict([('first', 'first'),
('subod.second', 'subod.second_disabled'),
('subod.subsubod.third', 'subod.subsubod.third_hidden')]),
#test a config with masterslaves
OrderedDict({'first.first': 'first_master.first',
'first.second': 'first_master.second_disabled',
'first.third': 'first_master.third_hidden'}),
OrderedDict([('first.first', 'first_master.first'),
('first.second', 'first_master.second_disabled'),
('first.third', 'first_master.third_hidden')]),
##test a config with dynoption
OrderedDict({'subodval1.firstval1': 'subod_dyn.first',
'subodval1.secondval1': 'subod_dyn.second_disabled',
'subodval1.thirdval1': 'subod_dyn.third_hidden',
'subodval2.firstval2': None,
'subodval2.secondval2': None,
'subodval2.thirdval2': None}),
OrderedDict([('subodval1.firstval1', 'subod_dyn.first'),
('subodval1.secondval1', 'subod_dyn.second_disabled'),
('subodval1.thirdval1', 'subod_dyn.third_hidden'),
('subodval2.firstval2', None),
('subodval2.secondval2', None),
('subodval2.thirdval2', None)]),
#test a config with dynoption subdir
OrderedDict({'subod.subodval1.firstval1': 'subod.subod_dyn.first',
'subod.subodval1.secondval1': 'subod.subod_dyn.second_disabled',
'subod.subodval1.thirdval1': 'subod.subod_dyn.third_hidden',
'subod.subodval2.firstval2': None,
'subod.subodval2.secondval2': None,
'subod.subodval2.thirdval2': None})
OrderedDict([('subod.subodval1.firstval1', 'subod.subod_dyn.first'),
('subod.subodval1.secondval1', 'subod.subod_dyn.second_disabled'),
('subod.subodval1.thirdval1', 'subod.subod_dyn.third_hidden'),
('subod.subodval2.firstval2', None),
('subod.subodval2.secondval2', None),
('subod.subodval2.thirdval2', None)])
]
@ -814,25 +814,31 @@ def test_options(paths):
#print(api.help)
@display_info
def test_tree_od_permissive():
DICT_PATHS2 = [
OrderedDict([('subod.subsubod.first', 'subod.subsubod_hidden.first'),
('subod.subsubod.second', 'subod.subsubod_hidden.second'),
('subod.subsubod.third', 'subod.subsubod_hidden.third_hidden')]),
OrderedDict([('subod.subodval1.firstval1', 'subod.subod_dyn_hidden.first'),
('subod.subodval1.secondval1', 'subod.subod_dyn_hidden.second'),
('subod.subodval1.thirdval1', 'subod.subod_dyn_hidden.third_hidden'),
('subod.subodval2.firstval2', None),
('subod.subodval2.secondval2', None),
('subod.subodval2.thirdval2', None)])
]
@pytest.fixture(scope="function", params=DICT_PATHS2)
def paths2(request):
print(u'\n{} {}: {}'.format(ICON, request.function.__name__, request.param))
return request.param
def test_tree_od_permissive(paths2):
"""permissive when optiondescription is hidden
"""
tpaths = [
OrderedDict({'subod.subsubod.first': 'subod.subsubod_hidden.first',
'subod.subsubod.second': 'subod.subsubod_hidden.second',
'subod.subsubod.third': 'subod.subsubod_hidden.third_hidden'}),
OrderedDict({'subod.subodval1.firstval1': 'subod.subod_dyn_hidden.first',
'subod.subodval1.secondval1': 'subod.subod_dyn_hidden.second',
'subod.subodval1.thirdval1': 'subod.subod_dyn_hidden.third_hidden',
'subod.subodval2.firstval2': None,
'subod.subodval2.secondval2': None,
'subod.subodval2.thirdval2': None})
]
for paths in tpaths:
lpaths = list(paths.keys())
lpaths = list(paths2.keys())
for multi in (False, True):
api = make_api(paths.values(), multi)
api = make_api(paths2.values(), multi)
if api is None:
continue
check_all(api, lpaths[0], multi, permissive=True)