Fix #936: Support byYear filtering in Subsonic API (#936)

This commit is contained in:
Eliot Berriot 2019-10-15 11:38:21 +02:00
commit b1e8d4cabd
No known key found for this signature in database
GPG key ID: 6B501DFD73514E14
3 changed files with 60 additions and 0 deletions

View file

@ -469,6 +469,35 @@ def test_get_album_list2_by_genre(f, db, logged_in_api_client, factories):
}
@pytest.mark.parametrize(
"params, expected",
[
({"type": "byYear", "fromYear": 1902, "toYear": 1903}, [2, 3]),
# Because why not, it's supported in Subsonic API…
# http://www.subsonic.org/pages/api.jsp#getAlbumList2
({"type": "byYear", "fromYear": 1903, "toYear": 1902}, [3, 2]),
],
)
def test_get_album_list2_by_year(params, expected, db, logged_in_api_client, factories):
albums = [
factories["music.Album"](
playable=True, release_date=datetime.date(1900 + i, 1, 1)
)
for i in range(5)
]
url = reverse("api:subsonic-get_album_list2")
base_params = {"f": "json"}
base_params.update(params)
response = logged_in_api_client.get(url, base_params)
assert response.status_code == 200
assert response.data == {
"albumList2": {
"album": serializers.get_album_list2_data([albums[i] for i in expected])
}
}
@pytest.mark.parametrize("f", ["json"])
@pytest.mark.parametrize(
"tags_field",