Emmanuel Garette
6de65859b4
* _cfgimpl_ => _impl_ * optimpl_ => impl_ * properties/permissives are now set/frozenset * validation raise ValueError if not valid, didn't return anything otherwise * consistencies are now validate in setting and when deleting value * ip/network with netmask consistency now works * DomainnameOption now works * if no validation, don't set cache for value * symlinkoption: remove path (not used)
46 lines
1.2 KiB
Python
46 lines
1.2 KiB
Python
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'
|