]> kaliko git repositories - python-musicpd.git/blobdiff - test.py
Improved Range object to deal with window parameter
[python-musicpd.git] / test.py
diff --git a/test.py b/test.py
index d90bd40962002456c96cf01781d713d8c2ec6b2b..0677905a800f319e4cf89318f910007df8061607 100755 (executable)
--- a/test.py
+++ b/test.py
@@ -614,5 +614,35 @@ class testContextManager(unittest.TestCase):
                 sock.close.assert_not_called()
             sock.close.assert_called()
 
+class testRange(unittest.TestCase):
+
+    def test_range(self):
+        tests = [
+                ((),          ':'),
+                ((None,None), ':'),
+                (('',''),     ':'),
+                (('',),       ':'),
+                ((42,42),     '42:42'),
+                ((42,),       '42:'),
+                (('42',),     '42:'),
+                (('42',None), '42:'),
+                (('42',''),   '42:'),
+        ]
+        for tpl, result in tests:
+            self.assertEqual(str(musicpd.Range(tpl)), result)
+        with self.assertRaises(musicpd.CommandError):
+            #CommandError: Integer expected to start the range: (None, 42)
+            musicpd.Range((None,'42'))
+        with self.assertRaises(musicpd.CommandError):
+            # CommandError: Not an integer: "foo"
+            musicpd.Range(('foo',))
+        with self.assertRaises(musicpd.CommandError):
+            # CommandError: Wrong range: 42 > 41
+            musicpd.Range(('42',41))
+        with self.assertRaises(musicpd.CommandError):
+            # CommandError: Wrong range: 42 > 41
+            musicpd.Range(('42','42','42'))
+
+
 if __name__ == '__main__':
     unittest.main()