Implemented test for bool_germen_from/to_german.
authorphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Tue, 2 Feb 2016 21:10:05 +0000 (21:10 +0000)
committerphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Tue, 2 Feb 2016 21:10:05 +0000 (21:10 +0000)
git-svn-id: http://www.winterrodeln.org/svn/wrpylib/trunk@2448 7aebc617-e5e2-0310-91dc-80fb5f6d2477

tests/test_wrvalidators.py

index d6e031189e2406602de1c98de8f09a7c1c5a392f..ff56cfe237c10e28de1c060bf5242232465713b0 100644 (file)
@@ -249,9 +249,28 @@ class TestOptUInt(unittest.TestCase):
         self.assertEqual('', opt_uint_to_str(None))
 
 
-# TODO: bool converter
+# bool converter
 # --------------
 
+class TestBoolGerman(unittest.TestCase):
+    def test_from_str(self):
+        self.assertEqual(True, bool_german_from_str('Ja'))
+        self.assertEqual(True, opt_bool_german_from_str('Ja'))
+        self.assertEqual(False, bool_german_from_str('Nein'))
+        self.assertEqual(False, opt_bool_german_from_str('Nein'))
+        self.assertEqual(None, opt_bool_german_from_str(''))
+        with self.assertRaises(ValueError):
+            bool_german_from_str('Vielleicht')
+            opt_bool_german_from_str('Vielleicht')
+            bool_german_from_str('')
+
+    def test_to_str(self):
+        self.assertEqual('Ja', bool_german_to_str(True))
+        self.assertEqual('Ja', opt_bool_german_to_str(True))
+        self.assertEqual('Nein', bool_german_to_str(False))
+        self.assertEqual('Nein', opt_bool_german_to_str(False))
+        self.assertEqual('', opt_bool_german_to_str(None))
+
 
 # tristate converter
 # ------------------