Ejemplo n.º 1
0
    def test_equality(self):
        a = Permissions(self.until, self.values, self.default)
        b = Permissions('', self.values, self.default)
        c = Permissions(self.until, self.values, self.default)

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

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

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

        Returns:
            :obj:`yandex_music.Status`: Информация об аккаунте пользователя.
        """
        if not data:
            return None

        data = super(Status, cls).de_json(data, client)
        from yandex_music import Account, Permissions, Plus, Subscription, StationData, Alert

        data['account'] = Account.de_json(data.get('account'), client)
        data['permissions'] = Permissions.de_json(data.get('permissions'),
                                                  client)
        data['subscription'] = Subscription.de_json(data.get('subscription'),
                                                    client)
        data['plus'] = Plus.de_json(data.get('plus'), client)
        data['station_data'] = StationData.de_json(data.get('station_data'),
                                                   client)
        data['bar_below'] = Alert.de_json(data.get('bar_below'), client)

        return cls(client=client, **data)
Ejemplo n.º 3
0
    def test_de_json_all(self, client):
        json_dict = {
            'until': self.until,
            'values': self.values,
            'default': self.default
        }
        permissions = Permissions.de_json(json_dict, client)

        assert permissions.until == self.until
        assert permissions.values == self.values
        assert permissions.default == self.default
Ejemplo n.º 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.Status`: Объект класса :class:`yandex_music.Status`.
        """
        if not data:
            return None

        data = super(Status, cls).de_json(data, client)
        from yandex_music import Account, Permissions, Plus, Subscription
        data['account'] = Account.de_json(data.get('account'), client)
        data['permissions'] = Permissions.de_json(data.get('permissions'), client)
        data['subscription'] = Subscription.de_json(data.get('subscription'), client)
        data['plus'] = Plus.de_json(data.get('plus'), client)

        return cls(client=client, **data)
Ejemplo n.º 5
0
def permissions():
    return Permissions(TestPermissions.until, TestPermissions.values, TestPermissions.default)
Ejemplo n.º 6
0
 def test_de_json_none(self, client):
     assert Permissions.de_json({}, client) is None