コード例 #1
0
    def test_equality(self):
        a = Title(self.title, self.full_title)
        b = Title('')
        c = Title(self.title, self.full_title)

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

        assert a == c
コード例 #2
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)
コード例 #3
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)
コード例 #4
0
ファイル: genre.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.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)
コード例 #5
0
ファイル: conftest.py プロジェクト: trousev/yandex-music-api
def title():
    return Title(TestTitle.title, TestTitle.full_title)
コード例 #6
0
    def test_de_json_all(self, client):
        json_dict = {'title': self.title, 'full_title': self.full_title}
        title = Title.de_json(json_dict, client)

        assert title.title == self.title
        assert title.full_title == self.full_title
コード例 #7
0
    def test_de_json_required(self, client):
        json_dict = {'title': self.title}
        title = Title.de_json(json_dict, client)

        assert title.title == self.title
コード例 #8
0
 def test_de_json_none(self, client):
     assert Title.de_json({}, client) is None