本文整理匯總了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")
示例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")
示例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")
示例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")
示例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")
示例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")
示例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")
示例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")
示例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")
示例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
示例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")
示例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")
示例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")
示例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")
示例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")