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

tests/test_wrvalidators.py

index f35c7e107af14dd9d39b7f0f79ec962218408cef..b63ef00ec868bce1628dcbbd4858fd47f43045ad 100644 (file)
@@ -572,9 +572,46 @@ class TestLiftGermanValidator(unittest.TestCase):
         self.assertEqual('Sessellift (Wochenende); Taxi (6 Euro)', lift_german_to_str([('Sessellift', 'Wochenende'), ('Taxi', '6 Euro')]))
 
 
-# TODO: public transport converter
+# public transport converter
 # --------------------------
 
+class TestPublicTransportGerman(unittest.TestCase):
+    def test_from_str(self):
+        self.assertEqual(1, public_transport_german_from_str('Sehr gut'))
+        self.assertEqual(1, opt_public_transport_german_from_str('Sehr gut'))
+        self.assertEqual(2, public_transport_german_from_str('Gut'))
+        self.assertEqual(2, opt_public_transport_german_from_str('Gut'))
+        self.assertEqual(3, public_transport_german_from_str('Mittelmäßig'))
+        self.assertEqual(3, opt_public_transport_german_from_str('Mittelmäßig'))
+        self.assertEqual(4, public_transport_german_from_str('Schlecht'))
+        self.assertEqual(4, opt_public_transport_german_from_str('Schlecht'))
+        self.assertEqual(5, public_transport_german_from_str('Nein'))
+        self.assertEqual(5, opt_public_transport_german_from_str('Nein'))
+        self.assertEqual(6, public_transport_german_from_str('Ja'))
+        self.assertEqual(6, opt_public_transport_german_from_str('Ja'))
+        self.assertEqual(None, opt_public_transport_german_from_str(''))
+        with self.assertRaises(ValueError):
+            public_transport_german_from_str('')
+        with self.assertRaises(ValueError):
+            public_transport_german_from_str('Naja')
+        with self.assertRaises(ValueError):
+            opt_public_transport_german_from_str('Naja')
+
+    def test_to_str(self):
+        self.assertEqual('Sehr gut', public_transport_german_to_str(1))
+        self.assertEqual('Sehr gut', opt_public_transport_german_to_str(1))
+        self.assertEqual('Gut', public_transport_german_to_str(2))
+        self.assertEqual('Gut', opt_public_transport_german_to_str(2))
+        self.assertEqual('Mittelmäßig', public_transport_german_to_str(3))
+        self.assertEqual('Mittelmäßig', opt_public_transport_german_to_str(3))
+        self.assertEqual('Schlecht', public_transport_german_to_str(4))
+        self.assertEqual('Schlecht', opt_public_transport_german_to_str(4))
+        self.assertEqual('Nein', public_transport_german_to_str(5))
+        self.assertEqual('Nein', opt_public_transport_german_to_str(5))
+        self.assertEqual('Ja', public_transport_german_to_str(6))
+        self.assertEqual('Ja', opt_public_transport_german_to_str(6))
+        self.assertEqual('', opt_public_transport_german_to_str(None))
+
 
 # cachet converter
 # ----------------