+ def test_EmailCommentListNeinLoopNone(self):
+ v = wrpylib.wrvalidators.EmailCommentListNeinLoopNone()
+ assert v.to_python(u'') == None
+ assert v.to_python(u'Nein') == u'Nein'
+ assert v.to_python(u'first@example.com') == u'first@example.com'
+ assert v.to_python(u'first@example.com (Nur Winter); second@example.com') == u'first@example.com (Nur Winter); second@example.com'
+ assert v.from_python(None) == u''
+ assert v.from_python(u'Nein') == u'Nein'
+ assert v.from_python(u'first@example.com') == u'first@example.com'
+ assert v.from_python(u'first@example.com (Nur Winter); second@example.com') == u'first@example.com (Nur Winter); second@example.com'
+ testvalue = u'abc.def(at)example.com (comment)'
+ try:
+ v.to_python(testvalue)
+ assert False
+ except formencode.Invalid:
+ pass
+ try:
+ v.from_python(testvalue)
+ assert False
+ except formencode.Invalid:
+ pass
+ v = wrpylib.wrvalidators.EmailCommentListNeinLoopNone(allow_masked_email=True)
+ assert v.to_python(testvalue) == testvalue
+ assert v.from_python(testvalue) == testvalue
+
+
+ # test_WikiPage
+
+
+ # test_WikiPageList
+
+
+ def test_WikiPageListLoopNone(self):
+ v = wrpylib.wrvalidators.WikiPageListLoopNone()
+ assert v.to_python(u'') == None
+ assert v.to_python(u'[[Birgitzer Alm]]; [[Kemater Alm]]') == u'[[Birgitzer Alm]]; [[Kemater Alm]]'
+ assert v.from_python(None) == u''
+ assert v.from_python(u'[[Birgitzer Alm]]; [[Kemater Alm]]') == u'[[Birgitzer Alm]]; [[Kemater Alm]]'
+
+
+ # test_TupleSecondValidator
+
+
+ def test_BoolUnicodeTupleValidator(self):
+ v = wrpylib.wrvalidators.BoolUnicodeTupleValidator()
+ assert v.to_python(u'') == (None, None)
+ assert v.to_python(u'Nein') == (False, None)
+ assert v.to_python(u'any text') == (True, u'any text')
+ assert v.from_python((None, None)) == u''
+ assert v.from_python((False, None)) == u'Nein'
+ assert v.from_python((True, u'any text')) == u'any text'
+
+
+
+
+ def test_GermanLift(self):
+ v = wrpylib.wrvalidators.GermanLift()
+ assert v.to_python(u'') == (None, None)
+ assert v.to_python(u'Nein') == (False, None)
+ assert v.to_python(u'Sessellift (4 Euro)') == (True, u'Sessellift (4 Euro)')
+ assert v.from_python((None, None)) == u''
+ assert v.from_python((False, None)) == u'Nein'
+ assert v.from_python((True, u'Sessellift (4 Euro)')) == u'Sessellift (4 Euro)'
+
+
+ def test_SledRental(self):
+ v = wrpylib.wrvalidators.SledRental()
+ assert v.to_python(u'') == (None, None)
+ assert v.to_python(u'Nein') == (False, None)
+ assert v.to_python(u'Ja') == (True, u'Ja')
+ assert v.to_python(u'Talstation (nur mit Ticket); Schneealm') == (True, u'Talstation (nur mit Ticket); Schneealm')
+ assert v.from_python((None, None)) == u''
+ assert v.from_python((False, None)) == u'Nein'
+ assert v.from_python((True, u'Talstation (nur mit Ticket); Schneealm')) == u'Talstation (nur mit Ticket); Schneealm'
+ assert v.from_python((True, u'Ja')) == u'Ja'
+
+
+ def test_RodelbahnboxDictValidator(self):
+ v = wrpylib.wrvalidators.RodelbahnboxDictValidator()
+ other = collections.OrderedDict([
+ (u'Position', u'47.309820 N 9.986508 E'),
+ (u'Position oben', u''),
+ (u'Höhe oben', u'1244'),
+ (u'Position unten', u''),
+ (u'Höhe unten', u'806'),
+ (u'Länge', u'5045'),
+ (u'Schwierigkeit', u''),
+ (u'Lawinen', u'gelegentlich'),
+ (u'Betreiber', u''),
+ (u'Öffentliche Anreise', u'Ja'),
+ (u'Aufstieg möglich', u'Ja'),
+ (u'Aufstieg getrennt', u'Nein'),
+ (u'Gehzeit', u'105'),
+ (u'Aufstiegshilfe', u'Nein'),
+ (u'Beleuchtungsanlage', u'Nein'),
+ (u'Beleuchtungstage', u''),
+ (u'Rodelverleih', u'Ja'),
+ (u'Gütesiegel', u''),
+ (u'Webauskunft', u''),
+ (u'Telefonauskunft', u'+43-664-1808482 (Bergkristallhütte)'),
+ (u'Bild', u'Rodelbahn Bergkristallhütte 2009-03-03.jpg'),
+ (u'In Übersichtskarte', u'Ja'),
+ (u'Forumid', u'72')])
+ python = v.to_python(other, None)
+ other2 = v.from_python(python, None)
+ assert other == other2
+
+
+ def test_GasthausboxDictValidator(self):
+ v = wrpylib.wrvalidators.GasthausboxDictValidator()
+ other = collections.OrderedDict([
+ (u'Position', u'47.295549 N 9.986970 E'),
+ (u'Höhe', u'1250'),
+ (u'Betreiber', u''),
+ (u'Sitzplätze', u''),
+ (u'Übernachtung', u''),
+ (u'Rauchfrei', u'Nein'),
+ (u'Rodelverleih', u''),
+ (u'Handyempfang', u'A1; T-Mobile/Telering'),
+ (u'Homepage', u'http://www.bergkristallhuette.com/'),
+ (u'E-Mail', u'bergkristallhuette@gmx.at'),
+ (u'Telefon', u'+43-664-1808482'),
+ (u'Bild', u'Bergkritsallhütte 2009-02-07.JPG'),
+ (u'Rodelbahnen', u'[[Bergkristallhütte]]')])
+ python = v.to_python(other, None)
+ other2 = v.from_python(python, None)
+ assert other == other2