Beispiel #1
0
    def test_equality(self, playlist):
        a = GeneratedPlaylist(self.type, self.ready, self.notify, playlist)
        b = GeneratedPlaylist(self.type, False, self.notify, None)
        c = GeneratedPlaylist(self.type, self.ready, self.notify, playlist)

        assert a != b
        assert hash(a) != hash(b)
        assert a is not b

        assert a == c
Beispiel #2
0
def generated_playlist(playlist):
    return GeneratedPlaylist(
        TestGeneratedPlaylist.type,
        TestGeneratedPlaylist.ready,
        TestGeneratedPlaylist.notify,
        playlist,
        TestGeneratedPlaylist.description,
    )
Beispiel #3
0
    def test_de_json_all(self, client, playlist):
        json_dict = {'type_': self.type, 'ready': self.ready, 'notify': self.notify, 'data': playlist.to_dict()}
        generated_playlist = GeneratedPlaylist.de_json(json_dict, client)

        assert generated_playlist.type == self.type
        assert generated_playlist.ready == self.ready
        assert generated_playlist.notify == self.notify
        assert generated_playlist.data == playlist
Beispiel #4
0
    def de_json(cls, data: dict, client: 'Client') -> Optional['Feed']:
        if not data:
            return None

        data = super(Feed, cls).de_json(data, client)
        from yandex_music import GeneratedPlaylist, Day
        data['generated_playlists'] = GeneratedPlaylist.de_list(
            data.get('generated_playlists'), client)
        data['days'] = Day.de_list(data.get('days'), client)

        return cls(client=client, **data)
Beispiel #5
0
    def de_json(cls, data: dict, client: 'Client') -> Optional['Feed']:
        """Десериализация объекта.

        Args:
            data (:obj:`dict`): Поля и значения десериализуемого объекта.
            client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music.

        Returns:
            :obj:`yandex_music.Feed`: Фид.
        """
        if not data:
            return None

        data = super(Feed, cls).de_json(data, client)
        from yandex_music import GeneratedPlaylist, Day
        data['generated_playlists'] = GeneratedPlaylist.de_list(
            data.get('generated_playlists'), client)
        data['days'] = Day.de_list(data.get('days'), client)

        return cls(client=client, **data)
Beispiel #6
0
    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.Feed`: Объект класса :class:`yandex_music.Feed`.
        """
        if not data:
            return None

        data = super(Feed, cls).de_json(data, client)
        from yandex_music import GeneratedPlaylist, Day
        data['generated_playlists'] = GeneratedPlaylist.de_list(
            data.get('generated_playlists'), client)
        data['days'] = Day.de_list(data.get('days'), client)

        return cls(client=client, **data)
Beispiel #7
0
 def test_de_list_none(self, client):
     assert GeneratedPlaylist.de_list({}, client) == []
Beispiel #8
0
 def test_de_json_none(self, client):
     assert GeneratedPlaylist.de_json({}, client) is None