def de_json(cls, data: dict, client: 'Client') -> Optional['Track']: """Десериализация объекта. Args: data (:obj:`dict`): Поля и значения десериализуемого объекта. client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music. Returns: :obj:`yandex_music.Track`: Трек. """ if not data: return None data = super(Track, cls).de_json(data, client) from yandex_music import Normalization, Major, Album, Artist, User, MetaData, PoetryLoverMatch data['albums'] = Album.de_list(data.get('albums'), client) data['artists'] = Artist.de_list(data.get('artists'), client) data['normalization'] = Normalization.de_json( data.get('normalization'), client) data['major'] = Major.de_json(data.get('major'), client) data['substituted'] = Track.de_json(data.get('substituted'), client) data['matched_track'] = Track.de_json(data.get('matched_track'), client) data['user_info'] = User.de_json(data.get('user_info'), client) data['meta_data'] = MetaData.de_json(data.get('meta_data'), client) data['poetry_lover_matches'] = PoetryLoverMatch.de_list( data.get('poetry_lover_matches'), client) return cls(client=client, **data)
def de_json(cls, data, client): if not data: return None data = super(Track, cls).de_json(data, client) from yandex_music import Normalization, Major data['normalization'] = Normalization.de_json(data.get('normalization'), client) data['major'] = Major.de_json(data.get('major'), client) return cls(client=client, **data)
def de_json(cls, data, client): if not data: return None data = super(Track, cls).de_json(data, client) from yandex_music import Normalization, Major, Album, Artist data['albums'] = Album.de_list(data.get('albums'), client) data['artists'] = Artist.de_list(data.get('artists'), client) data['normalization'] = Normalization.de_json( data.get('normalization'), client) data['major'] = Major.de_json(data.get('major'), client) return cls(client=client, **data)
def de_json(cls, data: dict, client: 'Client') -> Optional['Track']: """Десериализация объекта. Args: data (:obj:`dict`): Поля и значения десериализуемого объекта. client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music. Returns: :obj:`yandex_music.Track`: Трек. """ if not data: return None data = super(Track, cls).de_json(data, client) from yandex_music import Normalization, Major, Album, Artist data['albums'] = Album.de_list(data.get('albums'), client) data['artists'] = Artist.de_list(data.get('artists'), client) data['normalization'] = Normalization.de_json( data.get('normalization'), client) data['major'] = Major.de_json(data.get('major'), 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.Track`: Объект класса :class:`yandex_music.Track`. """ if not data: return None data = super(Track, cls).de_json(data, client) from yandex_music import Normalization, Major, Album, Artist data['albums'] = Album.de_list(data.get('albums'), client) data['artists'] = Artist.de_list(data.get('artists'), client) data['normalization'] = Normalization.de_json( data.get('normalization'), client) data['major'] = Major.de_json(data.get('major'), client) return cls(client=client, **data)
def test_de_json_all(self, client): json_dict = {'gain': self.gain, 'peak': self.peak} normalization = Normalization.de_json(json_dict, client) assert normalization.gain == self.gain assert normalization.peak == self.peak
def test_de_json_none(self, client): assert Normalization.de_json({}, client) is None