1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
import pytest
from mopidy.internal import path
from tests import path_to_data_dir
@pytest.mark.parametrize("follow_symlinks", [True, False])
@pytest.mark.parametrize(
"uri, levelname",
[
("file:root", None),
("not_in_data_path", "WARNING"),
(path.path_to_uri(path_to_data_dir("song1.wav")), "ERROR"),
(path.path_to_uri(path_to_data_dir("")), None),
],
)
def test_file_browse(provider, uri, levelname, caplog):
result = provider.browse(uri)
assert type(result) is list
if levelname:
assert len(result) == 0
record = caplog.records[0]
assert record.levelname == levelname
assert "Rejected attempt" in record.message
return
assert len(result) >= 1
@pytest.mark.parametrize(
"media_dirs, expected",
[
([str(path_to_data_dir(""))], False),
([str(path_to_data_dir("")), str(path_to_data_dir(""))], True),
([], None),
([str(path_to_data_dir("song1.wav"))], None),
(["|" + str(path_to_data_dir(""))], False),
([str(path_to_data_dir("$"))], None),
],
)
def test_file_root_directory(provider, expected):
"""Test root_directory()"""
ref = provider.root_directory
if expected is None:
assert not ref
return
assert ref.name == "Files"
assert (ref.uri == "file:root") == expected
|