add cidr notation to domainnameoption if allow_ip is True (fixes #5)
This commit is contained in:
@ -4,8 +4,7 @@ do_autopath()
|
||||
import warnings, sys
|
||||
from py.test import raises
|
||||
|
||||
from tiramisu import Config
|
||||
from tiramisu.option import DomainnameOption, EmailOption, URLOption, OptionDescription
|
||||
from tiramisu import Config, DomainnameOption, EmailOption, URLOption, OptionDescription
|
||||
from tiramisu.error import ValueWarning
|
||||
from tiramisu.i18n import _
|
||||
from tiramisu.storage import list_sessions
|
||||
@ -19,9 +18,11 @@ def test_domainname():
|
||||
d = DomainnameOption('d', '')
|
||||
f = DomainnameOption('f', '', allow_without_dot=True)
|
||||
g = DomainnameOption('g', '', allow_ip=True)
|
||||
od = OptionDescription('a', '', [d, f, g])
|
||||
h = DomainnameOption('h', '', allow_ip=True, cidr=True)
|
||||
od = OptionDescription('a', '', [d, f, g, h])
|
||||
cfg = Config(od)
|
||||
cfg.property.read_write()
|
||||
#
|
||||
cfg.option('d').value.set('toto.com')
|
||||
raises(ValueError, "cfg.option('d').value.set('toto')")
|
||||
cfg.option('d').value.set('toto3.com')
|
||||
@ -40,9 +41,17 @@ def test_domainname():
|
||||
cfg.option('f').value.set('d.t')
|
||||
#
|
||||
raises(ValueError, "cfg.option('f').value.set('192.168.1.1')")
|
||||
raises(ValueError, "cfg.option('f').value.set('192.168.1.0/24')")
|
||||
#
|
||||
cfg.option('g').value.set('toto.com')
|
||||
cfg.option('g').value.set('192.168.1.0')
|
||||
cfg.option('g').value.set('192.168.1.29')
|
||||
raises(ValueError, "cfg.option('g').value.set('192.168.1.0/24')")
|
||||
#
|
||||
cfg.option('h').value.set('toto.com')
|
||||
raises(ValueError, "cfg.option('h').value.set('192.168.1.0')")
|
||||
raises(ValueError, "cfg.option('h').value.set('192.168.1.29')")
|
||||
cfg.option('h').value.set('192.168.1.0/24')
|
||||
|
||||
|
||||
def test_domainname_upper():
|
||||
|
Reference in New Issue
Block a user