can remove all data in options (value, properties and permissives) with new function in API: c.config.reset()

This commit is contained in:
2018-09-09 13:50:38 +02:00
parent 6110a37cc7
commit 657b401124
6 changed files with 94 additions and 44 deletions

View File

@ -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()

View File

@ -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() == []