consistency is now check not_equal if one option has PropertiesOptionError

This commit is contained in:
Emmanuel Garette 2016-10-12 21:58:37 +02:00
parent 0eff0cd989
commit c31590c2ac
4 changed files with 39 additions and 3 deletions

View File

@ -1,3 +1,7 @@
Wed Oct 12 21:55:53 2016 +0200 Emmanuel Garette <egarette@cadoles.com>
* consistency is now check "not_equal" if one option has
PropertiesOptionError
Mon Oct 10 21:39:04 2016 +0200 Emmanuel Garette <egarette@cadoles.com>
* consistency with default value for all values now works
* warnings works now even if default value is None

View File

@ -480,7 +480,7 @@ def test_callback_master_and_slaves_master4():
assert list(cfg.cfgimpl_get_values().mandatory_warnings(force_permissive=True)) == []
def test_callback_master_and_slaves_master_mandatory_transitive():
def test_consistency_master_and_slaves_master_mandatory_transitive():
#default value
val1 = IPOption('val1', "", ['192.168.0.1'], multi=True, properties=('mandatory',))
val2 = NetmaskOption('val2', "", multi=True, default_multi='255.255.255.0', properties=('disabled', 'mandatory'))
@ -501,7 +501,7 @@ def test_callback_master_and_slaves_master_mandatory_transitive():
assert list(cfg.cfgimpl_get_values().mandatory_warnings(force_permissive=True)) == []
def test_callback_master_and_slaves_master_mandatory_non_transitive():
def test_consistency_master_and_slaves_master_mandatory_non_transitive():
#no value
val1 = IPOption('val1', "", multi=True, properties=('mandatory',))
val2 = NetmaskOption('val2', "", multi=True, default_multi='255.255.255.0', properties=('disabled', 'mandatory'))

View File

@ -117,6 +117,38 @@ def test_consistency_not_equal_many_opts():
raises(ValueError, "c.e = 3")
def test_consistency_not_equal_many_opts_one_disabled():
a = IntOption('a', '')
b = IntOption('b', '')
c = IntOption('c', '')
d = IntOption('d', '')
e = IntOption('e', '')
f = IntOption('f', '')
g = IntOption('g', '', properties=('disabled',))
od = OptionDescription('od', '', [a, b, c, d, e, f, g])
a.impl_add_consistency('not_equal', b, c, d, e, f, g, transitive=False)
c = Config(od)
c.read_write()
assert c.a is None
assert c.b is None
#
c.a = 1
del(c.a)
#
c.a = 1
raises(ValueError, "c.b = 1")
#
c.b = 2
raises(ValueError, "c.f = 2")
raises(ValueError, "c.f = 1")
#
c.d = 3
raises(ValueError, "c.f = 3")
raises(ValueError, "c.a = 3")
raises(ValueError, "c.c = 3")
raises(ValueError, "c.e = 3")
def test_consistency_not_in_config_1():
a = IntOption('a', '')
b = IntOption('b', '')

View File

@ -419,7 +419,7 @@ class Option(OnlyOption):
if transitive:
return opt_value
else:
return
opt_value = None
else:
return opt_value
elif index is None: