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.Station`: Объект класса :class:`yandex_music.Station`. """ if not data: return None data = super(Station, cls).de_json(data, client) from yandex_music import Id, Icon, Restrictions data['id_'] = Id.de_json(data.get('id_'), client) data['parent_id'] = Id.de_json(data.get('parent_id'), client) data['icon'] = Icon.de_json(data.get('icon'), client) data['mts_icon'] = Icon.de_json(data.get('mts_icon'), client) data['geocell_icon'] = Icon.de_json(data.get('geocell_icon'), client) data['restrictions'] = Restrictions.de_json(data.get('restrictions'), client) data['restrictions2'] = Restrictions.de_json(data.get('restrictions2'), client) return cls(client=client, **data)
def de_json(cls, data: dict, client: 'Client') -> Optional['Station']: """Десериализация объекта. Args: data (:obj:`dict`): Поля и значения десериализуемого объекта. client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music. Returns: :obj:`yandex_music.Station`: Станция. """ if not data: return None data = super(Station, cls).de_json(data, client) from yandex_music import Id, Icon, Restrictions data['id_'] = Id.de_json(data.get('id_'), client) data['parent_id'] = Id.de_json(data.get('parent_id'), client) data['icon'] = Icon.de_json(data.get('icon'), client) data['mts_icon'] = Icon.de_json(data.get('mts_icon'), client) data['geocell_icon'] = Icon.de_json(data.get('geocell_icon'), client) data['restrictions'] = Restrictions.de_json(data.get('restrictions'), client) data['restrictions2'] = Restrictions.de_json(data.get('restrictions2'), client) return cls(client=client, **data)
def de_json(cls, data, client): if not data: return None data = super(Station, cls).de_json(data, client) from yandex_music import Id, Icon, Restrictions data['id'] = Id.de_json(data.get('id'), client) data['parent_id'] = Id.de_json(data.get('parent_id'), client) data['icon'] = Icon.de_json(data.get('icon'), client) data['mts_icon'] = Icon.de_json(data.get('mts_icon'), client) data['geocell_icon'] = Icon.de_json(data.get('geocell_icon'), client) data['restrictions'] = Restrictions.de_json(data.get('restrictions'), client) data['restrictions2'] = Restrictions.de_json(data.get('restrictions2'), client) return cls(client=client, **data)
def test_de_json_all(self, client, enum, discrete_scale): json_dict = {'language': enum.to_dict(), 'diversity': enum.to_dict(), 'mood': discrete_scale.to_dict(), 'energy': discrete_scale.to_dict(), 'mood_energy': enum.to_dict()} restrictions = Restrictions.de_json(json_dict, client) assert restrictions.language == enum assert restrictions.diversity == enum assert restrictions.mood == discrete_scale assert restrictions.energy == discrete_scale assert restrictions.mood_energy == enum
def test_de_json_required(self, client, enum): json_dict = {'language': enum.to_dict(), 'diversity': enum.to_dict()} restrictions = Restrictions.de_json(json_dict, client) assert restrictions.language == enum assert restrictions.diversity == enum
def test_de_json_none(self, client): assert Restrictions.de_json({}, client) is None