def test_equality(self): a = User(self.uid, self.login, self.name, self.sex, self.verified) b = User(1, self.login, self.name, self.sex, self.verified) c = User(self.uid, self.login, '', self.sex, self.verified) assert a != b assert hash(a) != hash(b) assert a is not b assert a == c
def test_equality(self): a = User(self.uid, self.login) b = User(1, self.login) c = User(self.uid, self.login) assert a != b assert hash(a) != hash(b) assert a is not b assert a == c
def de_json(cls, data: dict, client: 'Client') -> Optional['Track']: """Десериализация объекта. Args: data (:obj:`dict`): Поля и значения десериализуемого объекта. client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music. Returns: :obj:`yandex_music.Track`: Трек. """ if not data: return None data = super(Track, cls).de_json(data, client) from yandex_music import Normalization, Major, Album, Artist, User, MetaData, PoetryLoverMatch data['albums'] = Album.de_list(data.get('albums'), client) data['artists'] = Artist.de_list(data.get('artists'), client) data['normalization'] = Normalization.de_json( data.get('normalization'), client) data['major'] = Major.de_json(data.get('major'), client) data['substituted'] = Track.de_json(data.get('substituted'), client) data['matched_track'] = Track.de_json(data.get('matched_track'), client) data['user_info'] = User.de_json(data.get('user_info'), client) data['meta_data'] = MetaData.de_json(data.get('meta_data'), client) data['poetry_lover_matches'] = PoetryLoverMatch.de_list( data.get('poetry_lover_matches'), client) return cls(client=client, **data)
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.Playlist`: Объект класса :class:`yandex_music.Playlist`. """ if not data: return None data = super(Playlist, cls).de_json(data, client) from yandex_music import User, MadeFor, Cover, PlayCounter, TrackShort, PlaylistAbsence data['owner'] = User.de_json(data.get('owner'), client) data['cover'] = Cover.de_json(data.get('cover'), client) data['made_for'] = MadeFor.de_json(data.get('made_for'), client) data['tracks'] = TrackShort.de_list(data.get('tracks'), client) data['play_counter'] = PlayCounter.de_json(data.get('play_counter'), client) data['playlist_absence'] = PlaylistAbsence.de_json( data.get('playlist_absence'), client) # на случай фикса if data.get('playlist_absense'): # очепятка яндуха data['playlist_absence'] = PlaylistAbsence.de_json( data.get('playlist_absense'), client) data.pop('playlist_absense') return cls(client=client, **data)
def de_json(cls, data: dict, client: 'Client') -> Optional['Playlist']: """Десериализация объекта. Args: data (:obj:`dict`): Поля и значения десериализуемого объекта. client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music. Returns: :obj:`yandex_music.Playlist`: Плейлист. """ if not data: return None data = super(Playlist, cls).de_json(data, client) from yandex_music import ( User, MadeFor, Cover, PlayCounter, TrackShort, PlaylistAbsence, Artist, TrackId, Contest, OpenGraphData, Brand, ) data['owner'] = User.de_json(data.get('owner'), client) data['cover'] = Cover.de_json(data.get('cover'), client) data['cover_without_text'] = Cover.de_json( data.get('cover_without_text'), client) data['made_for'] = MadeFor.de_json(data.get('made_for'), client) data['tracks'] = TrackShort.de_list(data.get('tracks'), client) data['recent_tracks'] = TrackId.de_list(data.get('recent_tracks'), client) data['play_counter'] = PlayCounter.de_json(data.get('play_counter'), client) data['top_artist'] = Artist.de_list(data.get('top_artist'), client) data['contest'] = Contest.de_json(data.get('contest'), client) data['og_data'] = OpenGraphData.de_json(data.get('og_data'), client) data['dummy_cover'] = Cover.de_json(data.get('dummy_cover'), client) data['dummy_rollover_cover'] = Cover.de_json( data.get('dummy_rollover_cover'), client) data['branding'] = Brand.de_json(data.get('branding'), client) data['similar_playlists'] = Playlist.de_list( data.get('similar_playlists'), client) data['last_owner_playlists'] = Playlist.de_list( data.get('last_owner_playlists'), client) data['playlist_absence'] = PlaylistAbsence.de_json( data.get('playlist_absence'), client) # на случай фикса if data.get('playlist_absense'): # очепятка яндуха data['playlist_absence'] = PlaylistAbsence.de_json( data.get('playlist_absense'), client) data.pop('playlist_absense') return cls(client=client, **data)
def test_de_json_all(self, client): json_dict = {'uid': self.uid, 'login': self.login, 'name': self.name, 'sex': self.sex, 'verified': self.verified} user = User.de_json(json_dict, client) assert user.uid == self.uid assert user.login == self.login assert user.name == self.name assert user.sex == self.sex assert user.verified == self.verified
def de_json(cls, data, client): if not data: return None data = super(MadeFor, cls).de_json(data, client) from yandex_music import User, CaseForms data['user_info'] = User.de_json(data.get('user_info'), client) data['case_forms'] = CaseForms.de_json(data.get('case_forms'), client) return cls(client=client, **data)
def user(): return User( TestUser.uid, TestUser.login, TestUser.name, TestUser.display_name, TestUser.full_name, TestUser.sex, TestUser.verified, TestUser.regions, )
def de_json(cls, data, client): if not data: return None data = super(Playlist, cls).de_json(data, client) from yandex_music import User, MadeFor, Cover, PlayCounter, TrackShort data['owner'] = User.de_json(data.get('owner'), client) data['cover'] = Cover.de_json(data.get('cover'), client) data['made_for'] = MadeFor.de_json(data.get('made_for'), client) data['tracks'] = TrackShort.de_list(data.get('tracks'), client) data['play_counter'] = PlayCounter.de_json(data.get('play_counter'), client) return cls(client=client, **data)
def de_json(cls, data, client): if not data: return None data = super(Playlist, cls).de_json(data, client) from yandex_music import User, MadeFor, Cover, PlayCounter, TrackShort, PlaylistAbsence data['owner'] = User.de_json(data.get('owner'), client) data['cover'] = Cover.de_json(data.get('cover'), client) data['made_for'] = MadeFor.de_json(data.get('made_for'), client) data['tracks'] = TrackShort.de_list(data.get('tracks'), client) data['play_counter'] = PlayCounter.de_json(data.get('play_counter'), client) data['playlist_absence'] = PlaylistAbsence.de_json(data.get('playlist_absence'), client) # на случай фикса if data.get('playlist_absense'): # очепятка яндуха data['playlist_absence'] = PlaylistAbsence.de_json(data.get('playlist_absense'), client) data.pop('playlist_absense') return cls(client=client, **data)
def de_json(cls, data: dict, client: 'Client') -> Optional['MadeFor']: """Десериализация объекта. Args: data (:obj:`dict`): Поля и значения десериализуемого объекта. client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music. Returns: :obj:`yandex_music.MadeFor`: Пользователь, для которого был сделан плейлист. """ if not data: return None data = super(MadeFor, cls).de_json(data, client) from yandex_music import User, CaseForms data['user_info'] = User.de_json(data.get('user_info'), client) data['case_forms'] = CaseForms.de_json(data.get('case_forms'), client) return cls(client=client, **data)
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.MadeFor`: Объект класса :class:`yandex_music.MadeFor`. """ if not data: return None data = super(MadeFor, cls).de_json(data, client) from yandex_music import User, CaseForms data['user_info'] = User.de_json(data.get('user_info'), client) data['case_forms'] = CaseForms.de_json(data.get('case_forms'), client) return cls(client=client, **data)
def de_json(cls, data: dict, client: 'Client') -> Optional['AutoRenewable']: """Десериализация объекта. Args: data (:obj:`dict`): Поля и значения десериализуемого объекта. client (:obj:`yandex_music.Client`): Клиент Yandex Music. Returns: :obj:`yandex_music.AutoRenewable`: Информация об автопродлении подписки. """ if not data: return None data = super(AutoRenewable, cls).de_json(data, client) from yandex_music import Product, User data['product'] = Product.de_json(data.get('product'), client) data['master_info'] = User.de_json(data.get('master_info'), client) return cls(client=client, **data)
def test_de_json_all(self, client): json_dict = { 'uid': self.uid, 'login': self.login, 'name': self.name, 'sex': self.sex, 'verified': self.verified, 'display_name': self.display_name, 'full_name': self.full_name, 'regions': self.regions, } user = User.de_json(json_dict, client) assert user.uid == self.uid assert user.login == self.login assert user.name == self.name assert user.display_name == self.display_name assert user.full_name == self.full_name assert user.sex == self.sex assert user.verified == self.verified assert user.regions == self.regions
def user(): return User(TestUser.uid, TestUser.login, TestUser.name, TestUser.sex, TestUser.verified)
def test_de_json_required(self, client): json_dict = {'uid': self.uid, 'login': self.login} user = User.de_json(json_dict, client) assert user.uid == self.uid assert user.login == self.login
def test_de_list_none(self, client): assert User.de_list({}, client) == []
def test_de_json_none(self, client): assert User.de_json({}, client) is None