add some tests for values
[tiramisu.git] / test / test_parsing_group.py
index 5f4985c..7b9dffe 100644 (file)
@@ -180,6 +180,9 @@ def test_values_with_master_and_slaves():
     assert cfg.ip_admin_eth0.netmask_admin_eth0 == [None]
     assert cfg.getowner(ip_admin_eth0) == owner
     assert cfg.getowner(netmask_admin_eth0) == owners.default
+    cfg.ip_admin_eth0.ip_admin_eth0 = ["192.168.230.145", "192.168.230.147"]
+    raises(SlaveError, 'cfg.ip_admin_eth0.netmask_admin_eth0.append(None)')
+    raises(SlaveError, 'cfg.ip_admin_eth0.netmask_admin_eth0.pop(0)')
 
 
 def test_reset_values_with_master_and_slaves():
@@ -395,3 +398,12 @@ def test_multi_extend_master():
     cfg.read_write()
     raises(SlaveError, "cfg.ip_admin_eth0.ip_admin_eth0.extend(['ok'])")
     raises(SlaveError, "cfg.ip_admin_eth0.netmask_admin_eth0.extend(['ok'])")
+
+
+def test_multi_non_valid_value():
+    ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé", multi=True)
+    maconfig = OptionDescription('toto', '', [ip_admin_eth0])
+    cfg = Config(maconfig)
+    cfg.read_write()
+    cfg.ip_admin_eth0 = ['a']
+    raises(ValueError, 'cfg.ip_admin_eth0[0] = 1')