test uppercase character before valid domain name for better error message

This commit is contained in:
2014-12-07 14:51:51 +01:00
parent bc65caa4dc
commit 85297d8c4d
5 changed files with 360 additions and 255 deletions

View File

@ -5,6 +5,7 @@ from py.test import raises
from tiramisu.config import Config
from tiramisu.option import DomainnameOption, EmailOption, URLOption, OptionDescription
from tiramisu.error import ValueWarning
from tiramisu.i18n import _
def test_domainname():
@ -36,6 +37,29 @@ def test_domainname():
c.g = '192.168.1.29'
def test_domainname_upper():
d = DomainnameOption('d', '')
od = OptionDescription('a', '', [d])
c = Config(od)
c.read_write()
c.d = 'toto.com'
msg = _('some characters are uppercase')
has_error = False
try:
c.d = 'TOTO.COM'
except ValueError, err:
assert msg in unicode(err)
has_error = True
assert has_error is True
has_error = False
try:
c.d = 'toTo.com'
except ValueError, err:
assert msg in unicode(err)
has_error = True
assert has_error is True
def test_domainname_warning():
d = DomainnameOption('d', '', warnings_only=True)
f = DomainnameOption('f', '', allow_without_dot=True, warnings_only=True)