def test_equality(self, auto_renewable):
        a = Subscription([auto_renewable])
        b = Subscription(None)

        assert a != b != auto_renewable
        assert hash(a) != hash(b) != hash(auto_renewable)
        assert a is not auto_renewable
示例#2
0
    def test_equality(self, renewable_remainder, auto_renewable):
        a = Subscription(renewable_remainder, [auto_renewable],
                         [auto_renewable])
        b = Subscription(renewable_remainder, [], [auto_renewable])

        assert a != b != auto_renewable
        assert hash(a) != hash(b) != hash(auto_renewable)
        assert a is not auto_renewable
示例#3
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)
    def test_de_json_all(self, client, auto_renewable):
        json_dict = {'auto_renewable': [auto_renewable.to_dict()], 'can_start_trial': self.can_start_trial,
                     'mcdonalds': self.mcdonalds, 'end': self.end}
        subscription = Subscription.de_json(json_dict, client)

        assert subscription.auto_renewable == [auto_renewable]
        assert subscription.can_start_trial == self.can_start_trial
        assert subscription.mcdonalds == self.mcdonalds
        assert subscription.end == self.end
示例#5
0
def subscription(renewable_remainder, auto_renewable, operator,
                 non_auto_renewable):
    return Subscription(
        renewable_remainder,
        [auto_renewable],
        [auto_renewable],
        [operator],
        non_auto_renewable,
        TestSubscription.can_start_trial,
        TestSubscription.mcdonalds,
        TestSubscription.end,
    )
示例#6
0
    def test_de_json_required(self, client, renewable_remainder,
                              auto_renewable):
        json_dict = {
            'non_auto_renewable_remainder': renewable_remainder.to_dict(),
            'auto_renewable': [auto_renewable.to_dict()],
            'family_auto_renewable': [auto_renewable.to_dict()],
        }
        subscription = Subscription.de_json(json_dict, client)

        assert subscription.non_auto_renewable_remainder == renewable_remainder
        assert subscription.auto_renewable == [auto_renewable]
        assert subscription.family_auto_renewable == [auto_renewable]
    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)
示例#8
0
    def test_de_json_all(self, client, renewable_remainder, auto_renewable,
                         non_auto_renewable, operator):
        json_dict = {
            'auto_renewable': [auto_renewable.to_dict()],
            'can_start_trial': self.can_start_trial,
            'mcdonalds': self.mcdonalds,
            'end': self.end,
            'non_auto_renewable_remainder': renewable_remainder.to_dict(),
            'family_auto_renewable': [auto_renewable.to_dict()],
            'non_auto_renewable': non_auto_renewable.to_dict(),
            'operator': [operator.to_dict()],
        }
        subscription = Subscription.de_json(json_dict, client)

        assert subscription.non_auto_renewable_remainder == renewable_remainder
        assert subscription.auto_renewable == [auto_renewable]
        assert subscription.family_auto_renewable == [auto_renewable]
        assert subscription.operator == [operator]
        assert subscription.non_auto_renewable == non_auto_renewable
        assert subscription.can_start_trial == self.can_start_trial
        assert subscription.mcdonalds == self.mcdonalds
        assert subscription.end == self.end
示例#9
0
def subscription(auto_renewable):
    return Subscription([auto_renewable], TestSubscription.can_start_trial, TestSubscription.mcdonalds,
                        TestSubscription.end)
 def test_de_json_required(self, client):
     json_dict = {}
     subscription = Subscription.de_json(json_dict, client)
示例#11
0
 def test_de_json_none(self, client):
     assert Subscription.de_json({}, client) is None