Added a test to OrderedSchema.
authorphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Mon, 10 Mar 2014 20:56:32 +0000 (20:56 +0000)
committerphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Mon, 10 Mar 2014 20:56:32 +0000 (20:56 +0000)
git-svn-id: http://www.winterrodeln.org/svn/wrpylib/trunk@1921 7aebc617-e5e2-0310-91dc-80fb5f6d2477

tests/test_wrvalidators.py

index fcce7e2b4e1f29cfc8d417c55da5a6bd843bfc59..1383ec56585bd6f2767c444c96f6c15bec708fa9 100644 (file)
@@ -5,6 +5,23 @@ import wrpylib.wrvalidators
 import formencode
 
 
+def test_OrderedSchema():
+    v = wrpylib.wrvalidators.OrderedSchema()
+    v.pre_validators = [formencode.Validator()]
+    v.chained_validators = [formencode.Validator()]
+    v.add_field(u'c', formencode.Validator())
+    v.add_field(u'b', formencode.Validator())
+    v.add_field(u'a', formencode.Validator())
+    v.add_field(u'd', formencode.Validator())
+    other = collections.OrderedDict([('d', 'd'), ('b', 'b'), ('a', 'a'), ('c', 'c')])
+    python = v.to_python(other)
+    assert python.keys() == other.keys()
+    assert python.values() == other.values()
+    other2 = v.from_python(python)
+    assert other.keys() == other2.keys()
+    assert other.values() == other2.values()
+
+
 def test_NoneValidator():
     v =  wrpylib.wrvalidators.NoneValidator(wrpylib.wrvalidators.Unicode())
     assert v.to_python(u'') == None