import autopath from py.test import raises from tiramisu.setting import owners from tiramisu.config import Config from tiramisu.option import IPOption, NetworkOption, NetmaskOption, \ OptionDescription def test_ip(): a = IPOption('a', '') b = IPOption('b', '', only_private=True) od = OptionDescription('od', '', [a, b]) c = Config(od) c.a = '192.168.1.1' c.a = '192.168.1.0' c.a = '88.88.88.88' c.a = '0.0.0.0' assert(ValueError, "c.a = '255.255.255.0'") c.b = '192.168.1.1' c.b = '192.168.1.0' assert(ValueError, "c.b = '88.88.88.88'") c.b = '0.0.0.0' assert(ValueError, "c.b = '255.255.255.0'") def test_network(): a = NetworkOption('a', '') od = OptionDescription('od', '', [a]) c = Config(od) c.a = '192.168.1.1' c.a = '192.168.1.0' c.a = '88.88.88.88' c.a = '0.0.0.0' assert(ValueError, "c.a = '255.255.255.0'") def test_netmask(): a = NetmaskOption('a', '') od = OptionDescription('od', '', [a]) c = Config(od) assert(ValueError, "c.a = '192.168.1.1'") assert(ValueError, "c.a = '192.168.1.0'") assert(ValueError, "c.a = '88.88.88.88'") c.a = '0.0.0.0' c.a = '255.255.255.0'