예제 #1
0
    def de_json(cls, data: dict, client: 'Client') -> Optional['Genre']:
        if not data:
            return None

        data = super(Genre, cls).de_json(data, client)
        from yandex_music import Title, Icon, Images
        data['titles'] = Title.de_dict(data.get('titles'), client)
        data['images'] = Images.de_json(data.get('images'), client)
        data['radio_icon'] = Icon.de_json(data.get('radio_icon'), client)
        data['sub_genres'] = Genre.de_list(data.get('sub_genres'), client)

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

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

        Returns:
            :obj:`yandex_music.Genre`: Жанр музыки.
        """
        if not data:
            return None

        data = super(Genre, cls).de_json(data, client)
        from yandex_music import Title, Icon, Images
        data['titles'] = Title.de_dict(data.get('titles'), client)
        data['images'] = Images.de_json(data.get('images'), client)
        data['radio_icon'] = Icon.de_json(data.get('radio_icon'), client)
        data['sub_genres'] = Genre.de_list(data.get('sub_genres'), client)

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

        data = super(Genre, cls).de_json(data, client)
        from yandex_music import Title, Icon, Images
        data['titles'] = Title.de_dict(data.get('titles'), client)
        data['images'] = Images.de_json(data.get('images'), client)
        data['radio_icon'] = Icon.de_json(data.get('radio_icon'), client)
        data['sub_genres'] = Genre.de_list(data.get('sub_genres'), client)

        return cls(client=client, **data)
예제 #4
0
def images():
    return Images(TestImages._208x208, TestImages._300x300)
예제 #5
0
    def test_equality(self):
        a = Images(self._208x208, self._300x300)
        b = Images(self._208x208, self._300x300)

        assert a == b
예제 #6
0
    def test_de_json_all(self, client):
        json_dict = {'_208x208': self._208x208, '_300x300': self._300x300}
        images = Images.de_json(json_dict, client)

        assert images._208x208 == self._208x208
        assert images._300x300 == self._300x300
예제 #7
0
 def test_de_json_required(self, client):
     json_dict = {}
     images = Images.de_json(json_dict, client)
예제 #8
0
 def test_de_json_none(self, client):
     assert Images.de_json({}, client) is None