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


Python models.Track方法代码示例

本文整理汇总了Python中mopidy.models.Track方法的典型用法代码示例。如果您正苦于以下问题:Python models.Track方法的具体用法?Python models.Track怎么用?Python models.Track使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mopidy.models的用法示例。


在下文中一共展示了models.Track方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_count_correct_length

# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import Track [as 别名]
def test_count_correct_length(self):
        # Count the lone track
        self.backend.library.dummy_find_exact_result = SearchResult(
            tracks=[Track(uri="dummy:a", name="foo", date="2001", length=4000)]
        )
        self.send_request('count "title" "foo"')
        self.assertInResponse("songs: 1")
        self.assertInResponse("playtime: 4")
        self.assertInResponse("OK")

        # Count multiple tracks
        self.backend.library.dummy_find_exact_result = SearchResult(
            tracks=[
                Track(uri="dummy:b", date="2001", length=50000),
                Track(uri="dummy:c", date="2001", length=600000),
            ]
        )
        self.send_request('count "date" "2001"')
        self.assertInResponse("songs: 2")
        self.assertInResponse("playtime: 650")
        self.assertInResponse("OK") 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:23,代码来源:test_music_db.py

示例2: test_searchaddpl_appends_to_existing_playlist

# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import Track [as 别名]
def test_searchaddpl_appends_to_existing_playlist(self):
        playlist = self.core.playlists.create("my favs").get()
        playlist = playlist.replace(
            tracks=[
                Track(uri="dummy:x", name="X"),
                Track(uri="dummy:y", name="y"),
            ]
        )
        self.core.playlists.save(playlist)
        self.backend.library.dummy_search_result = SearchResult(
            tracks=[Track(uri="dummy:a", name="A")]
        )

        items = self.core.playlists.get_items(playlist.uri).get()
        assert len(items) == 2

        self.send_request('searchaddpl "my favs" "title" "a"')

        items = self.core.playlists.get_items(playlist.uri).get()
        assert len(items) == 3
        assert items[0].uri == "dummy:x"
        assert items[1].uri == "dummy:y"
        assert items[2].uri == "dummy:a"
        self.assertInResponse("OK") 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:26,代码来源:test_music_db.py

示例3: test_searchaddpl_creates_missing_playlist

# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import Track [as 别名]
def test_searchaddpl_creates_missing_playlist(self):
        self.backend.library.dummy_search_result = SearchResult(
            tracks=[Track(uri="dummy:a", name="A")]
        )

        playlists = self.core.playlists.as_list().get()
        assert "my favs" not in {p.name for p in playlists}

        self.send_request('searchaddpl "my favs" "title" "a"')

        playlists = self.core.playlists.as_list().get()
        playlist = {p.name: p for p in playlists}["my favs"]

        items = self.core.playlists.get_items(playlist.uri).get()

        assert len(items) == 1
        assert items[0].uri == "dummy:a"
        self.assertInResponse("OK") 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:20,代码来源:test_music_db.py

示例4: test_listall_with_uri

# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models 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.send_request('listall "/dummy/foo"')

        self.assertNotInResponse("file: dummy:/a")
        self.assertInResponse("directory: /dummy/foo")
        self.assertInResponse("file: dummy:/foo/b")
        self.assertInResponse("OK") 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:22,代码来源:test_music_db.py

示例5: test_find_includes_fake_artist_and_album_tracks

# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import Track [as 别名]
def test_find_includes_fake_artist_and_album_tracks(self):
        self.backend.library.dummy_find_exact_result = SearchResult(
            albums=[Album(uri="dummy:album:a", name="A", date="2001")],
            artists=[Artist(uri="dummy:artist:b", name="B")],
            tracks=[Track(uri="dummy:track:c", name="C")],
        )

        self.send_request('find "any" "foo"')

        self.assertInResponse("file: dummy:artist:b")
        self.assertInResponse("Title: Artist: B")

        self.assertInResponse("file: dummy:album:a")
        self.assertInResponse("Title: Album: A")
        self.assertInResponse("Date: 2001")

        self.assertInResponse("file: dummy:track:c")
        self.assertInResponse("Title: C")

        self.assertInResponse("OK") 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:22,代码来源:test_music_db.py

示例6: test_find_artist_does_not_include_fake_artist_tracks

# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import Track [as 别名]
def test_find_artist_does_not_include_fake_artist_tracks(self):
        self.backend.library.dummy_find_exact_result = SearchResult(
            albums=[Album(uri="dummy:album:a", name="A", date="2001")],
            artists=[Artist(uri="dummy:artist:b", name="B")],
            tracks=[Track(uri="dummy:track:c", name="C")],
        )

        self.send_request('find "artist" "foo"')

        self.assertNotInResponse("file: dummy:artist:b")
        self.assertNotInResponse("Title: Artist: B")

        self.assertInResponse("file: dummy:album:a")
        self.assertInResponse("Title: Album: A")
        self.assertInResponse("Date: 2001")

        self.assertInResponse("file: dummy:track:c")
        self.assertInResponse("Title: C")

        self.assertInResponse("OK") 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:22,代码来源:test_music_db.py

示例7: test_find_albumartist_does_not_include_fake_artist_tracks

# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import Track [as 别名]
def test_find_albumartist_does_not_include_fake_artist_tracks(self):
        self.backend.library.dummy_find_exact_result = SearchResult(
            albums=[Album(uri="dummy:album:a", name="A", date="2001")],
            artists=[Artist(uri="dummy:artist:b", name="B")],
            tracks=[Track(uri="dummy:track:c", name="C")],
        )

        self.send_request('find "albumartist" "foo"')

        self.assertNotInResponse("file: dummy:artist:b")
        self.assertNotInResponse("Title: Artist: B")

        self.assertInResponse("file: dummy:album:a")
        self.assertInResponse("Title: Album: A")
        self.assertInResponse("Date: 2001")

        self.assertInResponse("file: dummy:track:c")
        self.assertInResponse("Title: C")

        self.assertInResponse("OK") 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:22,代码来源:test_music_db.py

示例8: test_search

# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import Track [as 别名]
def test_search(self):
        self.backend.library.dummy_search_result = SearchResult(
            albums=[Album(uri="dummy:album:a", name="A")],
            artists=[Artist(uri="dummy:artist:b", name="B")],
            tracks=[Track(uri="dummy:track:c", name="C")],
        )

        self.send_request('search "any" "foo"')

        self.assertInResponse("file: dummy:album:a")
        self.assertInResponse("Title: Album: A")
        self.assertInResponse("file: dummy:artist:b")
        self.assertInResponse("Title: Artist: B")
        self.assertInResponse("file: dummy:track:c")
        self.assertInResponse("Title: C")

        self.assertInResponse("OK") 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:19,代码来源:test_music_db.py

示例9: test_currentsong

# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import Track [as 别名]
def test_currentsong(self):
        track = Track(uri="dummy:/a")
        self.backend.library.dummy_library = [track]
        self.core.tracklist.add(uris=[track.uri]).get()

        self.core.playback.play().get()
        self.send_request("currentsong")
        self.assertInResponse("file: dummy:/a")
        self.assertInResponse("Time: 0")
        self.assertNotInResponse("Artist: ")
        self.assertNotInResponse("Title: ")
        self.assertNotInResponse("Album: ")
        self.assertNotInResponse("Track: 0")
        self.assertNotInResponse("Date: ")
        self.assertInResponse("Pos: 0")
        self.assertInResponse("Id: 1")
        self.assertInResponse("OK") 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:19,代码来源:test_status.py

示例10: setUp

# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import Track [as 别名]
def setUp(self):  # noqa: N802
        super().setUp()

        self.tracks = [
            Track(uri="dummy:/a", name="a"),
            Track(uri="dummy:/foo/b", name="b"),
            Track(uri="dummy:/foo/ǂ", name="ǂ"),
        ]

        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"),
            "/foo/ǂ": Ref.track(uri="dummy:/foo/ǂ", name="ǂ"),
        }

        self.backend.library.dummy_library = self.tracks 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:19,代码来源:test_current_playlist.py

示例11: test

# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import Track [as 别名]
def test(self):
        tracks = [
            Track(uri="dummy:a"),
            Track(uri="dummy:b"),
            Track(uri="dummy:c"),
            Track(uri="dummy:d"),
            Track(uri="dummy:e"),
            Track(uri="dummy:f"),
        ]
        self.backend.library.dummy_library = tracks
        self.core.tracklist.add(uris=[t.uri for t in tracks]).get()

        random.seed(1)

        self.send_request("play")
        self.send_request('random "1"')
        self.send_request('deleteid "1"')
        self.send_request('deleteid "2"')
        self.send_request('deleteid "3"')
        self.send_request('deleteid "4"')
        self.send_request('deleteid "5"')
        self.send_request('deleteid "6"')
        self.send_request("status") 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:25,代码来源:test_regression.py

示例12: test_listplaylistinfo

# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import Track [as 别名]
def test_listplaylistinfo(self):
        tracks = [
            Track(uri="dummy:a", name="Track A", length=5000),
            Track(uri="dummy:é", name="Track é", length=5000),
        ]
        self.backend.library.dummy_library = tracks
        self.backend.playlists.set_dummy_playlists(
            [Playlist(name="name", uri="dummy:name", tracks=tracks)]
        )

        self.send_request('listplaylistinfo "name"')

        self.assertInResponse("file: dummy:a")
        self.assertInResponse("Title: Track A")
        self.assertInResponse("Time: 5")
        self.assertInResponse("file: dummy:é")
        self.assertInResponse("Title: Track é")
        self.assertNotInResponse("Track: 0")
        self.assertNotInResponse("Pos: 0")
        self.assertInResponse("OK") 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:22,代码来源:test_stored_playlists.py

示例13: test_listplaylistinfo_duplicate

# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import Track [as 别名]
def test_listplaylistinfo_duplicate(self):
        tracks = [
            Track(uri="dummy:b"),
            Track(uri="dummy:c"),
        ]
        self.backend.library.dummy_library = tracks
        playlist1 = Playlist(name="a", uri="dummy:a1", tracks=tracks[:1])
        playlist2 = Playlist(name="a", uri="dummy:a2", tracks=tracks[1:])
        self.backend.playlists.set_dummy_playlists([playlist1, playlist2])

        self.send_request('listplaylistinfo "a [2]"')

        self.assertInResponse("file: dummy:c")
        self.assertNotInResponse("Track: 0")
        self.assertNotInResponse("Pos: 0")
        self.assertInResponse("OK") 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:18,代码来源:test_stored_playlists.py

示例14: test_load_with_range_loads_part_of_playlist

# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import Track [as 别名]
def test_load_with_range_loads_part_of_playlist(self):
        tracks = [
            Track(uri="dummy:a"),
            Track(uri="dummy:b"),
            Track(uri="dummy:c"),
            Track(uri="dummy:d"),
            Track(uri="dummy:e"),
        ]
        self.backend.library.dummy_library = tracks
        self.core.tracklist.add(uris=["dummy:a", "dummy:b"]).get()

        assert len(self.core.tracklist.get_tracks().get()) == 2
        self.backend.playlists.set_dummy_playlists(
            [Playlist(name="A-list", uri="dummy:A-list", tracks=tracks[2:])]
        )

        self.send_request('load "A-list" "1:2"')

        tracks = self.core.tracklist.get_tracks().get()
        assert 3 == len(tracks)
        assert "dummy:a" == tracks[0].uri
        assert "dummy:b" == tracks[1].uri
        assert "dummy:d" == tracks[2].uri
        self.assertInResponse("OK") 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:26,代码来源:test_stored_playlists.py

示例15: test_load_with_range_without_end_loads_rest_of_playlist

# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import Track [as 别名]
def test_load_with_range_without_end_loads_rest_of_playlist(self):
        tracks = [
            Track(uri="dummy:a"),
            Track(uri="dummy:b"),
            Track(uri="dummy:c"),
            Track(uri="dummy:d"),
            Track(uri="dummy:e"),
        ]
        self.backend.library.dummy_library = tracks
        self.core.tracklist.add(uris=["dummy:a", "dummy:b"]).get()

        assert len(self.core.tracklist.get_tracks().get()) == 2
        self.backend.playlists.set_dummy_playlists(
            [Playlist(name="A-list", uri="dummy:A-list", tracks=tracks[2:])]
        )

        self.send_request('load "A-list" "1:"')

        tracks = self.core.tracklist.get_tracks().get()
        assert 4 == len(tracks)
        assert "dummy:a" == tracks[0].uri
        assert "dummy:b" == tracks[1].uri
        assert "dummy:d" == tracks[2].uri
        assert "dummy:e" == tracks[3].uri
        self.assertInResponse("OK") 
开发者ID:mopidy,项目名称:mopidy-mpd,代码行数:27,代码来源:test_stored_playlists.py


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