Пример #1
0
    def test_playlist_next_song_works_as_expected_with_repeat_and_shuffle(
            self):
        f = Song(title="Odin",
                 artist="Manowar",
                 album="The Sons of Odin",
                 length="3:44")
        s = Song(title="Empty",
                 artist="Metric",
                 album="Live It Out",
                 length="5:55")
        q = Song(title="Superman",
                 artist="Eminem",
                 album="The Eminem Show",
                 length="5:50")
        code_songs = Playlist(name="Code", repeat=True, shuffle=True)
        test = Playlist(name="Code2", repeat=True, shuffle=True)

        code_songs.add_song(f)
        code_songs.add_song(s)
        code_songs.add_song(q)

        test.add_song(code_songs.next_song())
        test.add_song(code_songs.next_song())
        test.add_song(code_songs.next_song())

        code_songs.next_song()

        assert code_songs.next_song() in getattr(test, 'songs')
Пример #2
0
    def test_adding_ongs_to_the_playlist_return_a_divtionary_with_artists_and_count_of_songs_they_have_in_the_playlist(
            self):
        song1 = Song(title="Odin",
                     artist="Manowar1",
                     album="The Sons of Odin",
                     length="3:44")
        song2 = Song(title="Odin",
                     artist="Manowar2",
                     album="The Sons of Odin",
                     length="3:44")
        song3 = Song(title="7 Rings",
                     artist="Ariana Grande",
                     album="Thank U, Next",
                     length="4:44")
        song4 = Song(title="Tank U, Next",
                     artist="Ariana Grande",
                     album="Thank U, Next",
                     length="4:44")

        play_list = PlayList(name="My New PlayList", repeat=True, shuffle=True)

        play_list.add_song(song1)
        play_list.add_song(song2)
        play_list.add_song(song3)
        play_list.add_song(song4)

        dic = play_list.artists()

        self.assertEqual(dic, {
            'Manowar1': 1,
            'Manowar2': 1,
            'Ariana Grande': 2
        })
Пример #3
0
    def test_playlist_next_song_works_as_expected_with_no_repeat_and_no_shuffle(
            self):
        f = Song(title="Odin",
                 artist="Manowar",
                 album="The Sons of Odin",
                 length="3:44")
        s = Song(title="Empty",
                 artist="Metric",
                 album="Live It Out",
                 length="5:55")
        q = Song(title="Superman",
                 artist="Eminem",
                 album="The Eminem Show",
                 length="5:50")
        code_songs = Playlist(name="Code", repeat=False, shuffle=False)

        code_songs.add_song(f)
        code_songs.add_song(s)
        code_songs.add_song(q)

        code_songs.next_song()
        code_songs.next_song()

        self.assertEqual(code_songs.next_song(),
                         'There are no more songs in your playlist.')
Пример #4
0
 def setUp(self):
     self.my_song = Song("Solder Of Frortune", "Deep Purple",
                         "Stormbringer", "3:14")
     self.second_song = Song("I Stand Alone", "Godsmack", "Awake", "4:30")
     self.rock = Playlist("Rock songs", True)
     self.songs = [self.my_song, self.second_song]
     self.rock.add_songs(self.songs)
 def test_the_function_artists_of_a_playlist_then_return_dictionary_where_keys_are_the_artists_and_values_are_the_numbers_of_the_songs(self):
     song = Song(title="Odin", artist="Manowar1", album="The Sons of Odin", length="3:44")
     song2 = Song(title="Odin", artist="Manowar2", album="The Sons of Odin", length="3:44")
     song3 = Song(title="Odin", artist="Manowar3", album="The Sons of Odin", length="3:44")
     playlist = Playlist(name="Code", repeat=True, shuffle=True)
     playlist.add_songs([song, song2, song3])
     expected_result = {'Manowar1': 1, 'Manowar2': 1, 'Manowar3': 1}
     self.assertEqual(playlist.artists(), expected_result)
 def test_returning_playlist_next_song_when_reach_the_last_song_and_shuffle_and_no_repeat_then_return_a_song(self):
     song = Song(title="Odin", artist="Manowar1", album="The Sons of Odin", length="3:44")
     song2 = Song(title="Odin", artist="Manowar2", album="The Sons of Odin", length="3:44")
     song3 = Song(title="Odin", artist="Manowar3", album="The Sons of Odin", length="3:44")
     playlist = Playlist(name="Code", repeat=False, shuffle=True)
     playlist.add_songs([song, song2, song3])
     expected_result = song
     self.assertEqual(type(playlist.next_song(song3)), type(expected_result))
 def test_add_list_of_songs_to_an_empty_playlist_then_return_the_total_length_of_the_songs(self):
     song = Song(title="Odin", artist="Manowar", album="The Sons of Odin", length="3:44")
     song2 = Song(title="Odin", artist="Manowar", album="The Sons of Odin", length="3:44")
     song3 = Song(title="Odin", artist="Manowar", album="The Sons of Odin", length="3:44")
     playlist = Playlist(name="Code", repeat=True, shuffle=True)
     playlist.add_songs([song, song2, song3])
     expected_result = '0:11:12'
     self.assertEqual(playlist.total_length(), expected_result)
Пример #8
0
 def setUp(self):
     self.pl = Playlist("ssss")
     self.pl.add_song(
         Song(title="Odin",
              artist="Manowar",
              album="The Sons of Odin",
              time="3:44"))
     self.pl.add_song(
         Song(title="Odin", artist="Manowar", album="Odin", time="6:26"))
Пример #9
0
 def setUp(self):
     self.song = Song(title="Odin",
                      artist="Manowar",
                      album="The Sons of Odin",
                      time="3:44")
     self.song1 = Song(title="Odin",
                       artist="Manowar",
                       album="Odin",
                       time="6:26")
Пример #10
0
    def test_if_two_song_are_equal_after_equalization(self):
        song1 = Song(title="Odin",
                     artist="Manowar",
                     album="The Sons of Odin",
                     length="3:44")
        song2 = Song(title="Odin",
                     artist="Manowar",
                     album="The Sons of Odin",
                     length="3:44")

        self.assertEqual(song1, song2)
Пример #11
0
def main():
    song1 = Song(title="Odin", artist="Manowar1", album="The Sons of Odin", length="3:44")
    song2 = Song(title="Odin", artist="Manowar2", album="The Sons of Odin", length="3:44")
    song3 = Song(title="7 Rings", artist="Ariana Grande", album="Thank U, Next", length="4:44")
    song4 = Song(title="Tank U, Next", artist="Ariana Grande", album="Thank U, Next", length="4:44")

    playlist = PlayList(name="My New PlayList", repeat=True, shuffle=True)
    playlist.add_songs([song1, song2, song3, song4])

    playlist.save()
    playlist2 = PlayList.load("My-New-PlayList.json")
    print(playlist2.name == "My New PlayList")
Пример #12
0
    def test_song_len_correctly_returns_hours_when_called_with_hours(self):
        test1 = Song(title="Odin",
                     artist="Manowar",
                     album="The Sons of Odin",
                     length="3:44")
        test2 = Song(title="TEST",
                     artist="TEST",
                     album="TEST",
                     length="2:43:44")

        self.assertEqual(test1.length(hours=True), '0')
        self.assertEqual(test2.length(hours=True), '2')
Пример #13
0
	def test_length_in_hours(self):

		song1 = Song('title', 'artist', 'album', '02:55')
		song2 = Song('title2', 'artist2', 'album2', '02:03:55')
		song3 = Song('title3', 'artist3', 'album3', '00:58')

		hours1 = song1.length1(hours=True)
		hours2 = song2.length1(hours=True)
		hours3 = song3.length1(hours=True)

		self.assertEqual(hours1, 0)
		self.assertEqual(hours2, 2)
		self.assertEqual(hours3, 0)
Пример #14
0
	def test_length_in_seconds(self):

		song1 = Song('title', 'artist', 'album', '02:55')
		song2 = Song('title2', 'artist2', 'album2', '02:03:55')
		song3 = Song('title3', 'artist3', 'album3', '00:58')

		secs1 = song1.length1(seconds=True)
		secs2 = song2.length1(seconds=True)
		secs3 = song3.length1(seconds=True)

		self.assertEqual(secs1, 175)
		self.assertEqual(secs2, 955)
		self.assertEqual(secs3, 58)
Пример #15
0
	def test_length_in_minutes(self):

		song1 = Song('title', 'artist', 'album', '2:55')
		song2 = Song('title2', 'artist2', 'album2', '02:03:55')
		song3 = Song('title3', 'artist3', 'album3', '00:58')

		mins1 = song1.length1(minutes=True)
		mins2 = song2.length1(minutes=True)
		mins3 = song3.length1(minutes=True)

		self.assertEqual(mins1, 2)
		self.assertEqual(mins2, 123)
		self.assertEqual(mins3, 0)
Пример #16
0
    def test_song_len_correctly_returns_seconds_when_called_with_seconds(self):
        test = Song(title="Odin",
                    artist="Manowar",
                    album="The Sons of Odin",
                    length="3:44")

        self.assertEqual(test.length(seconds=True), '224')
Пример #17
0
    def test_song_eq_dunder_correctly_compares_objects(self):
        test1 = Song(title="Odin",
                     artist="Manowar",
                     album="The Sons of Odin",
                     length="3:44")
        test2 = Song(title="Odin",
                     artist="Manowar",
                     album="The Sons of Odin",
                     length="3:44")
        test3 = Song(title="Metric",
                     artist="Empty",
                     album="Live It Out",
                     length="5:55")

        self.assertEqual(test1, test2)
        self.assertNotEqual(test2, test3)
Пример #18
0
    def test_playlist_total_length_is_calculated_correctly_with_songs_under_a_minute(
            self):
        my_playlist = Playlist(name="Code", repeat=True, shuffle=True)
        test1 = Song(title="Odin",
                     artist="Manowar",
                     album="The Sons of Odin",
                     length="0:44")
        test2 = Song(title="Empty",
                     artist="Metric",
                     album="Live It Out",
                     length="0:10")

        my_playlist.add_song(test1)
        my_playlist.add_song(test2)

        self.assertEqual(my_playlist.total_length(), '0:54')
Пример #19
0
    def test_playlist_total_length_is_calculated_correctly_with_songs_sum_over_hour(
            self):
        my_playlist = Playlist(name="Code", repeat=True, shuffle=True)
        test1 = Song(title="Odin",
                     artist="Manowar",
                     album="The Sons of Odin",
                     length="55:44")
        test2 = Song(title="Empty",
                     artist="Metric",
                     album="Live It Out",
                     length="5:16")

        my_playlist.add_song(test1)
        my_playlist.add_song(test2)

        self.assertEqual(my_playlist.total_length(), '1:01:00')
Пример #20
0
	def test_string_representation(self):

		song = Song('title', 'artist', 'album', '02:55')
		
		result = str(song)
		expected = 'title - artist from album - 02:55'

		self.assertEqual(result, expected)
Пример #21
0
	def test_string_representation_of_length(self):

		song = Song('title', 'artist', 'album', '02:55')

		result = song.length1()
		expected = '02:55'

		self.assertEqual(result, expected)
Пример #22
0
    def test_song_len_correctly_returns_str_representation_when_called_without_arguments(
            self):
        test = Song(title="Odin",
                    artist="Manowar",
                    album="The Sons of Odin",
                    length="3:44")

        self.assertEqual(test.length(), '3:44')
Пример #23
0
    def test_song_str_dunder_representation_is_as_expected(self):
        test = Song(title="Odin",
                    artist="Manowar",
                    album="The Sons of Odin",
                    length="3:44")

        self.assertEqual(str(test),
                         'Manowar - Odin from The Sons of Odin - 3:44')
Пример #24
0
    def test_printing_the_song(self):
        song = Song(title="Odin",
                    artist="Manowar",
                    album="The Sons of Odin",
                    length="3:44")

        self.assertEqual(str(song),
                         "Manowar - Odin from The Sons of Odin - 3:44")
Пример #25
0
 def setUp(self, **kwargs):
     self.song = Song(title="Odin",
                      artist="Manowar",
                      album="The Sons of Odin",
                      length="3:44")
     self.title = "Odin"
     self.artist = "Manowar"
     self.album = "The Sons of Odin"
     self.length = "3:44"
Пример #26
0
 def test_shuffle(self):
     self.rock.change_shuffle(True)
     bard = Song("The Bard's Song", "Blind Guardian", "Somwhere Far Beyond",
                 "3:28")
     self.rock.add_song(bard)
     a = self.rock.next_song()
     b = self.rock.next_song()
     c = self.rock.next_song()
     self.assertTrue(a != b and c != a and c != b)
Пример #27
0
    def test_playlist_artists_works_as_expected(self):
        my_playlist = Playlist(name="Code", repeat=True, shuffle=True)
        test = Song(title="Odin",
                    artist="Manowar",
                    album="The Sons of Odin",
                    length="3:44")

        my_playlist.add_song(test)

        self.assertEqual(my_playlist.artists(), {'Manowar': 1})
Пример #28
0
    def test_if_there_are_no_arguments_returns_the_string_representation_of_the_length(
            self):
        song = Song(title="Odin",
                    artist="Manowar",
                    album="The Sons of Odin",
                    length="1:30:44")

        res = song.song_length()

        self.assertEqual(res, "1:30:44")
Пример #29
0
    def test_if_argument_hours_is_true_returns_the_length_in_hours_and_the_length_has_hours(
            self):
        song = Song(title="Odin",
                    artist="Manowar",
                    album="The Sons of Odin",
                    length="1:30:44")

        res = song.song_length(hours=True)

        self.assertEqual(res, 1)
Пример #30
0
    def test_adding_songs_to_the_play_list_return_a_string_representationof_the_total_length_of_all_songs_with_hours(
            self):
        song1 = Song(title="Odin",
                     artist="Manowar",
                     album="The Sons of Odin",
                     length="1:13:04")
        song2 = Song(title="7 Rings",
                     artist="Ariana Grande",
                     album="Thank U, Next",
                     length="4:44")

        play_list = PlayList(nam="My New PlayList", repeat=True, shuffle=True)

        play_list.add_song(song1)
        play_list.add_song(song2)

        res = play_list.total_length()

        self.assertEqual(res, "1:17:48")