def test_equality(self, account, permissions, subscription): a = Status(account, permissions) b = Status(None, permissions) c = Status(account, permissions) assert a != b assert hash(a) != hash(b) assert a is not b assert a == c
def test_de_json_all(self, client, account, permissions, subscription, plus, alert): json_dict = { 'account': account.to_dict(), 'permissions': permissions.to_dict(), 'subscription': subscription.to_dict(), 'cache_limit': self.cache_limit, 'subeditor': self.subeditor, 'subeditor_level': self.subeditor_level, 'plus': plus.to_dict(), 'default_email': self.default_email, 'skips_per_hour': self.skips_per_hour, 'station_exists': self.station_exists, 'premium_region': self.premium_region, 'advertisement': self.advertisement, 'bar_below': alert.to_dict(), 'experiment': self.experiment, } status = Status.de_json(json_dict, client) assert status.account == account assert status.permissions == permissions assert status.subscription == subscription assert status.advertisement == self.advertisement assert status.cache_limit == self.cache_limit assert status.subeditor == self.subeditor assert status.subeditor_level == self.subeditor_level assert status.plus == plus assert status.default_email == self.default_email assert status.skips_per_hour == self.skips_per_hour assert status.station_exists == self.station_exists assert status.bar_below == alert assert status.premium_region == self.premium_region assert status.experiment == self.experiment
def test_de_json_required(self, client, account, permissions): json_dict = { 'account': account.to_dict(), 'permissions': permissions.to_dict() } status = Status.de_json(json_dict, client) assert status.account == account assert status.permissions == permissions
def status(account, permissions, subscription, plus, station_data, alert): return Status( account, permissions, TestStatus.advertisement, subscription, TestStatus.cache_limit, TestStatus.subeditor, TestStatus.subeditor_level, plus, TestStatus.default_email, TestStatus.skips_per_hour, TestStatus.station_exists, station_data, alert, TestStatus.premium_region, TestStatus.experiment, )
def de_json(cls, data: dict, client: 'Client') -> Optional['PromoCodeStatus']: """Десериализация объекта. Args: data (:obj:`dict`): Поля и значения десериализуемого объекта. client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music. Returns: :obj:`yandex_music.PromoCodeStatus`: Статус активации промо-кода. """ if not data: return None data = super(PromoCodeStatus, cls).de_json(data, client) from yandex_music import Status data['account_status'] = Status.de_json(data.get('account_status'), 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.PromoCodeStatus`: Объект класса :class:`yandex_music.PromoCodeStatus`. """ if not data: return None data = super(PromoCodeStatus, cls).de_json(data, client) from yandex_music import Status data['account_status'] = Status.de_json(data.get('account_status'), client) return cls(client=client, **data)
def account_status(self, timeout=None, *args, **kwargs): """Получение статуса аккаунта. Нет обязательных параметров. Args: timeout (:obj:`int` | :obj:`float`, optional): Если это значение указано, используется как время ожидания ответа от сервера вместо указанного при создании пула. **kwargs (:obj:`dict`, optional): Произвольные аргументы (будут переданы в запрос). Returns: :obj:`yandex_music.Status`: Объекта класса :class:`yandex_music.Status` предоставляющий информацию об аккаунте если валиден, иначе :obj:`None`. Raises: :class:`yandex_music.YandexMusicError` """ url = f'{self.base_url}/account/status' result = self._request.get(url, timeout=timeout, *args, **kwargs) return Status.de_json(result, self)
def status(account, permissions, subscription, plus): return Status(account, permissions, subscription, TestStatus.cache_limit, TestStatus.subeditor, TestStatus.subeditor_level, plus, TestStatus.default_email, TestStatus.skips_per_hour, TestStatus.station_exists, TestStatus.premium_region)
def rotor_account_status(self, timeout=None, *args, **kwargs): url = f'{self.base_url}/rotor/account/status' result = self._request.get(url, timeout=timeout, *args, **kwargs) return Status.de_json(result, self)
def test_de_json_none(self, client): assert Status.de_json({}, client) is None