]> kaliko git repositories - python-musicpd.git/blobdiff - test.py
Update commands list in test
[python-musicpd.git] / test.py
diff --git a/test.py b/test.py
index 449101b994f6c096b989cb9df0de3afbe5553064..3da30bbed90d44dfdf8902007fb1871b19efe55c 100755 (executable)
--- a/test.py
+++ b/test.py
@@ -61,6 +61,26 @@ class testEnvVar(unittest.TestCase):
         self.assertEqual(client.pwd, 'pa55w04d')
         self.assertEqual(client.host, 'example.org')
 
+        # Test host alone
+        os.environ['MPD_HOST'] = 'example.org'
+        client = musicpd.MPDClient()
+        self.assertFalse(client.pwd)
+        self.assertEqual(client.host, 'example.org')
+
+        # Test password extraction (no host)
+        os.environ['MPD_HOST'] = 'pa55w04d@'
+        with mock.patch('os.path.exists', return_value=False):
+            client = musicpd.MPDClient()
+        self.assertEqual(client.pwd, 'pa55w04d')
+        self.assertEqual(client.host, 'localhost')
+
+        # Test badly formatted MPD_HOST
+        os.environ['MPD_HOST'] = '@'
+        with mock.patch('os.path.exists', return_value=False):
+            client = musicpd.MPDClient()
+        self.assertEqual(client.pwd, None)
+        self.assertEqual(client.host, 'localhost')
+
         # Test unix socket extraction
         os.environ['MPD_HOST'] = 'pa55w04d@/unix/sock'
         client = musicpd.MPDClient()
@@ -112,7 +132,7 @@ class testEnvVar(unittest.TestCase):
 class TestMPDClient(unittest.TestCase):
 
     longMessage = True
-    # last sync: musicpd 0.4.2 unreleased / Mon Nov 17 21:45:22 CET 2014
+    # last sync: musicpd 0.6.0 unreleased / Fri Feb 19 15:34:53 CET 2021
     commands = {
             # Status Commands
             'clearerror':         'nothing',
@@ -129,6 +149,7 @@ class TestMPDClient(unittest.TestCase):
             'random':             'nothing',
             'repeat':             'nothing',
             'setvol':             'nothing',
+            'getvol':             'object',
             'single':             'nothing',
             'replay_gain_mode':   'nothing',
             'replay_gain_status': 'item',
@@ -143,7 +164,7 @@ class TestMPDClient(unittest.TestCase):
             'seekid':             'nothing',
             'seekcur':            'nothing',
             'stop':               'nothing',
-            # Playlist Commands
+            # Queue Commands
             'add':                'nothing',
             'addid':              'item',
             'clear':              'nothing',
@@ -179,19 +200,23 @@ class TestMPDClient(unittest.TestCase):
             'rm':                 'nothing',
             'save':               'nothing',
             # Database Commands
+            'albumart':           'composite',
             'count':              'object',
+            'getfingerprint':     'object',
             'find':               'songs',
             'findadd':            'nothing',
             'list':               'list',
             'listall':            'database',
             'listallinfo':        'database',
+            'listfiles':          'database',
             'lsinfo':             'database',
+            'readcomments':       'object',
+            'readpicture':        'composite',
             'search':             'songs',
             'searchadd':          'nothing',
             'searchaddpl':        'nothing',
             'update':             'item',
             'rescan':             'item',
-            'readcomments':       'object',
             # Mounts and neighbors
             'mount':              'nothing',
             'unmount':            'nothing',
@@ -208,20 +233,28 @@ class TestMPDClient(unittest.TestCase):
             'kill':               None,
             'password':           'nothing',
             'ping':               'nothing',
+            'binarylimit':        'nothing',
+            'tagtypes':           'list',
+            'tagtypes disable':   'nothing',
+            'tagtypes enable':    'nothing',
+            'tagtypes clear':     'nothing',
+            'tagtypes all':       'nothing',
             # Partition Commands
             'partition':          'nothing',
             'listpartitions':     'list',
             'newpartition':       'nothing',
+            'delpartition':       'nothing',
+            'moveoutput':         'nothing',
             # Audio Output Commands
             'disableoutput':      'nothing',
             'enableoutput':       'nothing',
             'toggleoutput':       'nothing',
             'outputs':            'outputs',
+            'outputset':          'nothing',
             # Reflection Commands
             'config':             'object',
             'commands':           'list',
             'notcommands':        'list',
-            'tagtypes':           'list',
             'urlhandlers':        'list',
             'decoders':           'plugins',
             # Client to Client
@@ -489,6 +522,21 @@ class TestMPDClient(unittest.TestCase):
         res = self.client.albumart('muse/Raised Fist/2002-Dedication/', 0)
         self.assertEqual(res.get('data'), data)
 
+    def test_command_list(self):
+        self.MPDWillReturn('updating_db: 42\n',
+                           f'{musicpd.NEXT}\n',
+                           'repeat: 0\n',
+                           'random: 0\n',
+                           f'{musicpd.NEXT}\n',
+                           f'{musicpd.NEXT}\n',
+                           'OK\n')
+        self.client.command_list_ok_begin()
+        self.client.update()
+        self.client.status()
+        self.client.repeat(1)
+        self.client.command_list_end()
+        self.assertMPDReceived('command_list_end\n')
+
 
 if __name__ == '__main__':
     unittest.main()