Exemple #1
0
    def __init__(self, artist, title, album=None, year=None, track=None, duration=None):
        """Initialize a new song.

        @param artist: name of song's artist
        @param title: name song
        @param album: name of song's album
        @param year: year of song's album's release
        @param track: track number on album
        @param duration: length of song in seconds
        """
        self.title = Title(title)
        self.artist = Artist(artist)
        self.album = Album(album, year)
        self.track = self._parse_int(track, "track number")
        self.duration = self._parse_int(duration, "song duration")
        super(Song, self).__init__()
 def test_different(self):
     """Verify different artist names are not equal."""
     self.assertNotEqual(Artist("Artist A"), Artist("Artist B"))
 def test_types(self):
     """Verify different types are not equal."""
     self.assertNotEqual(Artist("Name"), "Name")
 def test_and_order(self):
     """Verify order of multiple artists does not matter."""
     self.assertEqual(Artist("Artist + Others"), Artist("Others & Artist"))
 def test_ands(self):
     """Verify artist "and" operators do not matter."""
     self.assertEqual(Artist("Artist + Others"), Artist("Artist & others"))
 def test_case(self):
     """Verify artist name case does not matter."""
     self.assertEqual(Artist("Artist Name"), Artist("Artist name"))
 def test_exact(self):
     """Verify exact artist name matches are equal."""
     self.assertEqual(Artist("Artist Name"), Artist("Artist Name"))
 def test_nominal(self):
     """Verify a normal artist can be formatted."""
     artist = Artist("The Something")
     self.assertEqual("The Something", str(artist))
     self.assertEqual(artist, eval(repr(artist)))
 def test_nominal(self):
     """Verify a normal artist can be parsed."""
     artist = Artist("The Something")
     self.assertEqual("The Something", artist.name)