コード例 #1
0
    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
コード例 #2
0
ファイル: day.py プロジェクト: sibiryoff/yandex-music-api
    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)
コード例 #3
0
    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)
コード例 #4
0
ファイル: day.py プロジェクト: Angel777d/yandex-music-api
    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)
コード例 #5
0
ファイル: conftest.py プロジェクト: trousev/yandex-music-api
def track_with_ads(track):
    return TrackWithAds(TestTrackWithAds.type, track)
コード例 #6
0
    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
コード例 #7
0
 def test_de_list_none(self, client):
     assert TrackWithAds.de_list({}, client) == []
コード例 #8
0
 def test_de_json_none(self, client):
     assert TrackWithAds.de_json({}, client) is None