Split artist and albumartist dependency, update tests based on this
This commit is contained in:
parent
51ffcb8609
commit
24944bd8e3
@ -120,7 +120,6 @@ def _convert_mpd_data(data, tracks):
|
|||||||
|
|
||||||
if 'artist' in data:
|
if 'artist' in data:
|
||||||
artist_kwargs['name'] = data['artist']
|
artist_kwargs['name'] = data['artist']
|
||||||
albumartist_kwargs['name'] = data['artist']
|
|
||||||
|
|
||||||
if 'albumartist' in data:
|
if 'albumartist' in data:
|
||||||
albumartist_kwargs['name'] = data['albumartist']
|
albumartist_kwargs['name'] = data['albumartist']
|
||||||
|
|||||||
@ -44,9 +44,6 @@ def track_to_mpd_format(track, position=None):
|
|||||||
track.track_no, track.album.num_tracks)))
|
track.track_no, track.album.num_tracks)))
|
||||||
else:
|
else:
|
||||||
result.append(('Track', track.track_no))
|
result.append(('Track', track.track_no))
|
||||||
if track.album is not None and track.album.artists:
|
|
||||||
artists = artists_to_mpd_format(track.album.artists)
|
|
||||||
result.append(('AlbumArtist', artists))
|
|
||||||
if position is not None and tlid is not None:
|
if position is not None and tlid is not None:
|
||||||
result.append(('Pos', position))
|
result.append(('Pos', position))
|
||||||
result.append(('Id', tlid))
|
result.append(('Id', tlid))
|
||||||
@ -55,6 +52,8 @@ def track_to_mpd_format(track, position=None):
|
|||||||
# FIXME don't use first and best artist?
|
# FIXME don't use first and best artist?
|
||||||
# FIXME don't duplicate following code?
|
# FIXME don't duplicate following code?
|
||||||
if track.album is not None and track.album.artists:
|
if track.album is not None and track.album.artists:
|
||||||
|
artists = artists_to_mpd_format(track.album.artists)
|
||||||
|
result.append(('AlbumArtist', artists))
|
||||||
artists = filter(
|
artists = filter(
|
||||||
lambda a: a.musicbrainz_id is not None, track.album.artists)
|
lambda a: a.musicbrainz_id is not None, track.album.artists)
|
||||||
if artists:
|
if artists:
|
||||||
|
|||||||
@ -26,6 +26,7 @@ class LocalLibraryProviderTest(unittest.TestCase):
|
|||||||
Album(name='album1', artists=[artists[0]]),
|
Album(name='album1', artists=[artists[0]]),
|
||||||
Album(name='album2', artists=[artists[1]]),
|
Album(name='album2', artists=[artists[1]]),
|
||||||
Album(name='album3', artists=[artists[2]]),
|
Album(name='album3', artists=[artists[2]]),
|
||||||
|
Album(name='album4'),
|
||||||
]
|
]
|
||||||
|
|
||||||
tracks = [
|
tracks = [
|
||||||
@ -41,6 +42,10 @@ class LocalLibraryProviderTest(unittest.TestCase):
|
|||||||
uri='local:track:path3', name='track3',
|
uri='local:track:path3', name='track3',
|
||||||
artists=[artists[3]], album=albums[2],
|
artists=[artists[3]], album=albums[2],
|
||||||
date='2003', length=4000, track_no=3),
|
date='2003', length=4000, track_no=3),
|
||||||
|
Track(
|
||||||
|
uri='local:track:path4', name='track4',
|
||||||
|
artists=[artists[2]], album=albums[3],
|
||||||
|
date='2004', length=60000, track_no=4),
|
||||||
]
|
]
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
@ -152,6 +157,12 @@ class LocalLibraryProviderTest(unittest.TestCase):
|
|||||||
result = self.library.find_exact(artist=['artist2'])
|
result = self.library.find_exact(artist=['artist2'])
|
||||||
self.assertEqual(list(result[0].tracks), self.tracks[1:2])
|
self.assertEqual(list(result[0].tracks), self.tracks[1:2])
|
||||||
|
|
||||||
|
import logging
|
||||||
|
logger = logging.getLogger('mopidy.backends.local')
|
||||||
|
logger.debug("==TEST= tracks: {}".format(self.tracks[2:3]))
|
||||||
|
result = self.library.find_exact(artist=['artist3'])
|
||||||
|
self.assertEqual(list(result[0].tracks), self.tracks[3:4])
|
||||||
|
|
||||||
def test_find_exact_album(self):
|
def test_find_exact_album(self):
|
||||||
result = self.library.find_exact(album=['album1'])
|
result = self.library.find_exact(album=['album1'])
|
||||||
self.assertEqual(list(result[0].tracks), self.tracks[:1])
|
self.assertEqual(list(result[0].tracks), self.tracks[:1])
|
||||||
@ -210,7 +221,7 @@ class LocalLibraryProviderTest(unittest.TestCase):
|
|||||||
|
|
||||||
# Matches on track album artists
|
# Matches on track album artists
|
||||||
result = self.library.find_exact(any=['artist3'])
|
result = self.library.find_exact(any=['artist3'])
|
||||||
self.assertEqual(list(result[0].tracks), self.tracks[2:3])
|
self.assertEqual(list(result[0].tracks), [self.tracks[3], self.tracks[2]])
|
||||||
|
|
||||||
# Matches on track year
|
# Matches on track year
|
||||||
result = self.library.find_exact(any=['2002'])
|
result = self.library.find_exact(any=['2002'])
|
||||||
@ -353,7 +364,7 @@ class LocalLibraryProviderTest(unittest.TestCase):
|
|||||||
|
|
||||||
# Matches on track album artists
|
# Matches on track album artists
|
||||||
result = self.library.search(any=['Tist3'])
|
result = self.library.search(any=['Tist3'])
|
||||||
self.assertEqual(list(result[0].tracks), self.tracks[2:3])
|
self.assertEqual(list(result[0].tracks), [self.tracks[3], self.tracks[2]])
|
||||||
|
|
||||||
# Matches on URI
|
# Matches on URI
|
||||||
result = self.library.search(any=['TH1'])
|
result = self.library.search(any=['TH1'])
|
||||||
|
|||||||
@ -93,28 +93,30 @@ class URItoM3UTest(unittest.TestCase):
|
|||||||
|
|
||||||
expected_artists = [Artist(name='name')]
|
expected_artists = [Artist(name='name')]
|
||||||
expected_albums = [
|
expected_albums = [
|
||||||
Album(name='albumname', artists=expected_artists, num_tracks=2)]
|
Album(name='albumname', artists=expected_artists, num_tracks=2),
|
||||||
|
Album(name='albumname', num_tracks=2)
|
||||||
|
]
|
||||||
expected_tracks = []
|
expected_tracks = []
|
||||||
|
|
||||||
|
|
||||||
def generate_track(path, ident):
|
def generate_track(path, ident, album_id):
|
||||||
uri = 'local:track:%s' % path
|
uri = 'local:track:%s' % path
|
||||||
track = Track(
|
track = Track(
|
||||||
uri=uri, name='trackname', artists=expected_artists,
|
uri=uri, name='trackname', artists=expected_artists,
|
||||||
album=expected_albums[0], track_no=1, date='2006', length=4000,
|
album=expected_albums[album_id], track_no=1, date='2006', length=4000,
|
||||||
last_modified=1272319626)
|
last_modified=1272319626)
|
||||||
expected_tracks.append(track)
|
expected_tracks.append(track)
|
||||||
|
|
||||||
|
|
||||||
generate_track('song1.mp3', 6)
|
generate_track('song1.mp3', 6, 0)
|
||||||
generate_track('song2.mp3', 7)
|
generate_track('song2.mp3', 7, 0)
|
||||||
generate_track('song3.mp3', 8)
|
generate_track('song3.mp3', 8, 1)
|
||||||
generate_track('subdir1/song4.mp3', 2)
|
generate_track('subdir1/song4.mp3', 2, 0)
|
||||||
generate_track('subdir1/song5.mp3', 3)
|
generate_track('subdir1/song5.mp3', 3, 0)
|
||||||
generate_track('subdir2/song6.mp3', 4)
|
generate_track('subdir2/song6.mp3', 4, 1)
|
||||||
generate_track('subdir2/song7.mp3', 5)
|
generate_track('subdir2/song7.mp3', 5, 1)
|
||||||
generate_track('subdir1/subsubdir/song8.mp3', 0)
|
generate_track('subdir1/subsubdir/song8.mp3', 0, 0)
|
||||||
generate_track('subdir1/subsubdir/song9.mp3', 1)
|
generate_track('subdir1/subsubdir/song9.mp3', 1, 1)
|
||||||
|
|
||||||
|
|
||||||
class MPDTagCacheToTracksTest(unittest.TestCase):
|
class MPDTagCacheToTracksTest(unittest.TestCase):
|
||||||
|
|||||||
@ -11,6 +11,7 @@ key: song8.mp3
|
|||||||
file: subdir1/subsubdir/song8.mp3
|
file: subdir1/subsubdir/song8.mp3
|
||||||
Time: 4
|
Time: 4
|
||||||
Artist: name
|
Artist: name
|
||||||
|
AlbumArtist: name
|
||||||
Title: trackname
|
Title: trackname
|
||||||
Album: albumname
|
Album: albumname
|
||||||
Track: 1/2
|
Track: 1/2
|
||||||
@ -32,6 +33,7 @@ key: song4.mp3
|
|||||||
file: subdir1/song4.mp3
|
file: subdir1/song4.mp3
|
||||||
Time: 4
|
Time: 4
|
||||||
Artist: name
|
Artist: name
|
||||||
|
AlbumArtist: name
|
||||||
Title: trackname
|
Title: trackname
|
||||||
Album: albumname
|
Album: albumname
|
||||||
Track: 1/2
|
Track: 1/2
|
||||||
@ -41,6 +43,7 @@ key: song5.mp3
|
|||||||
file: subdir1/song5.mp3
|
file: subdir1/song5.mp3
|
||||||
Time: 4
|
Time: 4
|
||||||
Artist: name
|
Artist: name
|
||||||
|
AlbumArtist: name
|
||||||
Title: trackname
|
Title: trackname
|
||||||
Album: albumname
|
Album: albumname
|
||||||
Track: 1/2
|
Track: 1/2
|
||||||
@ -76,6 +79,7 @@ key: song1.mp3
|
|||||||
file: /song1.mp3
|
file: /song1.mp3
|
||||||
Time: 4
|
Time: 4
|
||||||
Artist: name
|
Artist: name
|
||||||
|
AlbumArtist: name
|
||||||
Title: trackname
|
Title: trackname
|
||||||
Album: albumname
|
Album: albumname
|
||||||
Track: 1/2
|
Track: 1/2
|
||||||
@ -85,6 +89,7 @@ key: song2.mp3
|
|||||||
file: /song2.mp3
|
file: /song2.mp3
|
||||||
Time: 4
|
Time: 4
|
||||||
Artist: name
|
Artist: name
|
||||||
|
AlbumArtist: name
|
||||||
Title: trackname
|
Title: trackname
|
||||||
Album: albumname
|
Album: albumname
|
||||||
Track: 1/2
|
Track: 1/2
|
||||||
|
|||||||
@ -6,6 +6,7 @@ songList begin
|
|||||||
key: key1
|
key: key1
|
||||||
file: /path1
|
file: /path1
|
||||||
Artist: artist1
|
Artist: artist1
|
||||||
|
AlbumArtist: artist1
|
||||||
Title: track1
|
Title: track1
|
||||||
Album: album1
|
Album: album1
|
||||||
Date: 2001-02-03
|
Date: 2001-02-03
|
||||||
@ -14,6 +15,7 @@ Time: 4
|
|||||||
key: key2
|
key: key2
|
||||||
file: /path2
|
file: /path2
|
||||||
Artist: artist2
|
Artist: artist2
|
||||||
|
AlbumArtist: artist2
|
||||||
Title: track2
|
Title: track2
|
||||||
Album: album2
|
Album: album2
|
||||||
Date: 2002
|
Date: 2002
|
||||||
@ -28,4 +30,12 @@ Album: album3
|
|||||||
Date: 2003
|
Date: 2003
|
||||||
Track: 3
|
Track: 3
|
||||||
Time: 4
|
Time: 4
|
||||||
|
key: key4
|
||||||
|
file: /path4
|
||||||
|
Artist: artist3
|
||||||
|
Title: track4
|
||||||
|
Album: album4
|
||||||
|
Date: 2004
|
||||||
|
Track: 4
|
||||||
|
Time: 60
|
||||||
songList end
|
songList end
|
||||||
|
|||||||
@ -7,6 +7,7 @@ key: song1.mp3
|
|||||||
file: /song1.mp3
|
file: /song1.mp3
|
||||||
Time: 4
|
Time: 4
|
||||||
Artist: name
|
Artist: name
|
||||||
|
AlbumArtist: name
|
||||||
Title: trackname
|
Title: trackname
|
||||||
Album: albumname
|
Album: albumname
|
||||||
Track: 1/2
|
Track: 1/2
|
||||||
|
|||||||
@ -7,6 +7,7 @@ key: song1.mp3
|
|||||||
file: /song1.mp3
|
file: /song1.mp3
|
||||||
Time: 4
|
Time: 4
|
||||||
Artist: æøå
|
Artist: æøå
|
||||||
|
AlbumArtist: æøå
|
||||||
Title: æøå
|
Title: æøå
|
||||||
Album: æøå
|
Album: æøå
|
||||||
mtime: 1272319626
|
mtime: 1272319626
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user