From c31590c2ac811aa3d318827b2642196852ffb4ae Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Wed, 12 Oct 2016 21:58:37 +0200 Subject: [PATCH] consistency is now check not_equal if one option has PropertiesOptionError --- ChangeLog | 4 ++++ test/test_option_calculation.py | 4 ++-- test/test_option_consistency.py | 32 ++++++++++++++++++++++++++++++++ tiramisu/option/baseoption.py | 2 +- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 53ab5f1..a76a26c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Wed Oct 12 21:55:53 2016 +0200 Emmanuel Garette + * consistency is now check "not_equal" if one option has + PropertiesOptionError + Mon Oct 10 21:39:04 2016 +0200 Emmanuel Garette * consistency with default value for all values now works * warnings works now even if default value is None diff --git a/test/test_option_calculation.py b/test/test_option_calculation.py index 3ecd047..9da8103 100644 --- a/test/test_option_calculation.py +++ b/test/test_option_calculation.py @@ -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')) diff --git a/test/test_option_consistency.py b/test/test_option_consistency.py index a5fedc4..37dcc9b 100644 --- a/test/test_option_consistency.py +++ b/test/test_option_consistency.py @@ -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', '') diff --git a/tiramisu/option/baseoption.py b/tiramisu/option/baseoption.py index 2f43ffd..f7baa7f 100644 --- a/tiramisu/option/baseoption.py +++ b/tiramisu/option/baseoption.py @@ -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: