當前位置: 首頁>>代碼示例>>Python>>正文


Python models.SearchResult方法代碼示例

本文整理匯總了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") 
開發者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 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") 
開發者ID:mopidy,項目名稱:mopidy-mpd,代碼行數:26,代碼來源:test_music_db.py

示例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") 
開發者ID:mopidy,項目名稱:mopidy-mpd,代碼行數:22,代碼來源:test_music_db.py

示例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") 
開發者ID:mopidy,項目名稱:mopidy-mpd,代碼行數:22,代碼來源:test_music_db.py

示例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") 
開發者ID:mopidy,項目名稱:mopidy-mpd,代碼行數:22,代碼來源:test_music_db.py

示例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") 
開發者ID:mopidy,項目名稱:mopidy-mpd,代碼行數:22,代碼來源:test_music_db.py

示例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") 
開發者ID:mopidy,項目名稱:mopidy-mpd,代碼行數:19,代碼來源:test_music_db.py

示例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:'])) 
開發者ID:mopidy,項目名稱:mopidy-local-sqlite,代碼行數:10,代碼來源:test_library.py

示例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) 
開發者ID:mopidy,項目名稱:mopidy-local-sqlite,代碼行數:11,代碼來源:library.py

示例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") 
開發者ID:mopidy,項目名稱:mopidy-mpd,代碼行數:10,代碼來源:test_music_db.py

示例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") 
開發者ID:mopidy,項目名稱:mopidy-mpd,代碼行數:15,代碼來源:test_music_db.py

示例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") 
開發者ID:mopidy,項目名稱:mopidy-mpd,代碼行數:13,代碼來源:test_music_db.py

示例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 
開發者ID:mopidy,項目名稱:mopidy-mpd,代碼行數:12,代碼來源:test_music_db.py

示例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 
開發者ID:mopidy,項目名稱:mopidy-mpd,代碼行數:15,代碼來源:test_music_db.py

示例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 
開發者ID:mopidy,項目名稱:mopidy-mpd,代碼行數:15,代碼來源:test_music_db.py


注:本文中的mopidy.models.SearchResult方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。