Exemple #1
0
class PlaylistTests(unittest.TestCase):
    def setUp(self):
        self.song1 = Song(
            title="Bullet with Butterfly Wings",
            artist="Smashing Pumpkins",
            time='00:04:17'
        )
        self.song2 = Song(
            title="Song 2",
            artist="Blur",
            time="00:02:01"
        )
        self.song3 = Song(
            title="Creep",
            artist="Radiohead",
            time="00:03:58"
        )
        self.playlist = Playlist(
            [self.song1, self.song2, self.song3]
        )

    def test_playlist_length(self):
        self.assertEqual(len(self.playlist), 3)

    def test_play_time(self):
        self.assertEqual(self.playlist.play_time, 616)

    def test_play_next_song(self):
        self.playlist.play_next_song()
        self.assertLess(self.playlist.play_time, 616)

    def test_play_next_song_when_empty(self):
        playlist2 = Playlist()
        with self.assertRaises(IndexError):
            playlist2.play_next_song()
    def test_init_playlist(self):
        with self.subTest("test init"):
            Playlist(name="Test_Playlist")

        with self.subTest("test init"):
            Playlist(name="Test_Playlist", repeat=True)

        with self.subTest("test init"):
            Playlist(name="Test_Playlist", shuffle=True)

        with self.subTest("test init"):
            Playlist(name="Test_Playlist", repeat=True, shuffle=True)
Exemple #3
0
 def setUp(self):
     self.song1 = Song(
         title="Bullet with Butterfly Wings",
         artist="Smashing Pumpkins",
         time='00:04:17'
     )
     self.song2 = Song(
         title="Song 2",
         artist="Blur",
         time="00:02:01"
     )
     self.song3 = Song(
         title="Creep",
         artist="Radiohead",
         time="00:03:58"
     )
     self.playlist = Playlist(
         [self.song1, self.song2, self.song3]
     )
    def setUp(self):
        self.one = Song("bbb", "aaa", "ccc", "3:36")
        self.two = Song("ddd", "aaa", "eee", "4:20")
        self.three = Song("eee", "aaa", "ccc", "12:28")
        self.four = Song("nnn", "mmm", "ooo", "6:32")
        self.five = Song("sss", "ppp", "rrr", "1:20:03")
        self.six = Song("yyy", "xxx", "zzz", "2:32:15")

        self.playlist_one = Playlist(name="First")
        self.playlist_two = Playlist(name="First", repeat=True)
        self.playlist_three = Playlist(name="First", shuffle=True)
        self.playlist_four = Playlist(name="First", repeat=True, shuffle=True)

        self.list_of_songs = [
            self.one, self.two, self.three, self.four, self.five, self.six
        ]
Exemple #5
0
    def __init__(self):
        # APPLICATION VARIABLES
        self._volume = 100
        self._cur_time = 0
        self._max_time = 0
        self._repeat = False

        # PLAYLIST
        self.playlist = Playlist()

        # GUI
        self.qapp = QApplication([])
        self.mainwindow = MainWindow(self)

        # MUSIC PLAYER
        self.player = MusicPlayer(self)
from music import Playlist

if __name__ == '__main__':

  arvoreMusical = Playlist('Lonely', 2004, 'Trouble', 1)
  m1 = Playlist('Batom cereja', 2021, 'Aqui e agora', 2)
  m2 = Playlist('Foi pá pum', 2020, 'Debaixo do meu telhado', 3)
  m3 = Playlist('Laços de familia', 2004, 'Alma gêmea', 4)

  arvoreMusical.inserir(m1)
  arvoreMusical.inserir(m2)
  arvoreMusical.inserir(m3)

  arvoreMusical.display()

  arvoreMusical.em_ordem(arvoreMusical)

  print()

  # def imprimeMenu():
  #   print(f'''
  #                       Music

  #       |  [1]    Cadastrar Nova Playlist     |
  #       |  [2]     Acrescentar Música         |
  #       |  [3]     Buscar Música por ID       |
  #       |  [4]   Exibir Maior e Menor Idade   |
  #       |  [5]   Ordernar Surfistas Por Nome  |
  #       |  [6]   Exibir Surfistas Cadastrados |
  #       |  [7] Mostrar Quantidade de Surfitas |
  #       |  [8]       Remover um Surfista      |
Exemple #7
0
 def test_play_next_song_when_empty(self):
     playlist2 = Playlist()
     with self.assertRaises(IndexError):
         playlist2.play_next_song()
Exemple #8
0
def main():
    p = Playlist(name='za ceniteli')

    p.add_songs([
        Song(title='Domination',
             artist='Pantera',
             album='Cowboys From Hell',
             length='05:04'),
        Song(title='This Love',
             artist='Pantera',
             album='Vulgar display of power',
             length='04:54'),
        Song(title='Walk',
             artist='Pantera',
             album='Vulgar display of power',
             length='03:54'),
        Song(title='Momicheto',
             artist='Hipodil',
             album='Nadurveni vuglishta',
             length='03:09')
    ])

    p.pprint_playlist()
    p.save()

    print('*' * 50)

    p = Playlist.load('za-ceniteli.json')

    p.add_songs([
        Song(title='Vurtianalen SEX',
             artist='Hipodil',
             album='Nadurveni vuglishta',
             length='04:04'),
        Song(title='Kolio Piqndeto',
             artist='Obraten Efekt',
             album='Efekten Obrat',
             length='03:31'),
        Song(title='Polet',
             artist='Obraten Efekt',
             album='Vervaite ni',
             length='03:50'),
        Song(title='Choki',
             artist='Obraten Efekt',
             album='Vervaite ni',
             length='04:09')
    ])

    p.pprint_playlist()
    p.save()
class PlaylistTests(unittest.TestCase):
    def setUp(self):
        self.one = Song("bbb", "aaa", "ccc", "3:36")
        self.two = Song("ddd", "aaa", "eee", "4:20")
        self.three = Song("eee", "aaa", "ccc", "12:28")
        self.four = Song("nnn", "mmm", "ooo", "6:32")
        self.five = Song("sss", "ppp", "rrr", "1:20:03")
        self.six = Song("yyy", "xxx", "zzz", "2:32:15")

        self.playlist_one = Playlist(name="First")
        self.playlist_two = Playlist(name="First", repeat=True)
        self.playlist_three = Playlist(name="First", shuffle=True)
        self.playlist_four = Playlist(name="First", repeat=True, shuffle=True)

        self.list_of_songs = [
            self.one, self.two, self.three, self.four, self.five, self.six
        ]

    def test_init_playlist(self):
        with self.subTest("test init"):
            Playlist(name="Test_Playlist")

        with self.subTest("test init"):
            Playlist(name="Test_Playlist", repeat=True)

        with self.subTest("test init"):
            Playlist(name="Test_Playlist", shuffle=True)

        with self.subTest("test init"):
            Playlist(name="Test_Playlist", repeat=True, shuffle=True)

    def test_add_song_to_playlist(self):
        expected = [self.one]
        self.playlist_one.add_song(self.one)
        result = self.playlist_one.songs
        self.assertEqual(result, expected)

    def test_add_songs_to_playlist(self):
        expected = [
            self.one, self.two, self.three, self.four, self.five, self.six
        ]
        self.playlist_one.add_songs(self.list_of_songs)
        result = self.playlist_one.songs
        self.assertEqual(result, expected)

    def test_remove_song_from_playlist(self):
        expected = [self.one, self.three, self.four, self.five, self.six]
        self.playlist_one.add_songs(self.list_of_songs)
        self.playlist_one.remove_song(self.two)
        result = self.playlist_one.songs
        self.assertEqual(result, expected)

    def test_total_length_of_playlist(self):
        expected = "4:19:14"
        self.playlist_one.add_songs(self.list_of_songs)
        result = self.playlist_one.total_length()
        self.assertEqual(result, expected)

    def test_artists_of_playlist(self):
        expected = {'aaa': 3, 'mmm': 1, 'ppp': 1, 'xxx': 1}
        self.playlist_one.add_songs(self.list_of_songs)
        result = self.playlist_one.artists()
        self.assertDictEqual(result, expected)

    def test_next_song_of_playlist(self):
        with self.subTest("next song without shuffle and repeat"):
            expected = [
                self.one, self.two, self.three, self.four, self.five, self.six
            ]
            self.playlist_one.add_songs(self.list_of_songs)
            result = []
            for i in range(len(expected)):
                result.append(self.playlist_one.next_song())
            self.assertListEqual(result, expected)

        with self.subTest("next song with repeat without shuffle"):
            expected = [
                self.one, self.two, self.three, self.four, self.five, self.six,
                self.one, self.two
            ]
            self.playlist_two.add_songs(self.list_of_songs)
            result = []
            for i in range(len(expected)):
                result.append(self.playlist_two.next_song())
            self.assertListEqual(result, expected)

        with self.subTest("next song with shuffle without repeat"):
            expected = [
                self.one, self.two, self.three, self.four, self.five, self.six
            ]
            self.playlist_three.add_songs(self.list_of_songs)
            result = []
            for i in range(len(expected)):
                result.append(self.playlist_three.next_song())
            self.assertTrue(
                len(result) == len(expected)
                and all([result.count(i) == expected.count(i)
                         for i in result]))

        with self.subTest("HOW TO: next song with shuffle with repeat"):
            expected = self.playlist_four.played
            self.playlist_four.add_songs(self.list_of_songs)
            result = []
            for i in range(len(expected)):
                result.append(self.playlist_four.next_song())
            self.assertListEqual(result, expected)