コード例 #1
0
    def test_next_song_returns_next_song(self):
        s1 = Song('One', 'U2', 'Achtung Baby', '4:38')
        s2 = Song('Two', 'U2', 'Epimeno', '7:32')
        p = Playlist('Ala bala')
        p.add_songs([s1, s2])

        self.assertEqual(p.next_song(), s1)
        self.assertEqual(p.next_song(), s2)
コード例 #2
0
    def test_playlist_total_length(self):
        s1 = Song('One', 'U2', 'Achtung Baby', '4:38')
        s2 = Song('Warriors of the World', 'Manowar', 'Manowar album', '3:10')
        p = Playlist('random songs')

        p.add_songs([s1,s2])
        result = p.total_length()

        self.assertEqual(result , '7:48')
コード例 #3
0
    def test_show_artists_displays_correctly(self):
        s1 = Song('One', 'U2', 'Achtung Baby', '4:38')
        s2 = Song('Two', 'U2', 'Epimeno', '7:32')
        s3 = Song('Three', 'U2', 'Achtung Baby', '3:15')
        s4 = Song('Warriors of the World', 'Manowar', 'Manowar album', '3:10')
        p = Playlist('Ala bala')
        p.add_songs([s1, s2, s3, s4])
        expectedHistogram = {'U2': 3, 'Manowar': 1}

        self.assertEqual(p.show_artists(), expectedHistogram)
コード例 #4
0
    def test_playlist_add_songs(self):
        s1 = Song('One', 'U2', 'Achtung Baby', '4:38')
        s2 = Song('Warriors of the World', 'Manowar', 'Manowar album', '3:10')
        s3 = Song('Chiki chiki ta', 'Kondio', 'Doko doko', '7:32')
        songlist = [s1, s2, s3]
        p = Playlist('mish mash')
        
        p.add_songs(songlist)

        for s in songlist:
            self.assertIn(s, p.songslist)
コード例 #5
0
    def test_load(self):
        s1 = Song('One', 'U2', 'Achtung Baby', '4:38')
        s2 = Song('Two', 'U2', 'Epimeno', '7:32')
        s3 = Song('Three', 'Kondio', 'Doko doko', '7:32')
        p = Playlist('newplaylist')
        newsongs = p.load('./Ala-bala.json')
        os.remove("./Ala-bala.json")
        p.add_songs(newsongs)

        self.assertIn(s1, p.songslist)
        self.assertIn(s2, p.songslist)
        self.assertNotIn(s3, p.songslist)
コード例 #6
0
 def test_save(self):
     s1 = Song('One', 'U2', 'Achtung Baby', '4:38')
     s2 = Song('Two', 'U2', 'Epimeno', '7:32')
     p = Playlist('Ala bala')
     p.add_songs([s1, s2])
     p.save()
     self.assertTrue(os.path.isfile('./Ala-bala.json'))
コード例 #7
0
    def test_next_song_repeat_works(self):
        s1 = Song('One', 'U2', 'Achtung Baby', '4:38')
        s2 = Song('Two', 'U2', 'Epimeno', '7:32')
        s3 = Song('Three', 'U2', 'Achtung Baby', '3:15')
        p = Playlist('Ala bala', repeat=True)
        p.add_songs([s1, s2, s3])

        self.assertEqual(p.next_song(), s1)
        self.assertEqual(p.next_song(), s2)
        self.assertEqual(p.next_song(), s3)
        self.assertEqual(p.next_song(), s1)
コード例 #8
0
    def test_playlist_add_song(self):
        s1 = Song('One', 'U2', 'Achtung Baby', '4:38')
        p = Playlist('Onesong')
        p.add_song(s1)

        self.assertIn(s1, p.songslist)