def test_equality(self, shot_type):
        a = ShotData(self.cover_uri, self.mds_url, self.shot_text, shot_type)
        b = ShotData('', self.mds_url, self.shot_text, shot_type)
        c = ShotData(self.cover_uri, '', self.shot_text, shot_type)
        d = ShotData(self.cover_uri, self.mds_url, self.shot_text, shot_type)

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

        assert a == d
        assert hash(a) == hash(d)
    def test_de_json_all(self, client, shot_type):
        json_dict = {
            'cover_uri': self.cover_uri,
            'mds_url': self.mds_url,
            'shot_text': self.shot_text,
            'shot_type': shot_type.to_dict(),
        }
        shot_data = ShotData.de_json(json_dict, client)

        assert shot_data.cover_uri == self.cover_uri
        assert shot_data.mds_url == self.mds_url
        assert shot_data.shot_text == self.shot_text
        assert shot_data.shot_type == shot_type
示例#3
0
    def de_json(cls, data: dict, client: 'Client') -> Optional['Shot']:
        """Десериализация объекта.

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

        Returns:
            :obj:`yandex_music.Shot`: Шот от Алисы.
        """
        if not data:
            return None

        data = super(Shot, cls).de_json(data, client)
        from yandex_music import ShotData
        data['shot_data'] = ShotData.de_json(data.get('shot_data'), client)

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

        data = super(Shot, cls).de_json(data, client)
        from yandex_music import ShotData
        data['shot_data'] = ShotData.de_json(data.get('shot_data'), client)

        return cls(client=client, **data)
示例#5
0
def shot_data(shot_type):
    return ShotData(TestShotData.cover_uri, TestShotData.mds_url, TestShotData.shot_text, shot_type)
 def test_de_json_none(self, client):
     assert ShotData.de_json({}, client) is None