def test_equality(self): a = VideoSupplement(self.cover, self.title, self.provider, self.provider_video_id) b = VideoSupplement(self.cover, '', self.provider, self.provider_video_id) c = VideoSupplement(self.cover, self.title, self.provider, self.provider_video_id) assert a != b assert hash(a) != hash(b) assert a is not b assert a == c
def video_supplement(): return VideoSupplement( TestVideoSupplement.cover, TestVideoSupplement.provider, TestVideoSupplement.title, TestVideoSupplement.provider_video_id, TestVideoSupplement.url, TestVideoSupplement.embed_url, TestVideoSupplement.embed, )
def test_de_json_required(self, client): json_dict = { 'cover': self.cover, 'title': self.title, 'provider': self.provider, 'provider_video_id': self.provider_video_id } video_supplement = VideoSupplement.de_json(json_dict, client) assert video_supplement.cover == self.cover assert video_supplement.title == self.title assert video_supplement.provider == self.provider assert video_supplement.provider_video_id == self.provider_video_id
def test_de_json_all(self, client): json_dict = { 'cover': self.cover, 'title': self.title, 'provider': self.provider, 'provider_video_id': self.provider_video_id, 'url': self.url, 'embed_url': self.embed_url, 'embed': self.embed } video_supplement = VideoSupplement.de_json(json_dict, client) assert video_supplement.cover == self.cover assert video_supplement.title == self.title assert video_supplement.provider == self.provider assert video_supplement.provider_video_id == self.provider_video_id assert video_supplement.url == self.url assert video_supplement.embed_url == self.embed_url assert video_supplement.embed == self.embed
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_list_none(self, client): assert VideoSupplement.de_list({}, client) == []
def test_de_json_none(self, client): assert VideoSupplement.de_json({}, client) is None
def test_de_json_required(self, client): json_dict = {'cover': self.cover, 'provider': self.provider} video_supplement = VideoSupplement.de_json(json_dict, client) assert video_supplement.cover == self.cover assert video_supplement.provider == self.provider