Remove Album._artists workaround
This commit is contained in:
parent
c5dd33a343
commit
9499250a7f
@ -84,6 +84,7 @@ def artists_to_mpd_format(artists):
|
||||
:type track: array of :class:`mopidy.models.Artist`
|
||||
:rtype: string
|
||||
"""
|
||||
artists = list(artists)
|
||||
artists.sort(key=lambda a: a.name)
|
||||
return u', '.join([a.name for a in artists if a.name])
|
||||
|
||||
|
||||
@ -65,6 +65,7 @@ class ImmutableObject(object):
|
||||
% key)
|
||||
return self.__class__(**data)
|
||||
|
||||
|
||||
class Artist(ImmutableObject):
|
||||
"""
|
||||
:param uri: artist URI
|
||||
@ -105,6 +106,9 @@ class Album(ImmutableObject):
|
||||
#: The album name. Read-only.
|
||||
name = None
|
||||
|
||||
#: A set of album artists. Read-only.
|
||||
artists = frozenset()
|
||||
|
||||
#: The number of tracks in the album. Read-only.
|
||||
num_tracks = 0
|
||||
|
||||
@ -112,14 +116,9 @@ class Album(ImmutableObject):
|
||||
musicbrainz_id = None
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self._artists = frozenset(kwargs.pop('artists', []))
|
||||
self.__dict__['artists'] = frozenset(kwargs.pop('artists', []))
|
||||
super(Album, self).__init__(*args, **kwargs)
|
||||
|
||||
@property
|
||||
def artists(self):
|
||||
"""List of :class:`Artist` elements. Read-only."""
|
||||
return list(self._artists)
|
||||
|
||||
|
||||
class Track(ImmutableObject):
|
||||
"""
|
||||
|
||||
@ -142,9 +142,9 @@ class AlbumTest(unittest.TestCase):
|
||||
self.assertRaises(AttributeError, setattr, album, 'name', None)
|
||||
|
||||
def test_artists(self):
|
||||
artists = [Artist()]
|
||||
album = Album(artists=artists)
|
||||
self.assertEqual(album.artists, artists)
|
||||
artist = Artist()
|
||||
album = Album(artists=[artist])
|
||||
self.assert_(artist in album.artists)
|
||||
self.assertRaises(AttributeError, setattr, album, 'artists', None)
|
||||
|
||||
def test_num_tracks(self):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user