]> kaliko git repositories - python-musicpd.git/blobdiff - test.py
Some documentation refactoring, improvements
[python-musicpd.git] / test.py
diff --git a/test.py b/test.py
index 5215917ce898c838c2c53c3cb81f5e7ad42bbd23..0677905a800f319e4cf89318f910007df8061607 100755 (executable)
--- a/test.py
+++ b/test.py
@@ -1,7 +1,7 @@
 #!/usr/bin/env python3
 # coding: utf-8
 # SPDX-FileCopyrightText: 2012-2021  kaliko <kaliko@azylum.org>
-# SPDX-License-Identifier: GPL-3.0-or-later
+# SPDX-License-Identifier: LGPL-3.0-or-later
 # pylint: disable=missing-docstring
 """
 Test suite highly borrowed^Wsteal from python-mpd2 [0] project.
@@ -419,6 +419,12 @@ class TestMPDClient(unittest.TestCase):
         self.client.send_status()
         self.assertRaises(musicpd.CommandError, self.client.noidle)
 
+    def test_send_noidle_calls_noidle(self):
+        self.MPDWillReturn('OK\n') # nothing changed after idle
+        self.client.send_idle()
+        self.client.send_noidle()
+        self.assertMPDReceived('noidle\n')
+
     def test_client_to_client(self):
         self.MPDWillReturn('OK\n')
         self.assertIsNone(self.client.subscribe("monty"))
@@ -608,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()