Skip to content

Commit

Permalink
Add missing lines, so we can read the code better
Browse files Browse the repository at this point in the history
  • Loading branch information
multani committed Dec 11, 2012
1 parent 3ca8ea7 commit 56e9bc4
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ class TestMPDClient(unittest.TestCase):
@classmethod
def setUpClass(self):
self.client = createMpdClient()

@classmethod
def tearDownClass(self):
self.client.disconnect()

def test_metaclass_commands(self):
# just some random functions
self.assertTrue(hasattr(self.client, "commands"))
Expand All @@ -78,13 +80,17 @@ def test_metaclass_commands(self):
self.assertTrue(hasattr(self.client, "close"))
self.assertTrue(hasattr(self.client, "fetch_close"))
self.assertTrue(hasattr(self.client, "send_close"))

def test_fetch_nothing(self):
self.assertIsNone(self.client.ping())
self.assertIsNone(self.client.clearerror())

def test_fetch_list(self):
self.assertIsInstance(self.client.list("album"), list)

def test_fetch_item(self):
self.assertIsNotNone(self.client.update())

def test_fetch_object(self):
status = self.client.status()
stats = self.client.stats()
Expand All @@ -95,21 +101,25 @@ def test_fetch_object(self):
self.assertIsInstance(stats, dict)
self.assertIn("artists", stats)
self.assertIn("uptime", stats)

def test_fetch_songs(self):
playlist = self.client.playlistinfo()
self.assertTrue(type(playlist) is list)
if len(playlist) > 0:
self.assertIsInstance(playlist[0], dict)

def test_send_and_fetch(self):
self.client.send_status()
self.client.fetch_status()

def test_iterating(self):
self.client.iterate = True
playlist = self.client.playlistinfo()
self.assertIsInstance(playlist, types.GeneratorType)
for song in playlist:
self.assertIsInstance(song, dict)
self.client.iterate = False

def test_idle(self):
idleclient = createMpdClient()
# clean event mask
Expand All @@ -119,6 +129,7 @@ def test_idle(self):
self.client.update()
event = idleclient.fetch_idle()
self.assertEqual(event, ['update'])

def test_add_and_remove_command(self):
self.client.add_command("awesome command", mpd.MPDClient._fetch_nothing)
self.assertTrue(hasattr(self.client, "awesome_command"))
Expand Down

0 comments on commit 56e9bc4

Please sign in to comment.