当前位置: 首页>>代码示例>>Python>>正文


Python Ref.track方法代码示例

本文整理汇总了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')
        ]
开发者ID:anthonydahanne,项目名称:mopidy-dleyna,代码行数:11,代码来源:test_browse.py

示例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)
开发者ID:schinken,项目名称:mopidy-spotify,代码行数:11,代码来源:translator.py

示例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'),
        ])
开发者ID:HaBaLeS,项目名称:mopidy,代码行数:13,代码来源:test_library.py

示例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
开发者ID:AddBassStudios,项目名称:mopidy,代码行数:13,代码来源:test_current_playlist.py

示例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')
开发者ID:MacGyverQue,项目名称:mopidy,代码行数:15,代码来源:test_current_playlist.py

示例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'),
        ]
开发者ID:tkem,项目名称:mopidy-dleyna,代码行数:16,代码来源:test_browse.py

示例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")
开发者ID:valentinb,项目名称:mopidy,代码行数:16,代码来源:test_music_db.py

示例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"),
            ],
        )
开发者ID:Zarinia,项目名称:mopidy,代码行数:17,代码来源:test_library.py

示例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')
开发者ID:AndroidMarv,项目名称:mopidy,代码行数:17,代码来源:test_music_db.py

示例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)
开发者ID:lfcabend,项目名称:mopidy-spotify-web,代码行数:29,代码来源:library.py

示例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)
开发者ID:jcass77,项目名称:mopidy-dirble,代码行数:9,代码来源:translator.py

示例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")
开发者ID:valentinb,项目名称:mopidy,代码行数:10,代码来源:test_music_db.py

示例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)
开发者ID:valentinb,项目名称:mopidy,代码行数:10,代码来源:test_music_db.py

示例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")
开发者ID:valentinb,项目名称:mopidy,代码行数:10,代码来源:test_music_db.py

示例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')
开发者ID:MacGyverQue,项目名称:mopidy,代码行数:10,代码来源:test_current_playlist.py


注:本文中的mopidy.models.Ref.track方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。