consistency is now check not_equal if one option has PropertiesOptionError
authorEmmanuel Garette <egarette@cadoles.com>
Wed, 12 Oct 2016 19:58:37 +0000 (21:58 +0200)
committerEmmanuel Garette <egarette@cadoles.com>
Wed, 12 Oct 2016 19:58:37 +0000 (21:58 +0200)
ChangeLog
test/test_option_calculation.py
test/test_option_consistency.py
tiramisu/option/baseoption.py

index 53ab5f1..a76a26c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
index 3ecd047..9da8103 100644 (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'))
index a5fedc4..37dcc9b 100644 (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', '')
index 2f43ffd..f7baa7f 100644 (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: