add tests for coverage
This commit is contained in:
parent
33e68dbebf
commit
3a1745a885
@ -250,7 +250,11 @@ def test_groups_with_master_make_dict():
|
||||
od = OptionDescription('root', '', [interface1])
|
||||
api = Config(od)
|
||||
assert api.value.dict() == {'ip_admin_eth0.ip_admin_eth0': [], 'ip_admin_eth0.netmask_admin_eth0': []}
|
||||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.len() == 0
|
||||
assert api.option('ip_admin_eth0.netmask_admin_eth0').value.len() == 0
|
||||
api.option('ip_admin_eth0.ip_admin_eth0').value.set(['ip1', 'ip2'])
|
||||
assert api.option('ip_admin_eth0.ip_admin_eth0').value.len() == 2
|
||||
assert api.option('ip_admin_eth0.netmask_admin_eth0').value.len() == 2
|
||||
assert api.value.dict() == {'ip_admin_eth0.ip_admin_eth0': ['ip1', 'ip2'], 'ip_admin_eth0.netmask_admin_eth0': [None, None]}
|
||||
|
||||
|
||||
|
@ -123,6 +123,26 @@ def test_unknown_option():
|
||||
raises(AttributeError, "api.option('od.unknown.suboption').value.get()")
|
||||
|
||||
|
||||
def test_optiondescription_list():
|
||||
groups.notfamily1 = groups.GroupType('notfamily1')
|
||||
i = IntOption('test', '')
|
||||
i2 = IntOption('test', '')
|
||||
od1 = OptionDescription('od', '', [i])
|
||||
od1.impl_set_group_type(groups.family)
|
||||
od3 = OptionDescription('od2', '', [i2])
|
||||
od3.impl_set_group_type(groups.notfamily1)
|
||||
od2 = OptionDescription('od', '', [od1, od3])
|
||||
od4 = OptionDescription('od', '', [od2])
|
||||
api = Config(od4)
|
||||
assert len(list(api.option('od').list('option'))) == 0
|
||||
assert len(list(api.option('od').list('optiondescription'))) == 2
|
||||
assert len(list(api.option('od').list('optiondescription', group_type=groups.family))) == 1
|
||||
assert len(list(api.option('od').list('optiondescription', group_type=groups.notfamily1))) == 1
|
||||
assert len(list(api.option('od.od').list('option'))) == 1
|
||||
assert len(list(api.option('od.od2').list('option'))) == 1
|
||||
raises(APIError, "list(api.option.list('unknown'))")
|
||||
|
||||
|
||||
def test_optiondescription_group():
|
||||
groups.notfamily = groups.GroupType('notfamily')
|
||||
i = IntOption('test', '')
|
||||
@ -133,6 +153,7 @@ def test_optiondescription_group():
|
||||
od3.impl_set_group_type(groups.notfamily)
|
||||
od2 = OptionDescription('od', '', [od1, od3])
|
||||
api = Config(od2)
|
||||
assert len(list(api.option.list('option'))) == 0
|
||||
assert len(list(api.option.list('optiondescription'))) == 2
|
||||
assert len(list(api.option.list('optiondescription', group_type=groups.family))) == 1
|
||||
assert len(list(api.option.list('optiondescription', group_type=groups.notfamily))) == 1
|
||||
|
@ -201,6 +201,7 @@ def test_apply_requires_from_config():
|
||||
api.option('int').value.set(1)
|
||||
raises(PropertiesOptionError, "api.option('opt.str').value.get()")
|
||||
assert 'hidden' in api.forcepermissive.option('opt.str').property.get()
|
||||
assert 'hidden' not in api.forcepermissive.option('opt.str').property.get(apply_requires=False)
|
||||
|
||||
|
||||
def test_apply_requires_with_disabled():
|
||||
@ -215,6 +216,7 @@ def test_apply_requires_with_disabled():
|
||||
assert not 'disabled' in api.option('opt.str').property.get()
|
||||
api.option('int').value.set(1)
|
||||
raises(PropertiesOptionError, "api.option('opt.str').value.get()")
|
||||
assert 'disabled' not in api.unrestraint.option('opt.str').property.get(apply_requires=False)
|
||||
assert 'disabled' in api.unrestraint.option('opt.str').property.get()
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user