def test_equality(self): a = Lyrics(self.id, self.lyrics, self.full_lyrics, self.has_rights, self.text_language, self.show_translation) b = Lyrics(self.id, self.lyrics, '', self.has_rights, self.text_language, False) c = Lyrics(10, self.lyrics, self.full_lyrics, self.has_rights, '', self.show_translation) d = Lyrics(self.id, self.lyrics, self.full_lyrics, self.has_rights, self.text_language, self.show_translation) assert a != b != c assert hash(a) != hash(b) != hash(c) assert a is not b is not c assert a == d
def lyrics(): return Lyrics( TestLyrics.id, TestLyrics.lyrics, TestLyrics.full_lyrics, TestLyrics.has_rights, TestLyrics.show_translation, TestLyrics.text_language, TestLyrics.url, )
def test_de_json_all(self, client): json_dict = {'id_': self.id, 'lyrics': self.lyrics, 'full_lyrics': self.full_lyrics, 'has_rights': self.has_rights, 'text_language': self.text_language, 'show_translation': self.show_translation} lyrics = Lyrics.de_json(json_dict, client) assert lyrics.id == self.id assert lyrics.lyrics == self.lyrics assert lyrics.full_lyrics == self.full_lyrics assert lyrics.has_rights == self.has_rights assert lyrics.text_language == self.text_language assert lyrics.show_translation == self.show_translation
def test_de_json_required(self, client): json_dict = { 'id_': self.id, 'lyrics': self.lyrics, 'full_lyrics': self.full_lyrics, 'has_rights': self.has_rights, 'show_translation': self.show_translation, } lyrics = Lyrics.de_json(json_dict, client) assert lyrics.id == self.id assert lyrics.lyrics == self.lyrics assert lyrics.full_lyrics == self.full_lyrics assert lyrics.has_rights == self.has_rights assert lyrics.show_translation == self.show_translation
def de_json(cls, data: dict, client: 'Client') -> Optional['Supplement']: """Десериализация объекта. Args: data (:obj:`dict`): Поля и значения десериализуемого объекта. client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music. Returns: :obj:`yandex_music.Supplement`: Дополнительная информация о треке. """ if not data: return None data = super(Supplement, cls).de_json(data, client) from yandex_music import Lyrics, VideoSupplement data['lyrics'] = Lyrics.de_json(data.get('lyrics'), client) data['videos'] = VideoSupplement.de_list(data.get('videos'), 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.Supplement`: Объект класса :class:`yandex_music.Supplement`. """ if not data: return None data = super(Supplement, cls).de_json(data, client) from yandex_music import Lyrics, VideoSupplement data['lyrics'] = Lyrics.de_json(data.get('lyrics'), client) data['videos'] = VideoSupplement.de_list(data.get('videos'), client) return cls(client=client, **data)
def test_de_json_none(self, client): assert Lyrics.de_json({}, client) is None