can remove all data in options (value, properties and permissives) with new function in API: c.config.reset()
This commit is contained in:
@ -342,3 +342,23 @@ def test_help():
|
||||
od2 = OptionDescription('o', '', [od1])
|
||||
cfg = Config(od2)
|
||||
cfg.help(_display=False, _valid=True)
|
||||
|
||||
|
||||
def test_config_reset():
|
||||
descr = make_description()
|
||||
c = Config(descr)
|
||||
assert not c.option('gc.gc2.bool').value.get()
|
||||
assert not c.option('boolop').property.get()
|
||||
assert not c.option('boolop').permissive.get()
|
||||
#
|
||||
c.option('gc.gc2.bool').value.set(True)
|
||||
c.option('boolop').property.add('test')
|
||||
c.option('float').permissive.set(frozenset(['test']))
|
||||
assert c.option('gc.gc2.bool').value.get()
|
||||
assert c.option('boolop').property.get()
|
||||
assert c.option('float').permissive.get()
|
||||
#
|
||||
c.config.reset()
|
||||
assert not c.option('gc.gc2.bool').value.get()
|
||||
assert not c.option('boolop').property.get()
|
||||
assert not c.option('float').permissive.get()
|
||||
|
@ -686,7 +686,7 @@ def test_meta_reset():
|
||||
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
||||
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.2']
|
||||
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == ['192.168.1.1']
|
||||
meta.value.reset('ip_admin_eth0.ip_admin_eth0')
|
||||
meta.option('ip_admin_eth0.ip_admin_eth0').value.reset(children=True)
|
||||
assert meta.option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||
assert meta.config('conf1').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||
assert meta.config('conf2').option('ip_admin_eth0.ip_admin_eth0').value.get() == []
|
||||
|
Reference in New Issue
Block a user