-#!/usr/bin/python2.6
+#!/usr/bin/python2.7
# -*- coding: iso-8859-15 -*-
import wrpylib.wrvalidators
import formencode
assert v.from_python(None) == u''
+# test_NeinValidator
+
+
+# test_Unicode
+
+
+# test_UnicodeNone
+
+
+# test_Unsigned
+
+
def test_UnsignedNone():
v = wrpylib.wrvalidators.UnsignedNone()
assert v.to_python(u'42') == 42
assert v.from_python(None) == u''
-def test_GeoNone():
- coord = u'47.076207 N 11.453553 E'
- v = wrpylib.wrvalidators.GeoNone()
- (lat, lon) = v.to_python(coord)
- assert lat == 47.076207
- assert lon == 11.453553
- assert v.to_python(u'') == (None, None)
+# test_UnsignedNeinNone
- assert v.from_python((lat, lon)) == coord
- assert v.from_python((None, None)) == u''
+
+# test_Loop
+
+
+# test_DictValidator
+
+
+# test_GermanBoolNone
def test_GermanTristateTuple():
assert v.from_python((True, True)) == u'Teilweise'
-def tes_GermanTristateFloat():
+def test_GermanTristateFloat():
v = wrpylib.wrvalidators.GermanTristateFloat()
assert v.to_python(u'') == None
assert v.to_python(u'Ja') == 1.0
assert v.from_python(0.5) == u'Teilweise'
+# test_ValueComment
+
+
+# test_SemicolonList
+
+
def test_ValueCommentList():
v = wrpylib.wrvalidators.ValueCommentList()
assert v.to_python(u'abc') == [(u'abc', None)]
assert v.to_python(u'value (comment)') == [(u'value', u'comment')]
assert v.to_python(u'value1 (comment); value2') == [(u'value1', u'comment'), (u'value2', None)]
assert v.to_python(u'value1 (comment1); value2; value3 (comment3)') == [(u'value1', u'comment1'), (u'value2', None), ('value3', 'comment3')]
- assert v.to_python(u'value1 (comment1); value2 (test (not easy))') == [(u'value1', u'comment1'), (u'value2', u'test (not easy)')]
+ assert v.to_python(u'value1 (comment1); [[link (linkcomment)]] (not easy)') == [(u'value1', u'comment1'), (u'[[link (linkcomment)]]', u'not easy')]
+
+
+# test_GenericDateTime
+
+
+# test_DateTimeNoSec
+
+
+# test_DateNone
+
+
+# test_Geo
+
+
+def test_GeoNone():
+ coord = u'47.076207 N 11.453553 E'
+ v = wrpylib.wrvalidators.GeoNone()
+ (lat, lon) = v.to_python(coord)
+ assert lat == 47.076207
+ assert lon == 11.453553
+ assert v.to_python(u'') == (None, None)
+
+ assert v.from_python((lat, lon)) == coord
+ assert v.from_python((None, None)) == u''
+
+
+# test_MultiGeo
+
+
+# test_AustrianPhoneNumber
+
+
+# test_AustrianPhoneNumberNone
+
+
+# test_AustrianPhoneNumberCommentLoop
+
+
+# test_GermanDifficulty
+
+
+# test_GermanAvalanches
+
+
+def test_GermanPublicTransport():
+ v = wrpylib.wrvalidators.GermanPublicTransport()
+ assert v.to_python(u'') is None
+ assert v.to_python(u'Sehr gut') == 1
+ assert v.to_python(u'Gut') == 2
+ assert v.to_python(u'Mittelmäßig') == 3
+ assert v.to_python(u'Schlecht') == 4
+ assert v.to_python(u'Nein') == 5
+ assert v.to_python(u'Ja') == 6
+
+ assert v.from_python(None) == u''
+ assert v.from_python(1) == u'Sehr gut'
+ assert v.from_python(2) == u'Gut'
+ assert v.from_python(3) == u'Mittelmäßig'
+ assert v.from_python(4) == u'Schlecht'
+ assert v.from_python(5) == u'Nein'
+ assert v.from_python(6) == u'Ja'
+ assert v.from_python(1l) == u'Sehr gut'
+
+
+# test_GermanTristateFloatComment
+
+
+# test_UnsignedCommentNone
+
+
+# test_GermanCachet
+
+
+# test_url
def test_UrlNeinNone():
assert v.from_python(None) == u''
assert v.from_python(u'Nein') == u'Nein'
assert v.from_python(u'T-Mobile (gut); A1') == u'T-Mobile (gut); A1'
+
+
+# test_PhoneNumber
def test_PhoneCommentListNeinLoopNone():
assert v.from_python(u'+43-699-1234567 (nicht nach 20:00 Uhr); +43-512-123456') == u'+43-699-1234567 (nicht nach 20:00 Uhr); +43-512-123456'
+def test_MaskedEmail():
+ v = wrpylib.wrvalidators.MaskedEmail()
+ assert v.to_python(u'') == (None, None)
+ assert v.to_python(u'abc.def@example.com') == (u'abc.def@example.com', False)
+ assert v.to_python(u'abc.def(at)example.com') == (u'abc.def@example.com', True)
+ assert v.from_python((None, None)) == u''
+ assert v.from_python((u'abc.def@example.com', False)) == u'abc.def@example.com'
+ assert v.from_python((u'abc.def@example.com', True)) == u'abc.def(at)example.com'
+
+
def test_EmailCommentListNeinLoopNone():
v = wrpylib.wrvalidators.EmailCommentListNeinLoopNone()
assert v.to_python(u'') == None
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
-def test_GermanLift():
- 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)'
+# test_WikiPage
+
+
+# test_WikiPageList
def test_WikiPageListLoopNone():
assert v.from_python(u'[[Birgitzer Alm]]; [[Kemater Alm]]') == u'[[Birgitzer Alm]]; [[Kemater Alm]]'
+# test_TupleSecondValidator
+
+
def test_BoolUnicodeTupleValidator():
v = wrpylib.wrvalidators.BoolUnicodeTupleValidator()
assert v.to_python(u'') == (None, None)
assert v.from_python((True, u'any text')) == u'any text'
+
+
+def test_GermanLift():
+ 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():
v = wrpylib.wrvalidators.SledRental()
assert v.to_python(u'') == (None, None)
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_RodelbahnboxValidator():
+ v = wrpylib.wrvalidators.RodelbahnboxValidator()
+ other = {
+ 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'Gehzeit': u'105',
+ u'Aufstieg möglich': u'Ja',
+ u'Aufstieg getrennt': u'Nein',
+ 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
+