当前位置: 首页>>代码示例>>Python>>正文


Python Playlist.remove_bad_quality方法代码示例

本文整理汇总了Python中playlist.Playlist.remove_bad_quality方法的典型用法代码示例。如果您正苦于以下问题:Python Playlist.remove_bad_quality方法的具体用法?Python Playlist.remove_bad_quality怎么用?Python Playlist.remove_bad_quality使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在playlist.Playlist的用法示例。


在下文中一共展示了Playlist.remove_bad_quality方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Tests

# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import remove_bad_quality [as 别名]
class Tests(unittest.TestCase):
	def setUp(self):
		self.playlist = Playlist('PlayList')
		self.song = Song('title', 'artist', 'album', 5, 93, 256)

	def test_song_init(self):
		self.assertEqual(self.playlist.name, 'PlayList')

	def test_add_song(self):
		self.playlist.add_song(self.song)
		self.assertEqual(self.playlist.playlist[0],self.song)

	def test_remove_song(self):
		self.playlist.remove_song('title')
		self.assertEqual(len(self.playlist.playlist), 0)

	def test_total_length(self):
		song1 = Song('title1', 'artist1', 'album1', 5, 93, 256)
		song2 = Song('title2', 'artist2', 'album2', 3, 87, 126)
		self.playlist.add_song(song1)
		self.playlist.add_song(song2)
		self.assertEqual(self.playlist.total_length(),180)

	def test_remove_disrated(self):
		song1 = Song('title1', 'artist1', 'album1', 5, 93, 256)
		song2 = Song('title2', 'artist2', 'album2', 3, 87, 126)
		song3 = Song('title3', 'artist3', 'album3', 5, 88, 148)
		self.playlist.add_song(song1)
		self.playlist.add_song(song2)
		self.playlist.add_song(song3)
		self.playlist.remove_disrated(3)
		self.assertEqual(self.playlist.total_length(),181)

	def test_remove_bad_quality(self):
		song1 = Song('title1', 'artist1', 'album1', 5, 93, 256)
		song2 = Song('title2', 'artist2', 'album2', 3, 87, 126)
		song3 = Song('title3', 'artist3', 'album3', 5, 88, 148)
		self.playlist.add_song(song1)
		self.playlist.add_song(song2)
		self.playlist.add_song(song3)
		self.playlist.remove_bad_quality(126)
		self.assertEqual(self.playlist.total_length(),181)

	def test_show_artists(self):
		song1 = Song('title1', 'artist1', 'album1', 5, 93, 256)
		song2 = Song('title2', 'artist2', 'album2', 3, 87, 126)
		song3 = Song('title3', 'artist2', 'album3', 5, 88, 148)
		self.playlist.add_song(song1)
		self.playlist.add_song(song2)
		self.playlist.add_song(song3)
		artists = ['artist1','artist2']
		self.assertEqual(artists,self.playlist.show_artists())

	def test_str(self):
		song1 = Song('title1', 'artist1', 'album1', 5, 93, 256)
		song2 = Song('title2', 'artist2', 'album2', 3, 87, 126)
		self.playlist.add_song(song1)
		self.playlist.add_song(song2)
		songs = 'artist1 title1 - 1:33\nartist2 title2 - 1:27\n'
		self.assertEqual(songs,self.playlist.str())
开发者ID:kalpak44,项目名称:Program101,代码行数:62,代码来源:test_playlist.py

示例2: test_remove_bad_quality

# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import remove_bad_quality [as 别名]
 def test_remove_bad_quality(self):
     new_playlist = Playlist("my_playlist")
     enter_song = Song("Enter sandman", "Metallica", "Balck album", 2, 300, 192000)
     harvester_song = Song("Harvester of sorrow", "Metallica", "...And justice for all", 3, 300, 150000)
     new_playlist.songs.append(harvester_song)
     new_playlist.songs.append(enter_song)
     new_playlist.remove_bad_quality()
     self.assertEqual(len(new_playlist.songs), 1)
开发者ID:mihail-nikolov,项目名称:hackBG,代码行数:10,代码来源:test_playlist.py

示例3: __init__

# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import remove_bad_quality [as 别名]
class MusicPlayer:

    def __init__(self):
        self.playlist = Playlist("Playlist")

    def print_messages(self):
        print("Hello, welcome to the music player interface!\n")
        print("Load your playlist!")

    def get_input(self):
        command = input("Enter command> ")
        command = command.split(" ")
        return command

    def interface(self):
        command = self.get_input()
        while command[0] != "exit":
            if command[0] == "load_dir":
                folder = MusicCrawler(command[1])
                self.playlist = folder.generate_playlist()
                command = self.get_input()
            elif command[0] == "remove_song":
                self.playlist.remove_song(command[1])
                print("Songs removed.")
                command = self.get_input()
            elif command[0] == "total_length":
                print(self.playlist.total_length())
                command = self.get_input()
            elif command[0] == "remove_disrated":
                self.playlist.remove_disrated(command[1])
                command = self.get_input()
            elif command[0] == "remove_song":
                self.playlist.remove_song(command[1])
                command = self.get_input()
            elif command[0] == "remove_bad_quality":
                self.playlist.remove_bad_quality()
                print("Songs removed.")
                command = self.get_input()
            elif command[0] == "show_artists":
                print(self.playlist.show_artists())
                command = self.get_input()
            elif command[0] == "remove_song":
                self.playlist.remove_song(command[1])
                command = self.get_input()
            elif command[0] == "save":
                self.playlist.save(command[1])
                command = self.get_input()
            elif command[0] == "load":
                self.playlist = self.playlist.load(command[1])
                command = self.get_input()
            elif command[0] == "print_playlist":
                print(self.playlist)
                command = self.get_input()
            else:
                print("Bad input!")
                command = self.get_input()
        else:
            print("Goodbye!")
开发者ID:stoilov,项目名称:Programming101,代码行数:60,代码来源:musicplayer.py

示例4: PlaylistTest

# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import remove_bad_quality [as 别名]
class PlaylistTest(unittest.TestCase):

    def setUp(self):
        self.song1 = Song("Title1", "Artist1", "Album1", 2, 192, 128)
        self.song2 = Song("Title2", "Artist2", "Album2", 2, 183, 1024)
        self.playlist = Playlist("PlaylistTitle")
        self.playlist.songs.append(self.song1)
        self.playlist.songs.append(self.song2)

    def test_init(self):
        self.assertEqual(self.playlist.name, "PlaylistTitle")
        self.assertEqual(self.playlist.songs, [self.song1, self.song2])

    def test_add_song(self):
        self.song3 = Song("Title3", "Artist3", "Album3", 2, 201, 128)
        self.playlist.add_song(self.song3)
        self.assertEqual(
            self.playlist.songs, [self.song1, self.song2, self.song3])

    def test_remove_song(self):
        self.song3 = Song("Title3", "Artist3", "Album3", 4, 194, 1024)
        self.playlist.add_song(self.song3)
        self.playlist.remove_song("Title3")
        self.assertEqual(self.playlist.songs, [self.song1, self.song2])

    def test_total_length(self):
        self.assertEqual(self.playlist.total_length(), 375)

    def test_remove_disrated(self):
        self.song3 = Song("Title3", "Artist3", "Album3", 4, 206, 1024)
        self.playlist.add_song(self.song3)
        self.playlist.remove_disrated(3)
        self.assertEqual(self.playlist.songs, [self.song3])

    def test_remove_bad_quality(self):
        self.song3 = Song("Title3", "Artist3", "Album3", 4, 206, 1024)
        self.playlist.add_song(self.song3)
        self.playlist.remove_bad_quality(1000)
        self.assertEqual(self.playlist.songs, [self.song2, self.song3])

    def test_show_artists(self):
        self.song3 = Song("Title3", "Artist2", "Album3", 4, 206, 1024)
        self.playlist.add_song(self.song3)
        self.assertEqual(self.playlist.show_artists(), ["Artist1", "Artist2"])

    # def test_str(self):
    #     test = self.playlist.str()
    #     self.assertEqual(
    #         "Artist1 Title1 - 3:12\nArtist2 Title2 - 3:03\n", test)

    def test_save(self):
        self.playlist.save("pesho.txt")

    def test_load(self):
        self.playlist.load("pesho.txt")
开发者ID:kal0ian,项目名称:HackBulgaria,代码行数:57,代码来源:playlist-test.py

示例5: TestPlaylist

# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import remove_bad_quality [as 别名]
class TestPlaylist(unittest.TestCase):

    def setUp(self):
        self.playlist = Playlist("name")
        self.song = Song("title", "artist", "album", 4, 200, 256)
        self.beat = Song("beat", "dlg", "hrdlg", 2, 150, 20)

    def test_init_playlist(self):
        self.assertEqual(self.playlist.name, "name")
        self.assertEqual(len(self.playlist.songs), 0)

    def test_add_song(self):
        self.playlist.add_song(self.song)
        self.assertEqual(self.playlist.songs[0], self.song)

    def test_remove_song(self):
        self.playlist.add_song(self.song)
        self.playlist.add_song(self.song)
        self.playlist.remove_song("title")
        self.assertEqual(len(self.playlist.songs), 0)

    def test_total_length(self):
        self.playlist.add_song(self.song)
        self.playlist.add_song(self.beat)
        self.assertEqual(self.playlist.total_length(), 350)

    def test_remove_disrated(self):
        self.playlist.add_song(self.song)
        self.playlist.add_song(self.beat)
        self.playlist.remove_disrated(3)
        self.assertEqual(len(self.playlist.songs), 1)
        self.playlist.remove_disrated(5)
        self.assertEqual(len(self.playlist.songs), 0)

    def test_remove_bad_quality(self):
        self.playlist.add_song(self.song)
        self.playlist.add_song(self.beat)
        self.playlist.remove_bad_quality()
        self.assertEqual(len(self.playlist.songs), 1)

    def test_show_artists(self):
        self.playlist.add_song(self.song)
        self.playlist.add_song(self.beat)
        self.playlist.add_song(self.song)
        self.playlist.add_song(self.beat)
        result = set()
        result.add("artist")
        result.add("dlg")
        self.assertEqual(self.playlist.show_artists(), result)

    def test_to_str(self):
        self.playlist.add_song(self.song)
        self.playlist.add_song(self.beat)
        result = "artist title - 3:20\ndlg beat - 2:30\n"
        self.assertEqual(str(self.playlist), result)
开发者ID:svetlio2,项目名称:hackbg,代码行数:57,代码来源:playlist_test.py

示例6: TestPlaylist

# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import remove_bad_quality [as 别名]
class TestPlaylist(unittest.TestCase):

    def setUp(self):
        self.playlist = Playlist('Pro Playlist')
        self.song = Song("BeatBox", "PsychoFrog", "BB 2015", 4, 190, 320)

    def tearDown(self):
        os.remove('test_playlist.txt')

    def test_add_song(self):
        self.playlist.add_song(self.song)
        self.assertIn(self.song, self.playlist.songs)

    def test_remove_song(self):
        self.playlist.add_song(self.song)
        self.playlist.add_song(self.song)
        self.playlist.add_song(self.song)

        self.playlist.remove_song(self.song.title)
        self.assertEqual(self.playlist.songs, [])

    def test_total_length(self):
        self.playlist.add_song(self.song)
        self.playlist.add_song(self.song)

        self.assertEqual(self.song.length + self.song.length, self.playlist.total_length())

    def test_remove_disrated(self):
        self.playlist.add_song(self.song)
        self.playlist.remove_disrated(5)
        self.assertEqual([], self.playlist.songs)

    def test_remove_disrated_with_invalid_rating(self):
        with self.assertRaises(ValueError):
            self.playlist.remove_disrated(-1)

    def test_remove_bad_quality(self):
        self.playlist.add_song(self.song)
        bad_bit_song = Song("d", "R", "A", 4, 40, 256)
        self.playlist.add_song(bad_bit_song)
        self.playlist.remove_bad_quality()

        self.assertEqual([self.song], self.playlist.songs)

    def test_show_artists(self):
        self.playlist.add_song(self.song)
        self.playlist.add_song(self.song)
        self.playlist.add_song(Song("Other Song", "Other Artist", "Album", 5, 180, 320))

        self.assertEqual(["PsychoFrog", "Other Artist"], self.playlist.show_artists())

    def test_saving(self):
        self.playlist.save('test_playlist.txt')
开发者ID:betrakiss,项目名称:HackBulgaria,代码行数:55,代码来源:playlist_test.py

示例7: TestPlaylist

# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import remove_bad_quality [as 别名]
class TestPlaylist(unittest.TestCase):
    def setUp(self):
        self.plist = Playlist("plist out")
        self.ruby = Song(
            "Ruby",
            "Kaiser Chiefs",
            "Unknown",
            1,
            300,
            320

        )
        self.rubyDNB = Song(
            "Ruby DNB",
            "Kaiser Chiefs",
            "Unknown",
            4,
            300,
            120

        )
        self.plist.add_song(self.ruby)
        self.plist.add_song(self.ruby)
        self.plist.add_song(self.rubyDNB)

    def test_init(self):
        self.assertEqual(self.plist.name, "plist out")

    def test_add_song(self):
        self.assertIn(self.ruby, self.plist.songs)

    def test_remove_song(self):
        self.plist.remove_song("Ruby")
        self.assertNotIn(self.ruby, self.plist.songs)

    def test_total_length(self):
        self.assertEqual(self.plist.total_length(), 900)

    def test_rating_out_of_range(self):
        for item in self.plist.songs:
            self.assertIn(item.rating, [1, 2, 3, 4, 5])

    def test_remove_disrated(self):
        self.plist.remove_disrated(3)
        self.assertIn(self.rubyDNB, self.plist.songs)
        self.assertNotIn(self.ruby, self.plist.songs)

    def test_remove_bad_quality(self):
        self.plist.remove_bad_quality()
        self.assertNotIn(self.rubyDNB, self.plist.songs)

    def test_show_artists(self):
        self.assertEqual(self.plist.show_artists(), ["Kaiser Chiefs"])
开发者ID:stanislavBozhanov,项目名称:HackBulgaria,代码行数:55,代码来源:playlist_test.py

示例8: TestPlaylist

# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import remove_bad_quality [as 别名]
class TestPlaylist(unittest.TestCase):
    def setUp(self):
        self.testPlaylist = Playlist("My Playlist")
        self.testSong = Song("Title", "Artist", "Album", 5, 120, 512)
        self.testSong2 = Song("Title2", "Artist", "Album", 2, 120, 320)
        self.testPlaylist.add_song(self.testSong)

    def test_init(self):
        self.assertEqual(self.testPlaylist.name, "My Playlist")

    def test_add_song(self):
        self.assertEqual(self.testPlaylist.collection, [self.testSong])

    def test_remove_song(self):
        self.testPlaylist.add_song(self.testSong2)
        self.testSong3 = Song("Title2", "Artist", "Album", 1, 120, 320)
        self.testPlaylist.add_song(self.testSong3)
        self.testPlaylist.remove_song("Title2")
        self.assertEqual(self.testPlaylist.collection, [self.testSong])

    def test_total_length(self):
        self.testPlaylist.add_song(self.testSong2)
        result = self.testPlaylist.total_length()
        self.assertEqual(result, 240)

    def test_remove_disrated_with_value_error(self):
        with self.assertRaises(ValueError):
            self.testPlaylist.remove_disrated(6)
        with self.assertRaises(ValueError):
            self.testPlaylist.remove_disrated(0)

    def test_remove_disrated_with_correct_input(self):
        self.testPlaylist.add_song(self.testSong2)
        self.testSong3 = Song("Title2", "Artist", "Album", 1, 120, 320)
        self.testPlaylist.add_song(self.testSong3)
        self.testPlaylist.remove_disrated(3)
        self.assertEqual(self.testPlaylist.collection, [self.testSong])

    def test_remove_bad_quality(self):
        self.testPlaylist.add_song(self.testSong2)
        self.testSong3 = Song("Title2", "Artist", "Album", 1, 120, 192)
        self.testPlaylist.add_song(self.testSong3)
        self.testPlaylist.remove_bad_quality(340)
        self.assertEqual(self.testPlaylist.collection, [self.testSong])

    def test_show_artists(self):
        self.testPlaylist.add_song(self.testSong2)
        self.testSong3 = Song("Title2", "Artist", "Album", 1, 120, 192)
        self.testPlaylist.add_song(self.testSong3)
        result = self.testPlaylist.show_artists()
        self.assertEqual(result, {"Artist"})
开发者ID:kazuohirai,项目名称:HackBulgaria,代码行数:53,代码来源:test_playlist.py

示例9: TestPlaylist

# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import remove_bad_quality [as 别名]
class TestPlaylist(unittest.TestCase):

    def setUp(self):
        self.my_playlist = Playlist("Qki pesni 2011")
        self.song = Song("Title", "Gosho ot pochivka", "Album", 100, 128)
        self.song1 = Song("Title2", "Gosho ot pochivka2", "Album", 200, 256)
        self.song2 = Song("Title3", "Gosho ot pochivka2", "Album", 200, 128)

    def test_init(self):
        self.assertEqual("Qki pesni 2011", self.my_playlist.name)

    def test_add_song(self):
        self.my_playlist.add_song(self.song)
        self.assertIn(self.song, self.my_playlist.playlist)

    def test_remove_song(self):
        self.my_playlist.add_song(self.song)
        self.my_playlist.remove_song("Title")
        self.assertNotIn(self.song, self.my_playlist.playlist)

    def test_total_length(self):
        self.my_playlist.add_song(self.song)
        self.my_playlist.add_song(self.song1)
        self.assertEqual(300, self.my_playlist.total_length())

    def test_remove_disrated(self):
        self.song.rate(2)
        self.my_playlist.add_song(self.song)
        self.song1.rate(4)
        self.my_playlist.add_song(self.song1)
        self.song2.rate(3)
        self.my_playlist.add_song(self.song2)
        self.my_playlist.remove_disrated(3)
        self.assertNotIn(self.song, self.my_playlist.playlist)
        self.assertNotIn(self.song2, self.my_playlist.playlist)

    def test_remove_bad_quality(self):
        self.my_playlist.add_song(self.song)
        self.my_playlist.add_song(self.song1)
        self.my_playlist.remove_bad_quality()
        self.assertNotIn(self.song, self.my_playlist.playlist)

    def test_show_artists(self):
        self.my_playlist.add_song(self.song)
        self.my_playlist.add_song(self.song1)
        song2 = Song("Title5", "Gosho ot pochivka", "Album", 100, 128)
        self.my_playlist.add_song(song2)
        artists = ["Gosho ot pochivka", "Gosho ot pochivka2"]
        self.assertEqual(artists, self.my_playlist.show_artists())
开发者ID:SlaviSotirov,项目名称:HackBulgaria,代码行数:51,代码来源:playlist_test.py

示例10: PlaylistTest

# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import remove_bad_quality [as 别名]
class PlaylistTest(unittest.TestCase):
    def setUp(self):
        self.playlist = Playlist("Indie")
        self.song1 = Song(
            "Shelter", "Years & Years", "EP", 5, 320, 512)
        self.song2 = Song(
            "Shelter2", "Years & Years", "EP2", 5, 200, 64)


    def test_add_song(self):

        self.playlist.add_song(self.song1)
        self.playlist.add_song(self.song2)

        self.assertEqual(self.playlist.songlist[0],self.song1)
        self.assertEqual(self.playlist.songlist[1],self.song2)

    def test_remove_song(self):
        self.playlist.add_song(self.song1)
        song_name="Shelter2"
        self.playlist.remove_song(song_name)
        self.assertNotIn(song_name, self.playlist.songlist)


    def test_total_length(self):
        self.playlist.add_song(self.song1)
        self.playlist.add_song(self.song2)
        self.assertEqual(self.playlist.total_length(),520)


    def test_remove_bad_quality(self):
        self.playlist.add_song(self.song1)
        self.playlist.add_song(self.song2)
        self.playlist.remove_bad_quality()
        self.assertNotIn(self.song2,self.playlist.songlist)

    def test_save_file_with_json_output(self):






    def test_show_artist(self):
        pass


if __name__ == '__main__':
    unittest.main()
开发者ID:modzozo,项目名称:hack101,代码行数:51,代码来源:playlisttest.py

示例11: TestPlaylist

# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import remove_bad_quality [as 别名]
class TestPlaylist(unittest.TestCase):

    def setUp(self):

        self.song1 = Song("Title1", "Artist","Album", 5.0, 4, 320)
        self.song2 = Song("Title2", "Artist","Album", 2.0, 2, 320)
        self.song3 = Song("Title3", "Artist2","Album", 5.0, 4, 128)
        self.my_playlist = Playlist("Playlist")
        self.my_playlist.songs.append(self.song1)
        self.my_playlist.songs.append(self.song2)
        self.my_playlist.songs.append(self.song3)

    def test_init(self):

        self.assertEqual(self.my_playlist.songs, [self.song1, self.song2, self.song3])
        self.assertEqual(self.my_playlist.name, "Playlist")

    def test_add_song(self):

        self.song4 = Song("Title", "Artist","Album", 5.0, 4.22, 320)
        self.my_playlist.add_song(self.song4)
        self.assertEqual(self.my_playlist.songs, [self.song1, self.song2, self.song3, self.song4])

    def test_remove_song(self):

        self.my_playlist.remove_song("Title2")
        self.assertEqual(self.my_playlist.songs, [self.song1, self.song3])

    def test_total_lenght(self):

        self.assertEqual(self.my_playlist.total_lenght(), 10)

    def test_remove_disrated(self):

        self.my_playlist.remove_disrated(3)
        self.assertEqual(self.my_playlist.songs, [self.song1, self.song3])

    def test_remove_bad_quality(self):

        self.my_playlist.remove_bad_quality(320)
        self.assertEqual(self.my_playlist.songs, [self.song1, self.song2])

    def test_show_artists(self):

        self.assertEqual(self.my_playlist.show_artits(), ["Artist", "Artist2"])

    def test_str(self):

        print(self.my_playlist.str()) 
开发者ID:skdls-,项目名称:Python,代码行数:51,代码来源:test_playlist.py

示例12: main

# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import remove_bad_quality [as 别名]
def main():

    #new_songs_arr = []
    print(start_message())
    print(songs_to_add())
    new_playlist = Playlist("my_playlist")
    while True:
        command = split_command_str(input("Enter command>"))

        if the_command(command, "generate"):
            new_crawler = Music_crawler(command[1])
            new_playlist = new_crawler.generate_playlist()
            print(new_playlist.str_func())

        elif the_command(command, "remove_disrated"):
            new_playlist.remove_disrated(int(command[1]))
            print(new_playlist.str_func())

        elif the_command(command, "remove_bad_quality"):
            new_playlist.remove_bad_quality()
            print(new_playlist.str_func())

        elif the_command(command, "remove"):
            new_playlist.remove_song(command[1])
            print(new_playlist.str_func())

        elif the_command(command, "add"):
            for song in songs_arr:
                if command[1] == song.title:
                    new_playlist.add_song(song)
                    break
            print(new_playlist.str_func())

        elif the_command(command, "load"):
            new_playlist.load(command[1])
            print(new_playlist.str_func())

        elif the_command(command, "save"):
            new_playlist.save(command[1])

        elif the_command(command, "finish"):
            print("GoodBye. Thank you for using the player")
            break

        else:
            print(unknown_command())
开发者ID:mihail-nikolov,项目名称:hackBG,代码行数:48,代码来源:music_player.py

示例13: TestPlaylist

# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import remove_bad_quality [as 别名]
class TestPlaylist(unittest.TestCase):
    def setUp(self):
        self.test_playlist = Playlist("Rocking songs")

    def test_init_playlist(self):
        self.assertEqual(self.test_playlist.name, "Rocking songs")

    def test_add_song(self):
        test_song = Song("Take me", "AC DC", "Black in black", 4, 180, 320)
        self.test_playlist.add_song(test_song)
        self.assertIn(test_song, self.test_playlist.playlist)

    def test_remove_song(self):
        test_song = Song("Take me", "AC DC", "Black in black", 4, 180, 320)
        self.test_playlist.delete_song(test_song)
        self.assertNotIn(test_song, self.test_playlist.playlist)

    def test_total_length(self):
        test_song = Song("Take me", "AC DC", "Black in black", 4, 180, 320)
        test_song2 = Song("Fuck me", "Metallica", "Rock it", 4, 100, 256)
        self.test_playlist.add_song(test_song)
        self.test_playlist.add_song(test_song2)
        self.assertEqual(280, self.test_playlist.total_length())

    def test_remove_disrated(self):
        test_song = Song("Take me", "AC DC", "Black in black", 4, 180, 320)
        self.test_playlist.add_song(test_song)
        test_song.rate(5)
        self.test_playlist.remove_disrated(5)
        self.assertNotIn(test_song, self.test_playlist.playlist)

    def test_remove_bad_quality(self):
        test_song = Song("Take me", "AC DC", "Black in black", 4, 180, 64)
        self.test_playlist.add_song(test_song)
        self.assertIsNot(test_song, self.test_playlist.remove_bad_quality())

    def test_show_artists(self):
        test_song = Song("Take me", "AC DC", "Black in black", 4, 180, 64)
        test_song1 = Song("BlaBla", "Metallica", "Black in black", 4, 180, 64)
        test_song2 = Song("Take", "Rihanna", "Black in black", 4, 180, 64)
        test_song3 = Song("me", "AC DC", "Black in black", 4, 180, 64)
        test_song4 = Song("Take me", "AC DC", "Black in black", 4, 180, 64)
        self.test_playlist.add_song(test_song)
        self.test_playlist.add_song(test_song1)
        self.test_playlist.add_song(test_song2)
        self.test_playlist.add_song(test_song3)
        self.test_playlist.add_song(test_song4)
        self.assertListEqual(["AC DC", "Metallica", "Rihanna"], self.test_playlist.show_artists())

    def test_str(self):
        test_song = Song("Take me", "AC DC", "Black in black", 4, 180, 64)
        self.test_playlist.add_song(test_song)
        self.assertEqual("AC DC Take me - 3:00", self.test_playlist.__str__(test_song))
开发者ID:kkashev,项目名称:hackbulgaria,代码行数:55,代码来源:test_playlist_class.py

示例14: TestPlaylist

# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import remove_bad_quality [as 别名]
class TestPlaylist(unittest.TestCase):
    def setUp(self):
        self.playlist = Playlist("test_playlist")
        self.test_song = Song("Highway to Hell", "AC/DC", "Highway to Hell", 5, 208, 128, "sda")
        self.test_song2 = Song("Back in Black", "ACDC", "Back in Black", 4, 200, 256, "sdb")

        self.playlist.add_song(self.test_song)
        self.playlist.add_song(self.test_song2)
        self.playlist.save("sdadada.json")
        #self.playlist.load("sdadada.json")
    def test_init(self):
        self.assertEqual("test_playlist", self.playlist.name)

    def test_playlist_add_song(self):
        self.assertListEqual(self.playlist.songs, [self.test_song, self.test_song2])
        self.assertEqual(self.playlist.totalLength, 408)

    def test_playlist_remove_song(self):
        self.playlist.remove_song(self.test_song.title)
        self.assertListEqual(self.playlist.songs, [self.test_song2])
        self.assertEqual(self.playlist.totalLength, 200)

    def test_playlist_total_length(self):
        self.playlist.remove_song(self.test_song.title)
        self.assertEqual(self.playlist.total_length(), 200)

    def test_playlist_remove_disrated(self):
        self.playlist.remove_disrated(5)
        self.assertListEqual(self.playlist.songs, [self.test_song])
        self.assertEqual(self.playlist.total_length(), 208)

    def test_playlist_remove_bad_quality(self):
        self.playlist.remove_bad_quality()
        self.assertListEqual(self.playlist.songs, [self.test_song2])
        self.assertEqual(self.playlist.total_length(), 200)

    def test_playlist_list_artists(self):
        self.playlist.add_song(self.test_song2)
        artists = self.playlist.list_artists()
        self.assertListEqual(["AC/DC", "ACDC"], artists)
开发者ID:nkgeorgiev,项目名称:HackBulgaria---Programming101---2,代码行数:42,代码来源:playlist_test.py

示例15: SongTest

# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import remove_bad_quality [as 别名]
class SongTest(unittest.TestCase):
    def setUp(self):
        self.song = song.Song("Emerald Sword", "Rhapsody", "Fire", 4, 2400, 192)
        self.song2 = song.Song("Highway To Hell", "AC/DC", "Rough And Tough", 3, 2000, 64)
        self.my_playlist = Playlist("my_playlist")
        self.my_playlist.add_song(self.song)
        self.my_playlist.add_song(self.song2)

    def test_init(self):
        self.assertEqual(self.my_playlist.songs, [self.song, self.song2])
        self.assertEqual(self.my_playlist.name, "my_playlist")

    def test_add(self):
        self.assertEqual([self.song, self.song2], self.my_playlist.songs)

    def test_remove(self):
        self.my_playlist.remove_song(self.song)
        self.assertEqual(self.my_playlist.songs, [self.song2])

    def test_length(self):
        self.assertEqual(self.my_playlist.total_length(), 4400)

    def test_remove_disrated(self):
        self.my_playlist.remove_disrated(3)
        self.assertEqual(self.my_playlist.songs, [self.song])

    def test_remove_bad_quality(self):
        self.my_playlist.remove_bad_quality()
        self.assertEqual(self.my_playlist.songs, [self.song])

    def test_show_artists(self):
        self.assertEqual(self.my_playlist.show_artists(), ["Rhapsody", "AC/DC"])

    def test_str(self):
        self.my_playlist.remove_song(self.song2)
        self.assertEqual(self.my_playlist.str(), ["Rhapsody Emerald Sword 2400"])
开发者ID:georgi-lyubenov,项目名称:HackBulgaria,代码行数:38,代码来源:playlist_test.py


注:本文中的playlist.Playlist.remove_bad_quality方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。