X-Git-Url: http://git.kaliko.me/?p=python-musicpd.git;a=blobdiff_plain;f=test.py;h=70ac203ccdfdcd69696bbe9607b9fb2283937a54;hp=7f1890fe9f325ec1b4c5c450ea8048d8b5727cca;hb=c45cc084b0543af12fe815f6dee14303eac20e2a;hpb=691958e03673c01f8c4ea2f18cb9e8fe3ca3fab3 diff --git a/test.py b/test.py index 7f1890f..70ac203 100755 --- a/test.py +++ b/test.py @@ -551,6 +551,13 @@ class TestMPDClient(unittest.TestCase): self.client.command_list_end() self.assertMPDReceived('command_list_end\n') + def test_two_word_commands(self): + self.MPDWillReturn('OK\n') + self.client.tagtypes_clear() + self.assertMPDReceived('tagtypes clear\n') + self.MPDWillReturn('OK\n') + with self.assertRaises(AttributeError): + self.client.foo_bar() class testConnection(unittest.TestCase): @@ -582,5 +589,18 @@ class testConnection(unittest.TestCase): sock.connect.assert_called_with('/run/mpd/socket') +class testException(unittest.TestCase): + + def test_CommandError_on_newline(self): + os.environ['MPD_HOST'] = '/run/mpd/socket' + with mock.patch('musicpd.socket') as socket_mock: + sock = mock.MagicMock(name='socket') + socket_mock.socket.return_value = sock + cli = musicpd.MPDClient() + cli.connect() + with self.assertRaises(musicpd.CommandError): + cli.find('(album == "foo\nbar")') + + if __name__ == '__main__': unittest.main()