Skip to content

Commit

Permalink
library: Remove find_exact(), add exact to search()
Browse files Browse the repository at this point in the history
  • Loading branch information
jodal committed Mar 24, 2015
1 parent 27227ce commit 3974ce7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 2 additions & 4 deletions mopidy_spotify/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,9 @@ def _lookup_playlist(self, sp_link):
if track is not None:
yield track

def search(self, query=None, uris=None):
def search(self, query=None, uris=None, exact=False):
# TODO Respect `uris` argument
# TODO Support `exact` search

if query is None:
logger.debug('Ignored search without query')
Expand Down Expand Up @@ -261,6 +262,3 @@ def _search_by_uri(self, query):
uri = query['uri'][0]

return models.SearchResult(uri=uri, tracks=tracks)

# Spotify doesn't support exact search
find_exact = search
9 changes: 7 additions & 2 deletions tests/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,10 @@ def test_search_returns_albums_and_artists_and_tracks(
assert result.tracks[0].uri == 'spotify:track:abc'


def test_find_exact_is_the_same_as_search(provider):
assert provider.find_exact == provider.search
def test_exact_is_ignored(session_mock, sp_track_mock, provider):
session_mock.get_link.return_value = sp_track_mock.link

result1 = provider.search({'uri': ['spotify:track:abc']})
result2 = provider.search({'uri': ['spotify:track:abc']}, exact=True)

assert result1 == result2

0 comments on commit 3974ce7

Please sign in to comment.