tests: Make sure mpd tests wait for core when changing state.

This commit is contained in:
Thomas Adamcik 2015-09-16 23:38:15 +02:00
parent a09970106a
commit c1d21bd6c9
3 changed files with 21 additions and 15 deletions

View File

@ -248,7 +248,7 @@ class PlaybackControlHandlerTest(protocol.BaseTestCase):
self.assertEqual(self.core.playback.current_track.get(), None)
self.core.playback.play()
self.core.playback.next()
self.core.playback.stop()
self.core.playback.stop().get()
self.assertNotEqual(self.core.playback.current_track.get(), None)
self.send_request('play "-1"')
@ -266,6 +266,7 @@ class PlaybackControlHandlerTest(protocol.BaseTestCase):
self.assertInResponse('OK')
def test_play_minus_is_ignored_if_playing(self):
self.core.playback.play().get()
self.core.playback.seek(30000)
self.assertGreaterEqual(
self.core.playback.time_position.get(), 30000)
@ -278,6 +279,7 @@ class PlaybackControlHandlerTest(protocol.BaseTestCase):
self.assertInResponse('OK')
def test_play_minus_one_resumes_if_paused(self):
self.core.playback.play().get()
self.core.playback.seek(30000)
self.assertGreaterEqual(
self.core.playback.time_position.get(), 30000)
@ -312,8 +314,8 @@ class PlaybackControlHandlerTest(protocol.BaseTestCase):
def test_playid_minus_1_plays_current_track_if_current_track_is_set(self):
self.assertEqual(self.core.playback.current_track.get(), None)
self.core.playback.play()
self.core.playback.next()
self.core.playback.play().get()
self.core.playback.next().get()
self.core.playback.stop()
self.assertNotEqual(None, self.core.playback.current_track.get())
@ -332,6 +334,7 @@ class PlaybackControlHandlerTest(protocol.BaseTestCase):
self.assertInResponse('OK')
def test_playid_minus_is_ignored_if_playing(self):
self.core.playback.play().get()
self.core.playback.seek(30000)
self.assertGreaterEqual(
self.core.playback.time_position.get(), 30000)
@ -344,6 +347,7 @@ class PlaybackControlHandlerTest(protocol.BaseTestCase):
self.assertInResponse('OK')
def test_playid_minus_one_resumes_if_paused(self):
self.core.playback.play().get()
self.core.playback.seek(30000)
self.assertGreaterEqual(
self.core.playback.time_position.get(), 30000)
@ -417,7 +421,7 @@ class PlaybackControlHandlerTest(protocol.BaseTestCase):
self.assertInResponse('OK')
def test_seekcur_absolute_value(self):
self.core.playback.play()
self.core.playback.play().get()
self.send_request('seekcur "30"')
@ -425,7 +429,7 @@ class PlaybackControlHandlerTest(protocol.BaseTestCase):
self.assertInResponse('OK')
def test_seekcur_positive_diff(self):
self.core.playback.play()
self.core.playback.play().get()
self.core.playback.seek(10000)
self.assertGreaterEqual(self.core.playback.time_position.get(), 10000)
@ -435,7 +439,7 @@ class PlaybackControlHandlerTest(protocol.BaseTestCase):
self.assertInResponse('OK')
def test_seekcur_negative_diff(self):
self.core.playback.play()
self.core.playback.play().get()
self.core.playback.seek(30000)
self.assertGreaterEqual(self.core.playback.time_position.get(), 30000)

View File

@ -16,7 +16,7 @@ class StatusHandlerTest(protocol.BaseTestCase):
self.backend.library.dummy_library = [track]
self.core.tracklist.add(uris=[track.uri]).get()
self.core.playback.play()
self.core.playback.play().get()
self.send_request('currentsong')
self.assertInResponse('file: dummy:/a')
self.assertInResponse('Time: 0')

View File

@ -11,7 +11,7 @@ from mopidy.models import Track
from mopidy.mpd import dispatcher
from mopidy.mpd.protocol import status
from tests import dummy_backend, dummy_mixer
from tests import dummy_audio, dummy_backend, dummy_mixer
PAUSED = PlaybackState.PAUSED
@ -31,12 +31,14 @@ class StatusHandlerTest(unittest.TestCase):
}
}
self.audio = dummy_audio.create_proxy()
self.mixer = dummy_mixer.create_proxy()
self.backend = dummy_backend.create_proxy()
self.backend = dummy_backend.create_proxy(audio=self.audio)
with deprecation.ignore():
self.core = core.Core.start(
config,
audio=self.audio,
mixer=self.mixer,
backends=[self.backend]).proxy()
@ -154,21 +156,21 @@ class StatusHandlerTest(unittest.TestCase):
def test_status_method_when_playlist_loaded_contains_song(self):
self.set_tracklist(Track(uri='dummy:/a'))
self.core.playback.play()
self.core.playback.play().get()
result = dict(status.status(self.context))
self.assertIn('song', result)
self.assertGreaterEqual(int(result['song']), 0)
def test_status_method_when_playlist_loaded_contains_tlid_as_songid(self):
self.set_tracklist(Track(uri='dummy:/a'))
self.core.playback.play()
self.core.playback.play().get()
result = dict(status.status(self.context))
self.assertIn('songid', result)
self.assertEqual(int(result['songid']), 0)
def test_status_method_when_playing_contains_time_with_no_length(self):
self.set_tracklist(Track(uri='dummy:/a', length=None))
self.core.playback.play()
self.core.playback.play().get()
result = dict(status.status(self.context))
self.assertIn('time', result)
(position, total) = result['time'].split(':')
@ -188,7 +190,7 @@ class StatusHandlerTest(unittest.TestCase):
def test_status_method_when_playing_contains_elapsed(self):
self.set_tracklist(Track(uri='dummy:/a', length=60000))
self.core.playback.play()
self.core.playback.play().get()
self.core.playback.pause()
self.core.playback.seek(59123)
result = dict(status.status(self.context))
@ -197,7 +199,7 @@ class StatusHandlerTest(unittest.TestCase):
def test_status_method_when_starting_playing_contains_elapsed_zero(self):
self.set_tracklist(Track(uri='dummy:/a', length=10000))
self.core.playback.play()
self.core.playback.play().get()
self.core.playback.pause()
result = dict(status.status(self.context))
self.assertIn('elapsed', result)
@ -205,7 +207,7 @@ class StatusHandlerTest(unittest.TestCase):
def test_status_method_when_playing_contains_bitrate(self):
self.set_tracklist(Track(uri='dummy:/a', bitrate=3200))
self.core.playback.play()
self.core.playback.play().get()
result = dict(status.status(self.context))
self.assertIn('bitrate', result)
self.assertEqual(int(result['bitrate']), 3200)