예제 #1
0
class TestSong(unittest.TestCase):
    def setUp(self):
        self.song = Song("Bout Me", "Wiz Khalifa", "Cabin Fever", "3:30")

    def test_song_str(self):
        self.assertEqual(self.song.__str__(), "Wiz Khalifa - Bout Me from Cabin Fever - 3:30")

    def test_song_set_length(self):
        self.assertEqual(self.song.set_length(), time(0, 3, 30))

    def test_song_length_3(self):
        song3 = Song("Bout Me", "Wiz Khalifa", "Cabin Fever", "1:3:30")
        self.assertEqual(song3.set_length(), time(1, 3, 30))

    def test_song_length_seconds(self):
        self.assertEqual(self.song.length(seconds=True), 3*60 + 30)

    def test_song_length_minutes(self):
        self.assertEqual(self.song.length(minutes=True), 3)

    def test_song_length_hours(self):
        self.assertEqual(self.song.length(hours=True), 0)

    def test_song_length_song(self):
        self.assertEqual(self.song.length(), self.song.set_length().strftime("%h:%M:%S"))
예제 #2
0
class TestSong(unittest.TestCase):
    def setUp(self):
        self.song = Song("Bout Me", "Wiz Khalifa", "Cabin Fever", "3:30")

    def test_song_str(self):
        self.assertEqual(self.song.__str__(),
                         "Wiz Khalifa - Bout Me from Cabin Fever - 3:30")

    def test_song_set_length(self):
        self.assertEqual(self.song.set_length(), time(0, 3, 30))

    def test_song_length_3(self):
        song3 = Song("Bout Me", "Wiz Khalifa", "Cabin Fever", "1:3:30")
        self.assertEqual(song3.set_length(), time(1, 3, 30))

    def test_song_length_seconds(self):
        self.assertEqual(self.song.length(seconds=True), 3 * 60 + 30)

    def test_song_length_minutes(self):
        self.assertEqual(self.song.length(minutes=True), 3)

    def test_song_length_hours(self):
        self.assertEqual(self.song.length(hours=True), 0)

    def test_song_length_song(self):
        self.assertEqual(self.song.length(),
                         self.song.set_length().strftime("%h:%M:%S"))
예제 #3
0
class TestSong(unittest.TestCase):
    def setUp(self):
        self.song = Song()

    def test_init(self):
        self.assertEqual(self.song.__str__(),
                         "Manowar - Odin from The Sons of Odin - 3:44")

    def test_eq(self):
        self.assertEqual(self.song,
                         Song("Odin", "Manowar", "The Sons of Odin", "3:44"))

    def test_lenght_(self):
        song1 = Song(length="1:1:12")
        self.assertEqual(song1.lenght(seconds=True), "3672")
        self.assertEqual(song1.lenght(minutes=True), "61")
        self.assertEqual(song1.lenght(hours=True), "1")
        self.assertEqual(song1.lenght(), "1:1:12")