本文整理汇总了Python中mopidy.models.SearchResult方法的典型用法代码示例。如果您正苦于以下问题:Python models.SearchResult方法的具体用法?Python models.SearchResult怎么用?Python models.SearchResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mopidy.models
的用法示例。
在下文中一共展示了models.SearchResult方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_count_correct_length
# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import SearchResult [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 SearchResult [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_find_includes_fake_artist_and_album_tracks
# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import SearchResult [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")
示例4: test_find_artist_does_not_include_fake_artist_tracks
# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import SearchResult [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")
示例5: test_find_albumartist_does_not_include_fake_artist_tracks
# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import SearchResult [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")
示例6: test_find_artist_and_album_does_not_include_fake_tracks
# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import SearchResult [as 别名]
def test_find_artist_and_album_does_not_include_fake_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" "album" "bar"')
self.assertNotInResponse("file: dummy:artist:b")
self.assertNotInResponse("Title: Artist: B")
self.assertNotInResponse("file: dummy:album:a")
self.assertNotInResponse("Title: Album: A")
self.assertNotInResponse("Date: 2001")
self.assertInResponse("file: dummy:track:c")
self.assertInResponse("Title: C")
self.assertInResponse("OK")
示例7: test_search
# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import SearchResult [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")
示例8: test_search_uri
# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import SearchResult [as 别名]
def test_search_uri(self):
empty = SearchResult(uri='local:search?')
self.assertEqual(empty, self.library.search(uris=None))
self.assertEqual(empty, self.library.search(uris=[]))
self.assertEqual(empty, self.library.search(uris=['local:']))
self.assertEqual(empty, self.library.search(uris=['local:directory']))
self.assertEqual(empty, self.library.search(uris=['local:directory:']))
self.assertEqual(empty, self.library.search(uris=['foobar:']))
示例9: search
# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import SearchResult [as 别名]
def search(self, query=None, limit=100, offset=0, uris=None, exact=False):
q = []
for field, values in (query.items() if query else []):
q.extend((field, value) for value in values)
filters = [f for uri in uris or [] for f in self._filters(uri) if f]
with self._connect() as c:
tracks = schema.search_tracks(c, q, limit, offset, exact, filters)
uri = uritools.uricompose('local', path='search', query=q)
return SearchResult(uri=uri, tracks=tracks)
示例10: test_count_with_track_length_none
# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import SearchResult [as 别名]
def test_count_with_track_length_none(self):
self.backend.library.dummy_find_exact_result = SearchResult(
tracks=[Track(uri="dummy:b", date="2001", length=None)]
)
self.send_request('count "date" "2001"')
self.assertInResponse("songs: 1")
self.assertInResponse("playtime: 0")
self.assertInResponse("OK")
示例11: test_findadd
# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import SearchResult [as 别名]
def test_findadd(self):
track = Track(uri="dummy:a", name="A")
self.backend.library.dummy_library = [track]
self.backend.library.dummy_find_exact_result = SearchResult(
tracks=[track]
)
assert self.core.tracklist.get_length().get() == 0
self.send_request('findadd "title" "A"')
assert self.core.tracklist.get_length().get() == 1
assert self.core.tracklist.get_tracks().get()[0].uri == "dummy:a"
self.assertInResponse("OK")
示例12: test_searchadd
# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import SearchResult [as 别名]
def test_searchadd(self):
track = Track(uri="dummy:a", name="A")
self.backend.library.dummy_library = [track]
self.backend.library.dummy_search_result = SearchResult(tracks=[track])
assert self.core.tracklist.get_length().get() == 0
self.send_request('searchadd "title" "a"')
assert self.core.tracklist.get_length().get() == 1
assert self.core.tracklist.get_tracks().get()[0].uri == "dummy:a"
self.assertInResponse("OK")
示例13: test_list_artist_should_not_return_artists_without_names
# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import SearchResult [as 别名]
def test_list_artist_should_not_return_artists_without_names(self):
self.backend.library.dummy_find_exact_result = SearchResult(
tracks=[Track(artists=[Artist(name="")])]
)
self.send_request('list "artist"')
self.assertNotInResponse("Artist: ")
self.assertInResponse("OK")
# Albumartist
示例14: test_list_composer_should_not_return_artists_without_names
# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import SearchResult [as 别名]
def test_list_composer_should_not_return_artists_without_names(self):
self.backend.library.dummy_find_exact_result = SearchResult(
tracks=[Track(composers=[Artist(name="")])]
)
self.send_request('list "composer"')
self.assertNotInResponse("Artist: ")
self.assertNotInResponse("Albumartist: ")
self.assertNotInResponse("Composer: ")
self.assertNotInResponse("Performer: ")
self.assertInResponse("OK")
# Performer
示例15: test_list_performer_should_not_return_artists_without_names
# 需要导入模块: from mopidy import models [as 别名]
# 或者: from mopidy.models import SearchResult [as 别名]
def test_list_performer_should_not_return_artists_without_names(self):
self.backend.library.dummy_find_exact_result = SearchResult(
tracks=[Track(performers=[Artist(name="")])]
)
self.send_request('list "performer"')
self.assertNotInResponse("Artist: ")
self.assertNotInResponse("Albumartist: ")
self.assertNotInResponse("Composer: ")
self.assertNotInResponse("Performer: ")
self.assertInResponse("OK")
# Album