local: URIs should be unicode
Any non-ASCII content is uriencoded anyway.
This commit is contained in:
parent
9fde0bec55
commit
8b543bad44
@ -42,11 +42,11 @@ def path_to_local_track_uri(relpath):
|
|||||||
URI."""
|
URI."""
|
||||||
if isinstance(relpath, compat.text_type):
|
if isinstance(relpath, compat.text_type):
|
||||||
relpath = relpath.encode('utf-8')
|
relpath = relpath.encode('utf-8')
|
||||||
return b'local:track:%s' % urllib.quote(relpath)
|
return 'local:track:%s' % urllib.quote(relpath)
|
||||||
|
|
||||||
|
|
||||||
def path_to_local_directory_uri(relpath):
|
def path_to_local_directory_uri(relpath):
|
||||||
"""Convert path relative to :confval:`local/media_dir` directory URI."""
|
"""Convert path relative to :confval:`local/media_dir` directory URI."""
|
||||||
if isinstance(relpath, compat.text_type):
|
if isinstance(relpath, compat.text_type):
|
||||||
relpath = relpath.encode('utf-8')
|
relpath = relpath.encode('utf-8')
|
||||||
return b'local:directory:%s' % urllib.quote(relpath)
|
return 'local:directory:%s' % urllib.quote(relpath)
|
||||||
|
|||||||
@ -4,6 +4,7 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from mopidy import compat
|
||||||
from mopidy.local import translator
|
from mopidy.local import translator
|
||||||
|
|
||||||
|
|
||||||
@ -89,7 +90,9 @@ def test_path_to_file_uri(path, uri):
|
|||||||
(b'\x00\x01\x02', 'local:track:%00%01%02'),
|
(b'\x00\x01\x02', 'local:track:%00%01%02'),
|
||||||
])
|
])
|
||||||
def test_path_to_local_track_uri(path, uri):
|
def test_path_to_local_track_uri(path, uri):
|
||||||
assert translator.path_to_local_track_uri(path) == uri
|
result = translator.path_to_local_track_uri(path)
|
||||||
|
assert isinstance(result, compat.text_type)
|
||||||
|
assert result == uri
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('path,uri', [
|
@pytest.mark.parametrize('path,uri', [
|
||||||
@ -99,4 +102,6 @@ def test_path_to_local_track_uri(path, uri):
|
|||||||
(b'\x00\x01\x02', 'local:directory:%00%01%02'),
|
(b'\x00\x01\x02', 'local:directory:%00%01%02'),
|
||||||
])
|
])
|
||||||
def test_path_to_local_directory_uri(path, uri):
|
def test_path_to_local_directory_uri(path, uri):
|
||||||
assert translator.path_to_local_directory_uri(path) == uri
|
result = translator.path_to_local_directory_uri(path)
|
||||||
|
assert isinstance(result, compat.text_type)
|
||||||
|
assert result == uri
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user