Exemple #1
0
    def test_equality(self):
        a = TrackPosition(self.volume, self.index)
        b = TrackPosition(5, self.index)
        c = TrackPosition(self.volume, 10)

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

        assert a == c
Exemple #2
0
    def de_json(cls, data: dict, client: 'Client') -> Optional['Album']:
        """Десериализация объекта.

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

        Returns:
            :obj:`yandex_music.Album`: Альбом.
        """
        if not data:
            return None

        data = super(Album, cls).de_json(data, client)
        from yandex_music import Artist, Label, TrackPosition, Track, Deprecation

        data['artists'] = Artist.de_list(data.get('artists'), client)
        data['labels'] = Label.de_list(data.get('labels'), client)
        data['track_position'] = TrackPosition.de_json(
            data.get('track_position'), client)
        data['duplicates'] = Album.de_list(data.get('duplicates'), client)
        data['albums'] = Album.de_list(data.get('albums'), client)
        data['deprecation'] = Deprecation.de_json(data.get('deprecation'),
                                                  client)
        if data.get('volumes'):
            data['volumes'] = [
                Track.de_list(i, client) for i in data['volumes']
            ]

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

        data = super(Album, cls).de_json(data, client)
        from yandex_music import Artist, Label, TrackPosition, Track
        data['artists'] = Artist.de_list(data.get('artists'), client)
        data['labels'] = Label.de_list(data.get('labels'), client)
        data['track_position'] = TrackPosition.de_json(
            data.get('track_position'), client)
        if data.get('volumes'):
            data['volumes'] = [
                Track.de_list(i, client) for i in data['volumes']
            ]

        return cls(client=client, **data)
Exemple #4
0
    def de_json(cls, data, client):
        if not data:
            return None

        data = super(Album, cls).de_json(data, client)
        from yandex_music import Artist, Label, TrackPosition
        data['artists'] = Artist.de_list(data.get('artists'), client)
        data['labels'] = Label.de_list(data.get('labels'), client)
        data['track_position'] = TrackPosition.de_json(data.get('track_position'), client)

        return cls(client=client, **data)
Exemple #5
0
    def de_json(cls, data: dict, client: 'Client') -> Optional['Album']:
        if not data:
            return None

        data = super(Album, cls).de_json(data, client)
        from yandex_music import Artist, Label, TrackPosition, Track
        data['artists'] = Artist.de_list(data.get('artists'), client)
        data['labels'] = Label.de_list(data.get('labels'), client)
        data['track_position'] = TrackPosition.de_json(
            data.get('track_position'), client)
        if data.get('volumes'):
            data['volumes'] = [
                Track.de_list(i, client) for i in data['volumes']
            ]

        return cls(client=client, **data)
Exemple #6
0
def track_position():
    return TrackPosition(TestTrackPosition.volume, TestTrackPosition.index)
Exemple #7
0
    def test_de_json_all(self, client):
        json_dict = {'volume': self.volume, 'index': self.index}
        track_position = TrackPosition.de_json(json_dict, client)

        assert track_position.volume == self.volume
        assert track_position.index == self.index
Exemple #8
0
 def test_de_json_none(self, client):
     assert TrackPosition.de_json({}, client) is None