Skip to content

Commit

Permalink
core: Make lookup() ignore tracks without URI
Browse files Browse the repository at this point in the history
  • Loading branch information
jodal committed Jan 1, 2016
1 parent 1972683 commit f7b3fc9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ Bug fix release.
- MPD: Don't return tracks with empty URIs. (Partly fixes: :issue:`1340`, PR:
:issue:`1343`)

- Core: Make :meth:`~mopidy.core.LibraryController.lookup` ignore tracks with
empty URIs. (Partly fixes: :issue:`1340`)


v1.1.1 (2015-09-14)
===================
Expand Down
2 changes: 1 addition & 1 deletion mopidy/core/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def lookup(self, uri=None, uris=None):
result = future.get()
if result is not None:
validation.check_instances(result, models.Track)
results[u] = result
results[u] = [r for r in result if r.uri]

if uri:
return results[uri]
Expand Down
13 changes: 11 additions & 2 deletions tests/core/test_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ def test_lookup_fails_with_uri_and_uris_set(self):
self.core.library.lookup('dummy1:a', ['dummy2:a'])

def test_lookup_can_handle_uris(self):
track1 = Track(name='abc')
track2 = Track(name='def')
track1 = Track(uri='dummy1:a', name='abc')
track2 = Track(uri='dummy2:a', name='def')

self.library1.lookup().get.return_value = [track1]
self.library2.lookup().get.return_value = [track2]
Expand All @@ -169,6 +169,15 @@ def test_lookup_uris_returns_empty_list_for_dummy3_track(self):
self.assertFalse(self.library1.lookup.called)
self.assertFalse(self.library2.lookup.called)

def test_lookup_ignores_tracks_without_uri_set(self):
track1 = Track(uri='dummy1:a', name='abc')
track2 = Track()

self.library1.lookup().get.return_value = [track1, track2]

result = self.core.library.lookup(uris=['dummy1:a'])
self.assertEqual(result, {'dummy1:a': [track1]})

def test_refresh_with_uri_selects_dummy1_backend(self):
self.core.library.refresh('dummy1:a')

Expand Down

0 comments on commit f7b3fc9

Please sign in to comment.