#!/usr/bin/env python3
-# -*- coding: utf-8 -*-
+# coding: utf-8
+# SPDX-FileCopyrightText: 2012-2021 kaliko <kaliko@azylum.org>
+# SPDX-License-Identifier: LGPL-3.0-or-later
# pylint: disable=missing-docstring
"""
Test suite highly borrowed^Wsteal from python-mpd2 [0] project.
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"))
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()