def test_total_length(self): test_playlist = Playlist("chalgata") song1 = Song("s", "s", "s", 1, 2, 3) song2 = Song("a", "s", "s", 1, 3, 4) test_playlist.add_song(song1) test_playlist.add_song(song2) self.assertEqual(test_playlist.songs, [song1, song2]) self.assertEqual(test_playlist.total_length(), 5)
def test_remove_songs(self): test_playlist = Playlist("chalgata") song1 = Song("s", "s", "s", 1, 2, 3) test_playlist.add_song(song1) self.assertEqual(test_playlist.songs, [song1]) test_playlist.remove_song(song1) self.assertEqual(test_playlist.songs, [])
def generate_palylist(self): folder_name = (re.findall('\w+', self.path)).pop() playlist = Playlist(folder_name, True, True) files = self.get_music_files() for f in files: file_path = '{}/{}'.format(self.path, f) tags = ID3(file_path) audio = MP3(file_path) lenght = '{:0.2f}'.format(audio.info.length / 60) song = Song(tags['TIT2'], tags['TCOM'], tags['TALB'], '3.35') playlist.songs.append(song) return playlist
def test_playlist_init(self): test_playlist = Playlist("Chalgata!") self.assertEqual(test_playlist.name, "Chalgata!") self.assertEqual(test_playlist.songs, [])
def test_show_artists(self): test_playlist = Playlist("chalgata") song1 = Song("s", "s", "s", 1, 2, 3) test_playlist.add_song(song1) self.assertEqual(test_playlist.show_artists(), ["s"])
def test_bitrate(self): test_playlist = Playlist("chalgata") song1 = Song("s", "s", "s", 1, 2, 3) test_playlist.add_song(song1) test_playlist.remove_bad_quality(4) self.assertEqual(test_playlist.songs, [])
def test_disrated(self): test_playlist = Playlist("chalgata") song1 = Song("s", "s", "s", 1, 2, 3) test_playlist.add_song(song1) test_playlist.remove_disrated(2) self.assertEqual(test_playlist.songs, [])
def setUp(self): self.pl = Playlist("My_list", repeat=True, shuffle=True) self.pl.add_song(Song("Odin1", "Manomar", "The sons of Odin_01", "2:44")) self.pl.add_song(Song("Odin2", "Manomar", "The sons of Odin_02", "2:44")) self.pl.add_song(Song("Odin3", "Manomar", "The sons of Odin_03", "2:44")) self.pl.add_song(Song("Odin4", "Manomar", "The sons of Odin_04", "2:44"))
class playlistTest(unittest.TestCase): def setUp(self): self.pl = Playlist("My_list", repeat=True, shuffle=True) self.pl.add_song(Song("Odin1", "Manomar", "The sons of Odin_01", "2:44")) self.pl.add_song(Song("Odin2", "Manomar", "The sons of Odin_02", "2:44")) self.pl.add_song(Song("Odin3", "Manomar", "The sons of Odin_03", "2:44")) self.pl.add_song(Song("Odin4", "Manomar", "The sons of Odin_04", "2:44")) def test_total_lenght(self): self.assertEqual(self.pl.total_lenght(), '00:10:56') def test_add_songs(self): songs = [Song("Odin1", "Mar", "The sons of Odin_01", "2:78"), Song("Odin2", "Manomar", "The", "1:2:44"), Song("Odin3", "Manomar", "The sons ", "2:44"), Song("Odin90", "Manomar", "Theof Odi n_04", "2:44")] self.pl.add_songs(songs) self.pl.pprint_playlist() def test_artists(self): self.assertEqual(self.pl.artists(), "ghujoi,biiuo, joipp, hiii") def test_pprint_playlist(self): self.pl.pprint_playlist() def test_save(self): self.assertTrue(self.pl.save())