本文整理匯總了Python中Playlist.Playlist.get_first_song方法的典型用法代碼示例。如果您正苦於以下問題:Python Playlist.get_first_song方法的具體用法?Python Playlist.get_first_song怎麽用?Python Playlist.get_first_song使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Playlist.Playlist
的用法示例。
在下文中一共展示了Playlist.get_first_song方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: PlaylistTest
# 需要導入模塊: from Playlist import Playlist [as 別名]
# 或者: from Playlist.Playlist import get_first_song [as 別名]
class PlaylistTest(unittest.TestCase):
def setUp(self):
self.playlist = Playlist("MyPlaylist")
self.song1 = Song("TestTitle", "TestArtist",
"TestAlbum", 3, 200, 128, "")
self.playlist.add_song(self.song1)
def test_init(self):
self.assertEqual(self.playlist.name, "MyPlaylist")
def test_get_all_songs(self):
self.assertEqual(self.playlist.get_all_songs(), [self.song1])
def test_get_first_song(self):
self.assertEqual(self.playlist.get_first_song(), self.song1)
def test_add_song(self):
self.song2 = Song("It's My Life", "Bon Jovi",
"Unknown Album", 5, 200, 192, "")
self.playlist.add_song(self.song2)
self.assertEqual(
[self.song1, self.song2], self.playlist.get_all_songs())
def test_remove_song(self):
with mock.patch('builtins.input', return_value=1):
self.assertEqual(
self.playlist.get_first_song().title, 'TestTitle')
def test_rate_songs(self):
with mock.patch('builtins.input', return_value=3):
self.assertEqual(
self.playlist.get_first_song().rating, 3)
def test_remove_disrated(self):
with mock.patch('builtins.input', return_value=4):
self.assertEqual(self.playlist.get_all_songs(), [self.song1])