class TestingSongClass(unittest.TestCase):

    def setUp(self):
        self.s = Song("Odin", "Manowar", "The Sons of Odin", "3:44")
        self.other = Song("Odin", "Manowar", "The Sons of Odin", "3:44")
        self.other2 = Song("Odinkata", "Manowar", "The Sons of Odin", "3:4:40")

    def test_init(self):
        self.assertEqual(self.s.title, "Odin")
        self.assertEqual(self.s.artist, "Manowar")
        self.assertEqual(self.s.album, "The Sons of Odin")
        self.assertEqual(self.s.length, "3:44")

    def test_eq(self):

        self.assertEqual(self.s, self.other)
        self.assertFalse(self.s == self.other2)

    def test_hash(self):
        pass

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

    def test_lengths(self):
        self.assertEqual(self.s.get_length(seconds=True), 224)
        self.assertEqual(self.other2.get_length(minutes=True), 184)
        self.assertEqual(self.other2.get_length(hours=True), 3)
        self.assertEqual(self.other.get_length(), "3:44")
예제 #2
0
 def test_get_length_when_default(self):
     test_song = Song(title='Love Runs Out', artist='OneRepublic', album='Native', length='3:44')
     expected_result = '3:44'
     self.assertEqual(test_song.get_length(), expected_result)
예제 #3
0
 def test_get_length_when_hours_is_true(self):
     test_song = Song(title='Love Runs Out', artist='OneRepublic', album='Native', length='3:44')
     expected_result = 0
     self.assertEqual(test_song.get_length(hours=True), expected_result)