def de_json(cls, data: dict, client: 'Client') -> Optional['Genre']: if not data: return None data = super(Genre, cls).de_json(data, client) from yandex_music import Title, Icon, Images data['titles'] = Title.de_dict(data.get('titles'), client) data['images'] = Images.de_json(data.get('images'), client) data['radio_icon'] = Icon.de_json(data.get('radio_icon'), client) data['sub_genres'] = Genre.de_list(data.get('sub_genres'), client) return cls(client=client, **data)
def de_json(cls, data: dict, client: 'Client') -> Optional['Genre']: """Десериализация объекта. Args: data (:obj:`dict`): Поля и значения десериализуемого объекта. client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music. Returns: :obj:`yandex_music.Genre`: Жанр музыки. """ if not data: return None data = super(Genre, cls).de_json(data, client) from yandex_music import Title, Icon, Images data['titles'] = Title.de_dict(data.get('titles'), client) data['images'] = Images.de_json(data.get('images'), client) data['radio_icon'] = Icon.de_json(data.get('radio_icon'), client) data['sub_genres'] = Genre.de_list(data.get('sub_genres'), 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.Genre`: Объект класса :class:`yandex_music.Genre`. """ if not data: return None data = super(Genre, cls).de_json(data, client) from yandex_music import Title, Icon, Images data['titles'] = Title.de_dict(data.get('titles'), client) data['images'] = Images.de_json(data.get('images'), client) data['radio_icon'] = Icon.de_json(data.get('radio_icon'), client) data['sub_genres'] = Genre.de_list(data.get('sub_genres'), client) return cls(client=client, **data)
def images(): return Images(TestImages._208x208, TestImages._300x300)
def test_equality(self): a = Images(self._208x208, self._300x300) b = Images(self._208x208, self._300x300) assert a == b
def test_de_json_all(self, client): json_dict = {'_208x208': self._208x208, '_300x300': self._300x300} images = Images.de_json(json_dict, client) assert images._208x208 == self._208x208 assert images._300x300 == self._300x300
def test_de_json_required(self, client): json_dict = {} images = Images.de_json(json_dict, client)
def test_de_json_none(self, client): assert Images.de_json({}, client) is None