Skip to content

Commit

Permalink
Release v2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jodal committed Nov 15, 2015
2 parents 448e90a + 7968b7c commit 7903253
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 42 deletions.
17 changes: 15 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ Dependencies
The package is available as ``libspotify12`` from
`apt.mopidy.com <http://apt.mopidy.com/>`__.

- ``pyspotify`` >= 2.0. The ``libspotify`` python wrapper. The package is
- ``pyspotify`` >= 2.0. The ``libspotify`` Python wrapper. The package is
available as ``python-spotify`` from apt.mopidy.com or ``pyspotify`` on PyPI.
See https://pyspotify.mopidy.com/en/latest/installation/ for how to install
it and its dependencies on most platforms.

- ``Mopidy`` >= 1.1. The music server that Mopidy-Spotify extends.

Expand Down Expand Up @@ -133,12 +135,23 @@ Project resources

- `Source code <https://github.com/mopidy/mopidy-spotify>`_
- `Issue tracker <https://github.com/mopidy/mopidy-spotify/issues>`_
- `Download development snapshot <https://github.com/mopidy/mopidy-spotify/tarball/develop#egg=Mopidy-Spotify-dev>`_


Changelog
=========

v2.2.0 (2015-11-15)
-------------------

Feature release.

- As Spotify now exposes your "Starred" playlist as a regular playlist, we no
longer get your "Starred" playlist through the dedicated "Starred" API. This
avoids your "Starred" playlist being returned twice. Lookup of
``spotify:user:<username>:starred`` URIs works as before. (Fixes: #71)

- Interpret album year "0" as unknown. (Fixes: #72)

v2.1.0 (2015-09-22)
-------------------

Expand Down
2 changes: 1 addition & 1 deletion mopidy_spotify/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from mopidy import config, ext


__version__ = '2.1.0'
__version__ = '2.2.0'


class Extension(ext.Extension):
Expand Down
23 changes: 1 addition & 22 deletions mopidy_spotify/playlists.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,7 @@ def __init__(self, backend):

def as_list(self):
with utils.time_logger('playlists.as_list()'):
return (
list(self._get_starred_playlist_ref()) +
list(self._get_flattened_playlist_refs()))

def _get_starred_playlist_ref(self):
if self._backend._session is None:
return

sp_starred = self._backend._session.get_starred()
if sp_starred is None:
return

if (
self._backend._session.connection.state is
spotify.ConnectionState.LOGGED_IN):
sp_starred.load()

starred_ref = translator.to_playlist_ref(
sp_starred, username=self._backend._session.user_name)

if starred_ref is not None:
yield starred_ref
return list(self._get_flattened_playlist_refs())

def _get_flattened_playlist_refs(self):
if self._backend._session is None:
Expand Down
2 changes: 1 addition & 1 deletion mopidy_spotify/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def to_album(sp_album):
else:
artists = []

if sp_album.year is not None:
if sp_album.year is not None and sp_album.year != 0:
date = '%d' % sp_album.year
else:
date = None
Expand Down
23 changes: 7 additions & 16 deletions tests/test_playlists.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
def session_mock(
sp_playlist_mock,
sp_playlist_folder_start_mock, sp_playlist_folder_end_mock,
sp_user_mock, sp_starred_mock):
sp_user_mock):

sp_playlist2_mock = mock.Mock(spec=spotify.Playlist)
sp_playlist2_mock.is_loaded = True
Expand All @@ -32,7 +32,6 @@ def session_mock(
sp_session_mock = mock.Mock(spec=spotify.Session)
sp_session_mock.user = sp_user_mock
sp_session_mock.user_name = 'alice'
sp_session_mock.get_starred.return_value = sp_starred_mock
sp_session_mock.playlist_container = [
sp_playlist_mock,
sp_playlist_folder_start_mock,
Expand Down Expand Up @@ -62,45 +61,37 @@ def test_is_a_playlists_provider(provider):

def test_as_list_when_not_logged_in(
session_mock, provider):
session_mock.get_starred.return_value = None
session_mock.playlist_container = None

result = provider.as_list()

assert len(result) == 0


def test_as_list_when_offline(session_mock, sp_starred_mock, provider):
def test_as_list_when_offline(session_mock, provider):
session_mock.connection.state = spotify.ConnectionState.OFFLINE

result = provider.as_list()

assert len(result) == 3
assert sp_starred_mock.load.call_count == 0
assert len(result) == 2


def test_as_list_when_playlist_container_isnt_loaded(
session_mock, provider):
def test_as_list_when_playlist_container_isnt_loaded(session_mock, provider):
session_mock.playlist_container = None

result = provider.as_list()

assert len(result) == 1

assert result[0] == Ref.playlist(
uri='spotify:user:alice:starred', name='Starred')
assert len(result) == 0


def test_as_list_with_folders_and_ignored_unloaded_playlist(provider):
result = provider.as_list()

assert len(result) == 3
assert len(result) == 2

assert result[0] == Ref.playlist(
uri='spotify:user:alice:starred', name='Starred')
assert result[1] == Ref.playlist(
uri='spotify:user:alice:playlist:foo', name='Foo')
assert result[2] == Ref.playlist(
assert result[1] == Ref.playlist(
uri='spotify:playlist:bob:baz', name='Bar/Baz (by bob)')


Expand Down
7 changes: 7 additions & 0 deletions tests/test_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ def test_returns_unknown_date_if_year_is_none(self, sp_album_mock):

assert album.date is None

def test_returns_unknown_date_if_year_is_zero(self, sp_album_mock):
sp_album_mock.year = 0

album = translator.to_album(sp_album_mock)

assert album.date is None

def test_caches_results(self, sp_album_mock):
album1 = translator.to_album(sp_album_mock)
album2 = translator.to_album(sp_album_mock)
Expand Down

0 comments on commit 7903253

Please sign in to comment.