def test_equality(self): a = AdParams(self.partner_id, self.category_id, self.page_ref, self.target_ref, self.other_params, self.ad_volume) b = AdParams(self.partner_id, '10', self.page_ref, self.target_ref, self.other_params, self.ad_volume) c = AdParams(self.partner_id, self.category_id, '', self.target_ref, self.other_params, -30) d = AdParams(self.partner_id, self.category_id, self.page_ref, self.target_ref, self.other_params, self.ad_volume) assert a != b != c assert hash(a) != hash(b) != hash(c) assert a is not b is not c assert a == d
def ad_params(): return AdParams( TestAdParams.partner_id, TestAdParams.category_id, TestAdParams.page_ref, TestAdParams.target_ref, TestAdParams.other_params, TestAdParams.ad_volume, TestAdParams.genre_id, TestAdParams.genre_name, )
def de_json(cls, data, client): if not data: return None data = super(StationResult, cls).de_json(data, client) from yandex_music import Station, RotorSettings, AdParams data['station'] = Station.de_json(data.get('station'), client) data['settings'] = RotorSettings.de_json(data.get('settings'), client) data['settings2'] = RotorSettings.de_json(data.get('settings2'), client) data['ad_params'] = AdParams.de_json(data.get('ad_params'), client) return cls(client=client, **data)
def test_de_json_required(self, client): json_dict = { 'partner_id': self.partner_id, 'category_id': self.category_id, 'page_ref': self.page_ref, 'target_ref': self.target_ref, 'other_params': self.other_params, 'ad_volume': self.ad_volume } ad_params = AdParams.de_json(json_dict, client) assert ad_params.partner_id == self.partner_id assert ad_params.category_id == self.category_id assert ad_params.page_ref == self.page_ref assert ad_params.target_ref == self.target_ref assert ad_params.other_params == self.other_params assert ad_params.ad_volume == self.ad_volume
def de_json(cls, data: dict, client: 'Client') -> Optional['StationResult']: """Десериализация объекта. Args: data (:obj:`dict`): Поля и значения десериализуемого объекта. client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music. Returns: :obj:`yandex_music.StationResult`: Радиостанция с настройками. """ if not data: return None data = super(StationResult, cls).de_json(data, client) from yandex_music import Station, RotorSettings, AdParams data['station'] = Station.de_json(data.get('station'), client) data['settings'] = RotorSettings.de_json(data.get('settings'), client) data['settings2'] = RotorSettings.de_json(data.get('settings2'), client) data['ad_params'] = AdParams.de_json(data.get('ad_params'), 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.StationResult`: Объект класса :class:`yandex_music.StationResult`. """ if not data: return None data = super(StationResult, cls).de_json(data, client) from yandex_music import Station, RotorSettings, AdParams data['station'] = Station.de_json(data.get('station'), client) data['settings'] = RotorSettings.de_json(data.get('settings'), client) data['settings2'] = RotorSettings.de_json(data.get('settings2'), client) data['ad_params'] = AdParams.de_json(data.get('ad_params'), client) return cls(client=client, **data)
def test_de_json_none(self, client): assert AdParams.de_json({}, client) is None