+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
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'))
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'))
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', '')
if transitive:
return opt_value
else:
- return
+ opt_value = None
else:
return opt_value
elif index is None: