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, passport_phone): json_dict = { 'now': self.now, 'region': self.region, 'service_available': self.service_available, 'uid': self.uid, 'login': self.login, 'full_name': self.full_name, 'second_name': self.second_name, 'first_name': self.first_name, 'display_name': self.display_name, 'hosted_user': self.hosted_user, 'birthday': self.birthday, 'passport_phones': [passport_phone.to_dict()], 'registered_at': self.registered_at, 'has_info_for_app_metrica': self.has_info_for_app_metrica } account = Account.de_json(json_dict, client) assert account.now == self.now assert account.region == self.region assert account.service_available == self.service_available assert account.uid == self.uid assert account.login == self.login assert account.full_name == self.full_name assert account.second_name == self.second_name assert account.first_name == self.first_name assert account.display_name == self.display_name assert account.hosted_user == self.hosted_user assert account.birthday == self.birthday assert account.passport_phones == [passport_phone] assert account.registered_at == self.registered_at assert account.has_info_for_app_metrica == self.has_info_for_app_metrica
def account(passport_phone): return Account(TestAccount.now, TestAccount.service_available, TestAccount.region, TestAccount.uid, TestAccount.login, TestAccount.full_name, TestAccount.second_name, TestAccount.first_name, TestAccount.display_name, TestAccount.hosted_user, TestAccount.birthday, [passport_phone], TestAccount.registered_at, TestAccount.has_info_for_app_metrica)
def test_de_json_required(self, client): json_dict = { 'now': self.now, 'service_available': self.service_available } account = Account.de_json(json_dict, client) assert account.now == self.now assert account.service_available == self.service_available
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_equality(self, user): a = Account(self.now, self.service_available) assert a != user assert hash(a) != hash(user) assert a is not user
def test_de_json_none(self, client): assert Account.de_json({}, client) is None
from yandex_music import Client from yandex_music import Account from audioplayer import AudioPlayer from tkinter import Tk root = Tk() root.title("test") root.geometry("800x600") client = Client('AQAAAAAqSSA-AATuwYuw0JZQVECvmiI3T1btTgs') acc = Account() print(acc.login()) root.mainloop()