Deploy path_to_uri all over
This commit is contained in:
parent
5cabd1c255
commit
9bf1ecede8
@ -142,9 +142,8 @@ def parse_m3u(file_path):
|
||||
if line.startswith('file://'):
|
||||
uris.append(line)
|
||||
else:
|
||||
path = os.path.join(folder, line)
|
||||
path = urllib.pathname2url(path.encode('utf-8'))
|
||||
uris.append('file://' + path)
|
||||
path = path_to_uri(folder, line)
|
||||
uris.append(path)
|
||||
|
||||
return uris
|
||||
|
||||
@ -219,7 +218,7 @@ def _convert_mpd_data(data, tracks, artists, albums, music_dir):
|
||||
else:
|
||||
path = os.path.join(music_dir, data['file'])
|
||||
|
||||
track_kwargs['uri'] = 'file://' + urllib.pathname2url(path)
|
||||
track_kwargs['uri'] = path_to_uri(path)
|
||||
track_kwargs['length'] = int(data.get('time', 0)) * 1000
|
||||
|
||||
track = Track(**track_kwargs)
|
||||
|
||||
@ -1,17 +1,17 @@
|
||||
import unittest
|
||||
import os
|
||||
import urllib
|
||||
|
||||
from mopidy import settings
|
||||
from mopidy.backends.gstreamer import GStreamerBackend
|
||||
from mopidy.mixers.dummy import DummyMixer
|
||||
from mopidy.models import Playlist, Track
|
||||
from mopidy.utils import path_to_uri
|
||||
|
||||
from tests.backends.base import *
|
||||
from tests import SkipTest, data_folder
|
||||
|
||||
song = data_folder('song%s.wav')
|
||||
generate_song = lambda i: 'file://' + urllib.pathname2url(song % i)
|
||||
generate_song = lambda i: path_to_uri(song % i)
|
||||
|
||||
# FIXME can be switched to generic test
|
||||
class GStreamerCurrentPlaylistHandlerTest(BaseCurrentPlaylistControllerTest, unittest.TestCase):
|
||||
@ -25,7 +25,7 @@ class GStreamerPlaybackControllerTest(BasePlaybackControllerTest, unittest.TestC
|
||||
backend_class = GStreamerBackend
|
||||
|
||||
def add_track(self, file):
|
||||
uri = 'file://' + urllib.pathname2url(data_folder(file))
|
||||
uri = path_to_uri(data_folder(file))
|
||||
track = Track(uri=uri, id=1, length=4464)
|
||||
self.backend.current_playlist.add(track)
|
||||
|
||||
@ -95,7 +95,6 @@ class GStreamerStoredPlaylistsControllerTest(BaseStoredPlaylistsControllerTest,
|
||||
|
||||
def test_playlists_are_loaded_at_startup(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')
|
||||
|
||||
|
||||
@ -48,9 +48,9 @@ class PathToFileURITest(unittest.TestCase):
|
||||
song1_path = data_folder('song1.mp3')
|
||||
song2_path = data_folder('song2.mp3')
|
||||
encoded_path = data_folder(u'æøå.mp3')
|
||||
song1_uri = 'file://' + urllib.pathname2url(song1_path)
|
||||
song2_uri = 'file://' + urllib.pathname2url(song2_path)
|
||||
encoded_uri = 'file://' + urllib.pathname2url(encoded_path.encode('utf-8'))
|
||||
song1_uri = path_to_uri(song1_path)
|
||||
song2_uri = path_to_uri(song2_path)
|
||||
encoded_uri = path_to_uri(encoded_path)
|
||||
|
||||
|
||||
class M3UToUriTest(unittest.TestCase):
|
||||
@ -106,7 +106,7 @@ expected_albums = [Album(name='albumname', artists=expected_artists, num_tracks=
|
||||
expected_tracks = []
|
||||
|
||||
def generate_track(path):
|
||||
uri = 'file://' + urllib.pathname2url(data_folder(path))
|
||||
uri = path_to_uri(data_folder(path))
|
||||
track = Track(name='trackname', artists=expected_artists, track_no=1,
|
||||
album=expected_albums[0], length=4000, uri=uri)
|
||||
expected_tracks.append(track)
|
||||
@ -156,7 +156,7 @@ class MPDTagCacheToTracksTest(unittest.TestCase):
|
||||
tracks, artists, albums = parse_mpd_tag_cache(data_folder('blank_tag_cache'),
|
||||
data_folder(''))
|
||||
|
||||
uri = 'file://' + urllib.pathname2url(data_folder('song1.mp3'))
|
||||
uri = path_to_uri(data_folder('song1.mp3'))
|
||||
|
||||
self.assertEqual(set([Track(uri=uri, length=4000)]), tracks)
|
||||
self.assertEqual(set(), artists)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user