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
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)
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
def test_de_json_required(self, client): json_dict = {} subscription = Subscription.de_json(json_dict, client)
def test_de_json_none(self, client): assert Subscription.de_json({}, client) is None