refactor DomainnameOption
add options EmailOption and URLOption
This commit is contained in:
@ -2,7 +2,7 @@ import autopath
|
||||
from py.test import raises
|
||||
|
||||
from tiramisu.config import Config
|
||||
from tiramisu.option import DomainnameOption, OptionDescription
|
||||
from tiramisu.option import DomainnameOption, EmailOption, URLOption, OptionDescription
|
||||
|
||||
|
||||
def test_domainname():
|
||||
@ -14,11 +14,12 @@ def test_domainname():
|
||||
c.d = 'toto.com'
|
||||
raises(ValueError, "c.d = 'toto'")
|
||||
c.d = 'toto3.com'
|
||||
c.d = 'toto3.3la'
|
||||
raises(ValueError, "c.d = 'toto3.3la'")
|
||||
raises(ValueError, "c.d = '3toto.com'")
|
||||
c.d = 'toto.co3'
|
||||
raises(ValueError, "c.d = 'toto.co3'")
|
||||
raises(ValueError, "c.d = 'toto_super.com'")
|
||||
c.d = 'toto-.com'
|
||||
raises(ValueError, "c.d = 'toto..com'")
|
||||
|
||||
|
||||
def test_domainname_netbios():
|
||||
@ -41,3 +42,30 @@ def test_domainname_hostname():
|
||||
raises(ValueError, "c.d = 'toto.com'")
|
||||
c.d = 'toto'
|
||||
c.d = 'domainnametoolong'
|
||||
|
||||
|
||||
def test_email():
|
||||
e = EmailOption('e', '')
|
||||
od = OptionDescription('a', '', [e])
|
||||
c = Config(od)
|
||||
c.read_write()
|
||||
c.e = 'root@foo.com'
|
||||
raises(ValueError, "c.e = 'root'")
|
||||
raises(ValueError, "c.e = 'root@domain'")
|
||||
|
||||
|
||||
def test_url():
|
||||
u = URLOption('u', '')
|
||||
od = OptionDescription('a', '', [u])
|
||||
c = Config(od)
|
||||
c.read_write()
|
||||
c.u = 'http://foo.com'
|
||||
c.u = 'https://foo.com'
|
||||
c.u = 'https://foo.com/'
|
||||
raises(ValueError, "c.u = 'ftp://foo.com'")
|
||||
c.u = 'https://foo.com/index.html'
|
||||
c.u = 'https://foo.com/index.html?var=value&var2=val2'
|
||||
raises(ValueError, "c.u = 'https://foo.com/index\\n.html'")
|
||||
c.u = 'https://foo.com:8443'
|
||||
c.u = 'https://foo.com:8443/'
|
||||
c.u = 'https://foo.com:8443/index.html'
|
||||
|
Reference in New Issue
Block a user