def test_equality(self, track): a = TrackWithAds(self.type, track) b = TrackWithAds('', track) c = TrackWithAds(self.type, track) assert a != b assert hash(a) != hash(b) assert a is not b assert a == c
def de_json(cls, data, client): if not data: return None data = super(Day, cls).de_json(data, client) from yandex_music import Event, Track, TrackWithAds data['events'] = Event.de_list(data.get('events'), client) data['tracks_to_play_with_ads'] = TrackWithAds.de_list(data.get('tracks_to_play_with_ads'), client) data['tracks_to_play'] = Track.de_list(data.get('tracks_to_play'), client) return cls(client=client, **data)
def de_json(cls, data: dict, client: 'Client') -> Optional['Day']: """Десериализация объекта. Args: data (:obj:`dict`): Поля и значения десериализуемого объекта. client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music. Returns: :obj:`yandex_music.Day`: День в фиде. """ if not data: return None data = super(Day, cls).de_json(data, client) from yandex_music import Event, Track, TrackWithAds data['events'] = Event.de_list(data.get('events'), client) data['tracks_to_play_with_ads'] = TrackWithAds.de_list(data.get('tracks_to_play_with_ads'), client) data['tracks_to_play'] = Track.de_list(data.get('tracks_to_play'), 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.Day`: Объект класса :class:`yandex_music.Day`. """ if not data: return None data = super(Day, cls).de_json(data, client) from yandex_music import Event, Track, TrackWithAds data['events'] = Event.de_list(data.get('events'), client) data['tracks_to_play_with_ads'] = TrackWithAds.de_list( data.get('tracks_to_play_with_ads'), client) data['tracks_to_play'] = Track.de_list(data.get('tracks_to_play'), client) return cls(client=client, **data)
def track_with_ads(track): return TrackWithAds(TestTrackWithAds.type, track)
def test_de_json_all(self, client, track): json_dict = {'type_': self.type, 'track': track.to_dict()} track_with_ads = TrackWithAds.de_json(json_dict, client) assert track_with_ads.type == self.type assert track_with_ads.track == track
def test_de_list_none(self, client): assert TrackWithAds.de_list({}, client) == []
def test_de_json_none(self, client): assert TrackWithAds.de_json({}, client) is None