[Pkg-mpd-commits] [python-mpd] 88/262: Support upcomming client to client commands of mpd

Simon McVittie smcv at debian.org
Sun May 22 18:16:29 UTC 2016


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch upstream
in repository python-mpd.

commit 1a468a038695a9966a5d985bfcb7361c96e3d29a
Author: Jörg Thalheim <jthalheim at gmail.com>
Date:   Thu Feb 9 06:39:17 2012 +0100

    Support upcomming client to client commands of mpd
---
 doc/commands.txt |  7 +++++++
 mpd.py           |  9 +++++++++
 test.py          | 15 +++++++++++++++
 3 files changed, 31 insertions(+)

diff --git a/doc/commands.txt b/doc/commands.txt
index d71063f..82e42e3 100644
--- a/doc/commands.txt
+++ b/doc/commands.txt
@@ -97,3 +97,10 @@ notcommands                                -> fetch_list
 tagtypes                                   -> fetch_list
 urlhandlers                                -> fetch_list
 decoders                                   -> fetch_plugins
+
+== Client To Client
+subscribe          <str>                   -> fetch_nothing
+unsubscribe        <str>                   -> fetch_nothing
+channels                                   -> fetch_list
+readmessages                               -> fetch_messages
+sendmessage        <str> <str>             -> fetch_nothing
diff --git a/mpd.py b/mpd.py
index 21eef49..9b219bd 100644
--- a/mpd.py
+++ b/mpd.py
@@ -143,6 +143,12 @@ _commands = {
     "tagtypes":           "_fetch_list",
     "urlhandlers":        "_fetch_list",
     "decoders":           "_fetch_plugins",
+    # Client To Client
+    "subscribe":          "_fetch_nothing",
+    "unsubscribe":        "_fetch_nothing",
+    "channels":           "_fetch_list",
+    "readmessages":       "_fetch_messages",
+    "sendmessage":        "_fetch_nothing",
 }
 
 class MPDClient():
@@ -327,6 +333,9 @@ class MPDClient():
     def _fetch_database(self):
         return self._fetch_objects(["file", "directory", "playlist"])
 
+    def _fetch_messages(self):
+        return self._fetch_objects(["channel"])
+
     def _fetch_outputs(self):
         return self._fetch_objects(["outputid"])
 
diff --git a/test.py b/test.py
index dd32ed8..09a3d7d 100755
--- a/test.py
+++ b/test.py
@@ -76,6 +76,21 @@ class TestMPDClient(unittest.TestCase):
         self.assertFalse(hasattr(self.client, "awesome_command"))
         self.assertFalse(hasattr(self.client, "send_awesome_command"))
         self.assertFalse(hasattr(self.client, "fetch_awesome_command"))
+    def test_client_to_client(self):
+        # client to client is at this time in beta!
+        if not "channels" in self.client.commands():
+            return
+        self.assertIsNone(self.client.subscribe("monty"))
+        channels = self.client.channels()
+        self.assertTrue("monty" in channels)
+
+        self.assertIsNone(self.client.sendmessage("monty", "SPAM"))
+        msg = self.client.readmessages()
+        self.assertEqual(msg, [{"channel":"monty", "message": "SPAM"}])
+
+        self.assertIsNone(self.client.unsubscribe("monty"))
+        channels = self.client.channels()
+        self.assertFalse("monty" in channels)
 
 if __name__ == '__main__':
     unittest.main()

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mpd/python-mpd.git



More information about the Pkg-mpd-commits mailing list