Start writting tracks_to_tag_cache_format
This commit is contained in:
parent
3e595213ac
commit
02df8ca033
@ -1,3 +1,5 @@
|
||||
from mopidy.frontends.mpd import protocol
|
||||
|
||||
def track_to_mpd_format(track, position=None, cpid=None):
|
||||
"""
|
||||
Format track for output to MPD client.
|
||||
@ -72,3 +74,16 @@ def playlist_to_mpd_format(playlist, *args, **kwargs):
|
||||
Arguments as for :func:`tracks_to_mpd_format`, except the first one.
|
||||
"""
|
||||
return tracks_to_mpd_format(playlist.tracks, *args, **kwargs)
|
||||
|
||||
def tracks_to_tag_cache_format(tracks):
|
||||
result = [
|
||||
('info_begin',),
|
||||
('mpd_version', protocol.VERSION),
|
||||
('fs_charset', protocol.ENCODING),
|
||||
('info_end',)
|
||||
]
|
||||
|
||||
result.append(('songList begin',))
|
||||
result.append(('songList end',))
|
||||
|
||||
return result
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import datetime as dt
|
||||
import unittest
|
||||
|
||||
from mopidy.frontends.mpd import translator
|
||||
from mopidy.frontends.mpd import translator, protocol
|
||||
from mopidy.models import Album, Artist, Playlist, Track
|
||||
|
||||
class TrackMpdFormatTest(unittest.TestCase):
|
||||
@ -57,3 +57,22 @@ class PlaylistMpdFormatTest(unittest.TestCase):
|
||||
result = translator.playlist_to_mpd_format(playlist, 1, 2)
|
||||
self.assertEqual(len(result), 1)
|
||||
self.assertEqual(dict(result[0])['Track'], 2)
|
||||
|
||||
|
||||
class TracksToTagCacheFormatTest(unittest.TestCase):
|
||||
header_length = 4
|
||||
|
||||
def check_headers(self, result):
|
||||
self.assert_(('info_begin',) in result)
|
||||
self.assert_(('mpd_version', protocol.VERSION) in result)
|
||||
self.assert_(('fs_charset', protocol.ENCODING) in result)
|
||||
self.assert_(('info_end',) in result)
|
||||
|
||||
def test_empty_tag_cache(self):
|
||||
result = translator.tracks_to_tag_cache_format([])
|
||||
self.check_headers(result)
|
||||
|
||||
self.assert_(('songList begin',) in result)
|
||||
self.assert_(('songList end',) in result)
|
||||
self.assertEqual(len(result), self.header_length+2)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user