def test_equality(self): a = Title(self.title, self.full_title) b = Title('') c = Title(self.title, self.full_title) assert a != b assert hash(a) != hash(b) assert a is not b assert a == c
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 title(): return Title(TestTitle.title, TestTitle.full_title)
def test_de_json_all(self, client): json_dict = {'title': self.title, 'full_title': self.full_title} title = Title.de_json(json_dict, client) assert title.title == self.title assert title.full_title == self.full_title
def test_de_json_required(self, client): json_dict = {'title': self.title} title = Title.de_json(json_dict, client) assert title.title == self.title
def test_de_json_none(self, client): assert Title.de_json({}, client) is None