Ejemplo n.º 1
0
    def test_equality(self, track):
        a = Sequence(self.type, track, self.liked)
        b = Sequence('', track, True)
        c = Sequence(self.type, track, self.liked)

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

        assert a == c
    def de_json(cls, data, client) -> Optional['StationTracksResult']:
        if not data:
            return None

        data = super(StationTracksResult, cls).de_json(data, client)
        from yandex_music import Id, Sequence
        data['id_'] = Id.de_json(data.get('id_'), client)
        data['sequence'] = Sequence.de_list(data.get('sequence'), client)

        return cls(client=client, **data)
Ejemplo n.º 3
0
    def test_de_json_all(self, client, track):
        json_dict = {
            'type_': self.type,
            'track': track.to_dict(),
            'liked': self.liked
        }
        sequence = Sequence.de_json(json_dict, client)

        assert sequence.type == self.type
        assert sequence.track == track
        assert sequence.liked == self.liked
Ejemplo n.º 4
0
    def de_json(cls, data, client) -> Optional['StationTracksResult']:
        """Десериализация объекта.

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

        Returns:
            :obj:`yandex_music.StationTracksResult`: Последовательность треков станции.
        """
        if not data:
            return None

        data = super(StationTracksResult, cls).de_json(data, client)
        from yandex_music import Id, Sequence
        data['id_'] = Id.de_json(data.get('id_'), client)
        data['sequence'] = Sequence.de_list(data.get('sequence'), client)

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

        data = super(StationTracksResult, cls).de_json(data, client)
        from yandex_music import Id, Sequence
        data['id_'] = Id.de_json(data.get('id_'), client)
        data['sequence'] = Sequence.de_list(data.get('sequence'), client)

        return cls(client=client, **data)
Ejemplo n.º 6
0
def sequence(track):
    return Sequence(TestSequence.type, track, TestSequence.liked)
Ejemplo n.º 7
0
 def test_de_list_none(self, client):
     assert Sequence.de_list({}, client) == []
Ejemplo n.º 8
0
 def test_de_json_none(self, client):
     assert Sequence.de_json({}, client) is None