test lenght for a slave that have list as callback_params
authorEmmanuel Garette <egarette@cadoles.com>
Thu, 26 Jan 2017 20:18:57 +0000 (21:18 +0100)
committerEmmanuel Garette <egarette@cadoles.com>
Thu, 26 Jan 2017 20:18:57 +0000 (21:18 +0100)
test/test_option_calculation.py
tiramisu/autolib.py

index eebbd3a..b655bc4 100644 (file)
@@ -447,6 +447,24 @@ def test_callback_master_and_slaves_master():
     assert cfg.val1.val2 == [None, None]
 
 
+def test_callback_slave():
+    val1 = StrOption('val1', "", multi=True)
+    val2 = StrOption('val2', "", multi=True, callback=return_value, callback_params={'': (['string', 'new'],)})
+    interface1 = OptionDescription('val1', '', [val1, val2])
+    interface1.impl_set_group_type(groups.master)
+    maconfig = OptionDescription('rootconfig', '', [interface1])
+    cfg = Config(maconfig)
+    cfg.read_write()
+    cfg.val1.val1 = ['val']
+    assert cfg.val1.val2 == ['string']
+    cfg.val1.val1 = ['val', 'val1']
+    assert cfg.val1.val2 == ['string', 'new']
+    cfg.val1.val1 = ['val', 'val1', 'val2']
+    assert cfg.val1.val2 == ['string', 'new', None]
+    cfg.val1.val1 = ['val', 'val1', 'val2', 'val3']
+    assert cfg.val1.val2 == ['string', 'new', None, None]
+
+
 def test_callback_master_and_slaves_master2():
     val1 = StrOption('val1', "", multi=True)
     val2 = StrOption('val2', "", multi=True, default_multi='val2')
index bb7698f..1f86e54 100644 (file)
@@ -236,7 +236,6 @@ def carry_out_calculation(option, context, callback, callback_params,
                 if index < len(ret):
                     ret = ret[index]
                 else:
-                    #FIXME really?
                     ret = None
             else:
                 raise SlaveError(_("callback cannot return a list for a "