def test_equality(self): a = PlaylistId(self.uid, self.kind) b = PlaylistId(self.uid, 10) c = PlaylistId(10, self.kind) d = PlaylistId(self.uid, self.kind) assert a != b != c assert hash(a) != hash(b) != hash(c) assert a is not b is not c assert a == d
def de_json(cls, data: dict, client: 'Client') -> Optional['BriefInfo']: """Десериализация объекта. Args: data (:obj:`dict`): Поля и значения десериализуемого объекта. client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music. Returns: :obj:`yandex_music.BriefInfo`: Информация об артисте. """ if not data: return None data = super(BriefInfo, cls).de_json(data, client) from yandex_music import Artist, Track, Album, Cover, PlaylistId, Video, Chart, Vinyl, Playlist data['playlists'] = Playlist.de_list(data.get('playlists'), client) data['artist'] = Artist.de_json(data.get('artist'), client) data['similar_artists'] = Artist.de_list(data.get('similar_artists'), client) data['popular_tracks'] = Track.de_list(data.get('popular_tracks'), client) data['albums'] = Album.de_list(data.get('albums'), client) data['also_albums'] = Album.de_list(data.get('also_albums'), client) data['last_releases'] = Album.de_list(data.get('last_releases'), client) data['all_covers'] = Cover.de_list(data.get('all_covers'), client) data['playlist_ids'] = PlaylistId.de_list(data.get('playlist_ids'), client) data['videos'] = Video.de_list(data.get('videos'), client) data['tracks_in_chart'] = Chart.de_list(data.get('tracks_in_chart'), client) data['vinyls'] = Vinyl.de_list(data.get('vinyls'), client) return cls(client=client, **data)
def de_json(cls, data, client): """Десериализация объекта. Args: data (:obj:`dict`): Поля и значения десериализуемого объекта. client (:obj:`yandex_music.Client`): Объект класса :class:`yandex_music.Client` представляющий клиент Yandex Music. Returns: :obj:`yandex_music.BriefInfo`: Объект класса :class:`yandex_music.BriefInfo`. """ if not data: return None data = super(BriefInfo, cls).de_json(data, client) from yandex_music import Artist, Track, Album, Cover, PlaylistId, Video, Chart, Vinyl data['artist'] = Artist.de_json(data.get('artist'), client) data['popular_tracks'] = Track.de_list(data.get('popular_tracks'), client) data['albums'] = Album.de_list(data.get('albums'), client) data['also_albums'] = Album.de_list(data.get('also_albums'), client) data['all_covers'] = Cover.de_list(data.get('all_covers'), client) data['playlist_ids'] = PlaylistId.de_list(data.get('playlist_ids'), client) data['videos'] = Video.de_list(data.get('videos'), client) data['tracks_in_chart'] = Chart.de_list(data.get('tracks_in_chart'), client) data['vinyls'] = Vinyl.de_list(data.get('vinyls'), client) return cls(client=client, **data)
def de_json(cls, data, client): """Десериализация объекта. Args: data (:obj:`dict`): Поля и значения десериализуемого объекта. client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music. Returns: :obj:`yandex_music.TagResult`: Тег и его плейлисты. """ if not data: return None data = super(TagResult, cls).de_json(data, client) from yandex_music import Tag, PlaylistId data['tag'] = Tag.de_json(data.get('tag'), client) data['ids'] = PlaylistId.de_list(data.get('ids'), client) return cls(client=client, **data)
def de_json(cls, data: dict, client: 'Client') -> Optional['Chart']: """Десериализация объекта. Args: data (:obj:`dict`): Поля и значения десериализуемого объекта. client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music. Returns: :obj:`yandex_music.LandingList`: Список объектов лендинга. """ if not data: return None data = super(LandingList, cls).de_json(data, client) from yandex_music import PlaylistId data['new_playlists'] = PlaylistId.de_list(data.get('new_playlists'), client) return cls(client=client, **data)
def playlist_id(): return PlaylistId(TestPlaylistId.uid, TestPlaylistId.kind)
def test_de_json_all(self, client): json_dict = {'uid': self.uid, 'kind': self.kind} playlist_id = PlaylistId.de_json(json_dict, client) assert playlist_id.uid == self.uid assert playlist_id.kind == self.kind
def test_de_list_none(self, client): assert PlaylistId.de_list({}, client) == []
def test_de_json_none(self, client): assert PlaylistId.de_json({}, client) is None