Esempio n. 1
0
 def test_play_after_pause_resumes_same_track(self, basic_mock):
     playlist = sound.playlist.Playlist("../../test_data/playlist_single")
     threaded_play(playlist, basic_mock)
     playlist.pause()
     time.sleep(0.01)  # Bodge to make sure fully escaped last play
     playlist.play()
     basic_mock.assert_called_once()
Esempio n. 2
0
 def test_play_after_pause_plays_all_tracks(self, basic_mock):
     playlist = sound.playlist.Playlist("../../test_data/playlist_multiple")
     threaded_play(playlist, basic_mock)
     playlist.pause()
     time.sleep(0.01)  # Bodge to make sure fully escaped last play
     playlist.play()
     time.sleep(0.01)  # Bodge to make sure fully escaped last play
     self.assertEqual(basic_mock.call_count, 5)
Esempio n. 3
0
 def test_stop_resets_track_index(self, basic_mock):
     playlist = sound.playlist.Playlist("../../test_data/playlist_multiple")
     threaded_play(playlist, basic_mock)
     time.sleep(0.02)  # Bodge to make sure track_index gets off 0
     playlist.stop()
     time.sleep(0.01)  # Bodge to make sure fully escaped last play
     basic_mock.reset_mock()
     playlist.play()
     self.assertEqual(basic_mock.call_count, 5)
Esempio n. 4
0
 def test_playlist_checks_to_see_if_track_is_valid(self, basic_mock):
     playlist = sound.playlist.Playlist("../../test_data/playlist_single")
     playlist.play()
     basic_mock.verify_sound_data.assert_called_with({
         "type":
         "basic",
         "track":
         "sound/tracks/song.mp3"
     })
Esempio n. 5
0
 def test_playlist_randomises_order_of_tracks(self, basic_mock):
     different = False
     for _ in range(5):
         playlist = sound.playlist.Playlist(
             "../../test_data/playlist_multiple")
         playlist.play()
         first_calls = basic_mock.call_args
         basic_mock.reset_mock()
         playlist = sound.playlist.Playlist(
             "../../test_data/playlist_multiple")
         playlist.play()
         different_iter = False
         for first, second in zip(first_calls, basic_mock.call_args):
             if first != second:
                 different_iter = True
         if different_iter:
             different = True
     self.assertTrue(different)
Esempio n. 6
0
 def test_play_plays_track_in_playlist_with_chunksize(self, basic_mock):
     playlist = sound.playlist.Playlist("basic")
     chunk_size = 10
     playlist.play(chunk_size)
     basic_mock.return_value.play.assert_called_with(chunk_size)