Added avalanches tests.
authorphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Tue, 2 Feb 2016 21:10:12 +0000 (21:10 +0000)
committerphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Tue, 2 Feb 2016 21:10:12 +0000 (21:10 +0000)
git-svn-id: http://www.winterrodeln.org/svn/wrpylib/trunk@2450 7aebc617-e5e2-0310-91dc-80fb5f6d2477

tests/test_wrvalidators.py

index 2ca3fbf674c2672d4e5dceddd50c89d58d1ce6e8..f35c7e107af14dd9d39b7f0f79ec962218408cef 100644 (file)
@@ -518,9 +518,37 @@ class TestDifficultyGerman(unittest.TestCase):
         self.assertEqual('leicht', difficulty_german_to_str(1))
 
 
-# TODO: avalanches converter
+# avalanches converter
 # --------------------
 
+class TestAvalancesGermanConverter(unittest.TestCase):
+    def test_from_str(self):
+        self.assertEqual(1, avalanches_german_from_str('kaum'))
+        self.assertEqual(1, opt_avalanches_german_from_str('kaum'))
+        self.assertEqual(2, avalanches_german_from_str('selten'))
+        self.assertEqual(2, opt_avalanches_german_from_str('selten'))
+        self.assertEqual(3, avalanches_german_from_str('gelegentlich'))
+        self.assertEqual(3, opt_avalanches_german_from_str('gelegentlich'))
+        self.assertEqual(4, avalanches_german_from_str('häufig'))
+        self.assertEqual(4, opt_avalanches_german_from_str('häufig'))
+        self.assertEqual(None, opt_avalanches_german_from_str(''))
+        with self.assertRaises(ValueError):
+            avalanches_german_from_str('immer')
+        with self.assertRaises(ValueError):
+            opt_avalanches_german_from_str('immer')
+        with self.assertRaises(ValueError):
+            avalanches_german_from_str('')
+
+    def test_to_str(self):
+        self.assertEqual('kaum', avalanches_german_to_str(1))
+        self.assertEqual('kaum', opt_avalanches_german_to_str(1))
+        self.assertEqual('selten', avalanches_german_to_str(2))
+        self.assertEqual('selten', opt_avalanches_german_to_str(2))
+        self.assertEqual('gelegentlich', avalanches_german_to_str(3))
+        self.assertEqual('gelegentlich', opt_avalanches_german_to_str(3))
+        self.assertEqual('häufig', avalanches_german_to_str(4))
+        self.assertEqual('häufig', opt_avalanches_german_to_str(4))
+        self.assertEqual('', opt_avalanches_german_to_str(None))
 
 
 # lift converter