def test_path_to_uri(): from mopidy.m3u.translator import path_to_uri assert path_to_uri(b'test') == 'm3u:test' assert path_to_uri(b'test.m3u') == 'm3u:test.m3u' assert path_to_uri(b'./test.m3u') == 'm3u:test.m3u' assert path_to_uri(b'foo/../test.m3u') == 'm3u:test.m3u' assert path_to_uri(b'Test Playlist.m3u') == 'm3u:Test%20Playlist.m3u' assert path_to_uri(b'test.mp3', scheme='file') == 'file:///test.mp3'
def test_utf8_path_to_uri(): bytes_path = "æøå.m3u".encode() path = pathlib.Path(bytes_path.decode()) assert translator.path_to_uri(path) == "m3u:%C3%A6%C3%B8%C3%A5.m3u"
def test_latin1_path_to_uri(): bytes_path = "æøå.m3u".encode("latin-1") path = pathlib.Path(bytes_path.decode(errors="surrogateescape")) assert translator.path_to_uri(path) == "m3u:%E6%F8%E5.m3u"
def test_path_to_uri(path, scheme, expected): if scheme is not None: assert path_to_uri(pathlib.Path(path), scheme) == expected else: assert path_to_uri(pathlib.Path(path)) == expected
def test_utf8_path_to_uri(): path = 'æøå.m3u'.encode('utf-8') assert translator.path_to_uri(path) == 'm3u:%C3%A6%C3%B8%C3%A5.m3u'
def test_latin1_path_to_uri(): path = 'æøå.m3u'.encode('latin-1') assert translator.path_to_uri(path) == 'm3u:%E6%F8%E5.m3u'