本文整理汇总了Python中mopidy.models.Ref.track方法的典型用法代码示例。如果您正苦于以下问题:Python Ref.track方法的具体用法?Python Ref.track怎么用?Python Ref.track使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mopidy.models.Ref
的用法示例。
在下文中一共展示了Ref.track方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_browse_items
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import track [as 别名]
def test_browse_items(backend, container, items):
# FIXME: how to patch multiple object methods...
with mock.patch.object(backend, 'client') as m:
m.properties.return_value = Future.fromvalue(container)
m.browse.return_value = Future.fromvalue(items)
assert backend.library.browse(container['URI']) == [
Ref.track(name='Track #1', uri='dleyna://media/1'),
Ref.track(name='Track #2', uri='dleyna://media/2')
]
示例2: to_mopidy_track_ref
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import track [as 别名]
def to_mopidy_track_ref(spotify_track):
uri = str(spotify.Link.from_track(spotify_track, 0))
if not spotify_track.is_loaded():
return Ref.track(uri=uri, name='[loading] %s' % uri)
name = spotify_track.name()
if spotify_track.availability() != TRACK_AVAILABLE:
name = '[unplayable] %s' % name
return Ref.track(uri=uri, name=name)
示例3: test_browse_dir_returns_subdirs_and_tracks
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import track [as 别名]
def test_browse_dir_returns_subdirs_and_tracks(self):
self.library1.browse.return_value.get.return_value = [
Ref.directory(uri='dummy1:directory:/foo/bar', name='Bar'),
Ref.track(uri='dummy1:track:/foo/baz.mp3', name='Baz'),
]
result = self.core.library.browse('dummy1:directory:/foo')
self.assertEqual(result, [
Ref.directory(uri='dummy1:directory:/foo/bar', name='Bar'),
Ref.track(uri='dummy1:track:/foo/baz.mp3', name='Baz'),
])
示例4: setUp
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import track [as 别名]
def setUp(self): # noqa: N802
super(AddCommandsTest, self).setUp()
self.tracks = [Track(uri='dummy:/a', name='a'),
Track(uri='dummy:/foo/b', name='b')]
self.refs = {'/a': Ref.track(uri='dummy:/a', name='a'),
'/foo': Ref.directory(uri='dummy:/foo', name='foo'),
'/foo/b': Ref.track(uri='dummy:/foo/b', name='b')}
self.backend.library.dummy_library = self.tracks
示例5: test_add_with_library_should_recurse
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import track [as 别名]
def test_add_with_library_should_recurse(self):
tracks = [Track(uri='dummy:/a', name='a'),
Track(uri='dummy:/foo/b', name='b')]
self.backend.library.dummy_library = tracks
self.backend.library.dummy_browse_result = {
'dummy:/': [Ref.track(uri='dummy:/a', name='a'),
Ref.directory(uri='dummy:/foo', name='foo')],
'dummy:/foo': [Ref.track(uri='dummy:/foo/b', name='b')]}
self.sendRequest('add "/dummy"')
self.assertEqual(self.core.tracklist.tracks.get(), tracks)
self.assertInResponse('OK')
示例6: test_browse_items
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import track [as 别名]
def test_browse_items(backend, container, items):
# FIXME: how to patch multiple object methods...
with mock.patch.object(backend, 'client') as m:
m.properties.return_value = Future.fromvalue(container)
m.browse.side_effect = [
Future.fromvalue([items[0:2], True]),
Future.fromvalue([items[2:3], True]),
Future.fromvalue([[], False])
]
assert backend.library.browse(container['URI']) == [
Ref.track(name='Track #1', uri='dleyna://media/1'),
Ref.track(name='Track #2', uri='dleyna://media/2'),
Ref.track(name='Track #3', uri='dleyna://media/3'),
]
示例7: test_listall_with_uri
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import track [as 别名]
def test_listall_with_uri(self):
tracks = [Track(uri="dummy:/a", name="a"), Track(uri="dummy:/foo/b", name="b")]
self.backend.library.dummy_library = tracks
self.backend.library.dummy_browse_result = {
"dummy:/": [Ref.track(uri="dummy:/a", name="a"), Ref.directory(uri="dummy:/foo", name="foo")],
"dummy:/foo": [Ref.track(uri="dummy:/foo/b", name="b")],
}
self.sendRequest('listall "/dummy/foo"')
self.assertNotInResponse("file: dummy:/a")
self.assertInResponse("directory: /dummy/foo")
self.assertInResponse("file: dummy:/foo/b")
self.assertInResponse("OK")
示例8: test_browse_dir_returns_subdirs_and_tracks
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import track [as 别名]
def test_browse_dir_returns_subdirs_and_tracks(self):
self.library1.browse().get.return_value = [
Ref.directory(uri="dummy1:directory:/foo/bar", name="Bar"),
Ref.track(uri="dummy1:track:/foo/baz.mp3", name="Baz"),
]
self.library1.browse.reset_mock()
result = self.core.library.browse("dummy1:directory:/foo")
self.assertEqual(
result,
[
Ref.directory(uri="dummy1:directory:/foo/bar", name="Bar"),
Ref.track(uri="dummy1:track:/foo/baz.mp3", name="Baz"),
],
)
示例9: test_listall_with_uri
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import track [as 别名]
def test_listall_with_uri(self):
tracks = [Track(uri='dummy:/a', name='a'),
Track(uri='dummy:/foo/b', name='b')]
self.backend.library.dummy_library = tracks
self.backend.library.dummy_browse_result = {
'dummy:/': [Ref.track(uri='dummy:/a', name='a'),
Ref.directory(uri='dummy:/foo', name='foo')],
'dummy:/foo': [Ref.track(uri='dummy:/foo/b', name='b')]}
self.sendRequest('listall "/dummy/foo"')
self.assertNotInResponse('file: dummy:/a')
self.assertInResponse('directory: /dummy/foo')
self.assertInResponse('file: dummy:/foo/b')
self.assertInResponse('OK')
示例10: __init__
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import track [as 别名]
def __init__(self, tracks, *args, **kwargs):
logger.debug("initializing SpotifyWebLibraryProvider cache")
self.albums2tracks = {}
self.artists2albums = {}
self.sortedAlbums = []
self.sortedArtists = []
self.tracks = []
self.trackDict = {}
for t in tracks:
logger.debug("Adding track %s", t.name)
self.tracks.append(Ref.track(name=t.name, uri=t.uri))
self.trackDict[t.uri] = t
if hasattr(t, 'album'):
self.add_album_and_artists(t)
logger.debug('Sorting albums and artists')
cmp_dir_names = lambda x, y: cmp(x.name, y.name)
self.sortedAlbums.sort(cmp_dir_names)
self.sortedArtists.sort(cmp_dir_names)
logger.debug('Sorting albums by track number')
for key in self.albums2tracks:
logger.debug('Sorting album %s', key)
album = self.albums2tracks[key]
cmp_tracknos = lambda x, y: \
cmp(self.trackDict[x.uri].track_no,
self.trackDict[y.uri].track_no)
album.sort(cmp_tracknos)
示例11: station_to_ref
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import track [as 别名]
def station_to_ref(station, show_country=True):
name = station.get('name').strip() # TODO: fallback to streams URI?
if show_country:
# TODO: make this a setting so users can set '$name [$country]' etc?
name = '%s [%s]' % (name, station.get('country', '??'))
uri = unparse_uri('station', station['id'])
return Ref.track(uri=uri, name=name)
示例12: test_lsinfo_for_dir_includes_tracks
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import track [as 别名]
def test_lsinfo_for_dir_includes_tracks(self):
self.backend.library.dummy_library = [Track(uri="dummy:/a", name="a")]
self.backend.library.dummy_browse_result = {"dummy:/": [Ref.track(uri="dummy:/a", name="a")]}
self.sendRequest('lsinfo "/dummy"')
self.assertInResponse("file: dummy:/a")
self.assertInResponse("Title: a")
self.assertInResponse("OK")
示例13: test_lsinfo_for_dir_with_and_without_leading_slash_is_the_same
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import track [as 别名]
def test_lsinfo_for_dir_with_and_without_leading_slash_is_the_same(self):
self.backend.library.dummy_browse_result = {
"dummy:/": [Ref.track(uri="dummy:/a", name="a"), Ref.directory(uri="dummy:/foo", name="foo")]
}
response1 = self.sendRequest('lsinfo "dummy"')
response2 = self.sendRequest('lsinfo "/dummy"')
self.assertEqual(response1, response2)
示例14: test_lsinfo_for_root_includes_dirs_for_each_lib_with_content
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import track [as 别名]
def test_lsinfo_for_root_includes_dirs_for_each_lib_with_content(self):
self.backend.library.dummy_browse_result = {
"dummy:/": [Ref.track(uri="dummy:/a", name="a"), Ref.directory(uri="dummy:/foo", name="foo")]
}
self.sendRequest('lsinfo "/"')
self.assertInResponse("directory: dummy")
self.assertInResponse("OK")
示例15: test_add_root_should_not_add_anything_and_ok
# 需要导入模块: from mopidy.models import Ref [as 别名]
# 或者: from mopidy.models.Ref import track [as 别名]
def test_add_root_should_not_add_anything_and_ok(self):
self.backend.library.dummy_library = [Track(uri='dummy:/a', name='a')]
self.backend.library.dummy_browse_result = {
'dummy:/': [Ref.track(uri='dummy:/a', name='a')]}
self.sendRequest('add "/"')
self.assertEqual(len(self.core.tracklist.tracks.get()), 0)
self.assertInResponse('OK')