-
Notifications
You must be signed in to change notification settings - Fork 129
Expand file tree
/
Copy pathtest_genres.py
More file actions
58 lines (47 loc) · 2.08 KB
/
test_genres.py
File metadata and controls
58 lines (47 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Copyright (C) 2023- The Tidalapi Developers
# Copyright (C) 2019-2020 morguldir
# Copyright (C) 2014 Thomas Amland
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from io import BytesIO
import pytest
from PIL import Image
import tidalapi
def test_get_genres(session):
genres = list(session.genre.get_genres())
assert "Jazz" in [genre.name for genre in genres]
def test_get_items(session):
genres = session.genre.get_genres()
first_genre = genres[0]
# Note: Some (all?) genres appear to have albums, tracks but the endpoint is invalid, resulting in an error. Why?
# if first_genre.albums:
# genres[0].items(tidalapi.Album)
# if first_genre.tracks:
# genres[0].items(tidalapi.Track)
if first_genre.artists:
genres[0].items(tidalapi.Artist)
if first_genre.videos:
genres[0].items(tidalapi.Video)
if first_genre.playlists:
genres[0].items(tidalapi.Playlist)
def test_get_electronic_items(session):
genres = list(session.genre.get_genres())
electronic = [genre for genre in genres if genre.path == "Electronic"][0]
electronic_items = electronic.items(tidalapi.Playlist)
assert "Electronic: RISING" in [playlist.name for playlist in electronic_items]
def test_image(session):
genres = session.genre.get_genres()
electronic = [genre for genre in genres if genre.path == "Electronic"][0]
image = session.request_session.get(electronic.image).content
assert Image.open(BytesIO(image)).size == (460, 306)