Add test_playlist_contents_get_written_to_disk test
This commit is contained in:
parent
d522415757
commit
2f4cea2339
@ -142,6 +142,13 @@ class GStreamerStoredPlaylistsController(BaseStoredPlaylistsController):
|
||||
shutil.move(src, dst)
|
||||
|
||||
def save(self, playlist):
|
||||
file = os.path.join(self._folder, playlist.name + '.m3u')
|
||||
open(file, 'w').close()
|
||||
file_path = os.path.join(self._folder, playlist.name + '.m3u')
|
||||
|
||||
with open(file_path, 'w') as file:
|
||||
for track in playlist.tracks:
|
||||
if track.uri.startswith('file:'):
|
||||
file.write(track.uri[len('file:'):] + '\n')
|
||||
else:
|
||||
file.write(track.uri + '\n')
|
||||
|
||||
self._playlists.append(playlist)
|
||||
|
||||
@ -7,6 +7,7 @@ from mopidy.backends.gstreamer import GStreamerBackend
|
||||
from mopidy import settings
|
||||
|
||||
from tests.backends.base import *
|
||||
from tests import SkipTest
|
||||
|
||||
folder = os.path.dirname(__file__)
|
||||
folder = os.path.join(folder, '..', 'data')
|
||||
@ -79,6 +80,19 @@ class GStreamerBackendStoredPlaylistsControllerTest(BaseStoredPlaylistsControlle
|
||||
self.assert_(not os.path.exists(file1))
|
||||
self.assert_(os.path.exists(file2))
|
||||
|
||||
def test_playlist_contents_get_written_to_disk(self):
|
||||
track = Track(uri=generate_song(1))
|
||||
uri = track.uri[len('file:'):]
|
||||
playlist = Playlist(tracks=[track], name='test')
|
||||
file_path = os.path.join(settings.PLAYLIST_FOLDER, 'test.m3u')
|
||||
|
||||
self.stored.save(playlist)
|
||||
|
||||
with open(file_path) as file:
|
||||
contents = file.read()
|
||||
|
||||
self.assertEqual(uri, contents.strip())
|
||||
|
||||
def test_santitising_of_playlist_filenames(self):
|
||||
raise SkipTest
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user