Все поля кроме id у класса Album теперь опциональны в связи с тем, чт…
このコミットが含まれているのは:
コミット
7b1631ca08
|
@ -80,7 +80,7 @@ def track_without_artists_and_albums(track_factory):
|
|||
def album_factory(label, track_position):
|
||||
class AlbumFactory:
|
||||
def get(self, artists, volumes):
|
||||
return Album(TestAlbum.id, TestAlbum.title, TestAlbum.track_count, artists, [label],
|
||||
return Album(TestAlbum.id, TestAlbum.error, TestAlbum.title, TestAlbum.track_count, artists, [label],
|
||||
TestAlbum.available, TestAlbum.available_for_premium_users, TestAlbum.version,
|
||||
TestAlbum.cover_uri, TestAlbum.content_warning, TestAlbum.original_release_year,
|
||||
TestAlbum.genre, TestAlbum.og_image, TestAlbum.buy, TestAlbum.recent, TestAlbum.very_important,
|
||||
|
|
|
@ -3,6 +3,7 @@ from yandex_music import Album
|
|||
|
||||
class TestAlbum:
|
||||
id = 5239478
|
||||
error = 'not-found'
|
||||
title = 'In the End'
|
||||
version = 'feat. Mark Van Hoen & Mike Harding'
|
||||
cover_uri = 'avatars.yandex.net/get-music-content/95061/89c14a7d.a.5239478-1/%%'
|
||||
|
@ -27,6 +28,7 @@ class TestAlbum:
|
|||
|
||||
def test_expected_values(self, album, artist_without_tracks, label, track_position, track_without_albums):
|
||||
assert album.id == self.id
|
||||
assert album.error == self.error
|
||||
assert album.title == self.title
|
||||
assert album.version == self.version
|
||||
assert album.cover_uri == self.cover_uri
|
||||
|
@ -59,35 +61,26 @@ class TestAlbum:
|
|||
def test_de_list_none(self, client):
|
||||
assert Album.de_list({}, client) == []
|
||||
|
||||
def test_de_json_required(self, client, artist, label):
|
||||
json_dict = {'id_': self.id, 'title': self.title, 'cover_uri': self.cover_uri, 'track_count': self.track_count,
|
||||
'artists': [artist.to_dict()], 'labels': [label.to_dict()],
|
||||
'available': self.available, 'available_for_premium_users': self.available_for_premium_users}
|
||||
def test_de_json_required(self, client):
|
||||
json_dict = {'id_': self.id}
|
||||
album = Album.de_json(json_dict, client)
|
||||
|
||||
assert album.id == self.id
|
||||
assert album.title == self.title
|
||||
assert album.cover_uri == self.cover_uri
|
||||
assert album.track_count == self.track_count
|
||||
assert album.artists == [artist]
|
||||
assert album.labels == [label]
|
||||
assert album.available == self.available
|
||||
assert album.available_for_premium_users == self.available_for_premium_users
|
||||
|
||||
def test_de_json_all(self, client, artist, label, track_position, track):
|
||||
json_dict = {'id_': self.id, 'title': self.title, 'cover_uri': self.cover_uri, 'track_count': self.track_count,
|
||||
'artists': [artist.to_dict()], 'labels': [label.to_dict()], 'available': self.available,
|
||||
'available_for_premium_users': self.available_for_premium_users, 'version': self.version,
|
||||
'content_warning': self.content_warning, 'original_release_year': self.original_release_year,
|
||||
'genre': self.genre, 'og_image': self.og_image, 'buy': self.buy, 'recent': self.recent,
|
||||
'very_important': self.very_important, 'available_for_mobile': self.available_for_mobile,
|
||||
'available_partially': self.available_partially, 'bests': self.bests, 'prerolls': self.prerolls,
|
||||
'volumes': [[track.to_dict()]], 'year': self.year,
|
||||
'release_date': self.release_date,
|
||||
'type_': self.type, 'track_position': track_position.to_dict(), 'regions': self.regions}
|
||||
json_dict = {'id_': self.id, 'error': self.error, 'title': self.title, 'cover_uri': self.cover_uri,
|
||||
'track_count': self.track_count, 'artists': [artist.to_dict()], 'labels': [label.to_dict()],
|
||||
'available': self.available, 'available_for_premium_users': self.available_for_premium_users,
|
||||
'version': self.version, 'content_warning': self.content_warning, 'regions': self.regions,
|
||||
'original_release_year': self.original_release_year, 'genre': self.genre, 'buy': self.buy,
|
||||
'og_image': self.og_image, 'recent': self.recent, 'very_important': self.very_important,
|
||||
'available_for_mobile': self.available_for_mobile, 'available_partially': self.available_partially,
|
||||
'bests': self.bests, 'prerolls': self.prerolls, 'volumes': [[track.to_dict()]], 'year': self.year,
|
||||
'release_date': self.release_date, 'type_': self.type, 'track_position': track_position.to_dict()}
|
||||
album = Album.de_json(json_dict, client)
|
||||
|
||||
assert album.id == self.id
|
||||
assert album.error == self.error
|
||||
assert album.title == self.title
|
||||
assert album.version == self.version
|
||||
assert album.cover_uri == self.cover_uri
|
||||
|
@ -115,11 +108,9 @@ class TestAlbum:
|
|||
assert album.regions == self.regions
|
||||
|
||||
def test_equality(self, artist, label):
|
||||
a = Album(self.id, self.title, self.track_count, [artist], [label], self.available,
|
||||
self.available_for_premium_users)
|
||||
b = Album(10, '', 99, [artist], [label], self.available, self.available_for_premium_users)
|
||||
c = Album(self.id, self.title, self.track_count, [artist], [label], self.available,
|
||||
self.available_for_premium_users)
|
||||
a = Album(self.id)
|
||||
b = Album(10)
|
||||
c = Album(self.id)
|
||||
|
||||
assert a != b
|
||||
assert hash(a) != hash(b)
|
||||
|
|
|
@ -9,12 +9,13 @@ from yandex_music import YandexMusicObject
|
|||
class Album(YandexMusicObject):
|
||||
def __init__(self,
|
||||
id_: int,
|
||||
title: str,
|
||||
track_count: int,
|
||||
artists: List['Artist'],
|
||||
labels: List['Label'],
|
||||
available: bool,
|
||||
available_for_premium_users: bool,
|
||||
error: Optional[str] = None,
|
||||
title: Optional[str] = None,
|
||||
track_count: Optional[int] = None,
|
||||
artists: List['Artist'] = None,
|
||||
labels: List['Label'] = None,
|
||||
available: Optional[bool] = None,
|
||||
available_for_premium_users: Optional[bool] = None,
|
||||
version: Optional[str] = None,
|
||||
cover_uri: Optional[str] = None,
|
||||
content_warning=None,
|
||||
|
@ -28,7 +29,7 @@ class Album(YandexMusicObject):
|
|||
available_partially: Optional[bool] = None,
|
||||
bests: Optional[List[int]] = None,
|
||||
prerolls: Optional[list] = None,
|
||||
volumes: List['Track'] = None,
|
||||
volumes: Optional[List['Track']] = None,
|
||||
year: Optional[int] = None,
|
||||
release_date: Optional[str] = None,
|
||||
type_: Optional[str] = None,
|
||||
|
@ -37,13 +38,14 @@ class Album(YandexMusicObject):
|
|||
client: Optional['Client'] = None,
|
||||
**kwargs) -> None:
|
||||
self.id = id_
|
||||
|
||||
self.error = error
|
||||
self.title = title
|
||||
self.track_count = track_count
|
||||
self.artists = artists
|
||||
self.labels = labels
|
||||
self.available_for_premium_users = available_for_premium_users
|
||||
self.available = available
|
||||
|
||||
self.version = version
|
||||
self.cover_uri = cover_uri
|
||||
self.genre = genre
|
||||
|
@ -65,8 +67,7 @@ class Album(YandexMusicObject):
|
|||
self.content_warning = content_warning
|
||||
|
||||
self.client = client
|
||||
self._id_attrs = (self.id, self.title, self.track_count, self.artists, self.labels,
|
||||
self.available_for_premium_users, self.available)
|
||||
self._id_attrs = (self.id,)
|
||||
|
||||
def with_tracks(self, *args, **kwargs) -> Optional['Album']:
|
||||
"""Сокращение для::
|
||||
|
|
読み込み中…
新しいイシューから参照