consistancies can have more than one option
[tiramisu.git] / test / test_option_consistency.py
index 5cf53cd..1c23dac 100644 (file)
@@ -4,7 +4,7 @@ from py.test import raises
 from tiramisu.setting import owners, groups
 from tiramisu.config import Config
 from tiramisu.option import IPOption, NetworkOption, NetmaskOption, IntOption,\
-    SymLinkOption, OptionDescription
+    BroadcastOption, SymLinkOption, OptionDescription
 
 
 def test_consistency_not_equal():
@@ -159,3 +159,22 @@ def test_consistency_network_netmask_multi_master():
     c.a = ['192.168.1.0']
     c.b = ['255.255.255.0']
     raises(ValueError, "c.a = ['192.168.1.1']")
+
+
+def test_consistency_broadcast():
+    a = NetworkOption('a', '', multi=True)
+    b = NetmaskOption('b', '', multi=True)
+    c = BroadcastOption('c', '', multi=True)
+    od = OptionDescription('a', '', [a, b, c])
+    od.impl_set_group_type(groups.master)
+    b.impl_add_consistency('network_netmask', a)
+    c.impl_add_consistency('broadcast', a, b)
+    c = Config(od)
+    c.a = ['192.168.1.0']
+    c.b = ['255.255.255.0']
+    c.c = ['192.168.1.255']
+    raises(ValueError, "c.a = ['192.168.1.1']")
+    c.a = ['192.168.1.0', '192.168.2.128']
+    c.b = ['255.255.255.0', '255.255.255.128']
+    c.c = ['192.168.1.255', '192.168.2.255']
+    raises(ValueError, "c.c[1] = '192.168.2.128'")