def test_equality(self): a = InvocationInfo(self.hostname, self.req_id) b = InvocationInfo('', self.req_id, 0) c = InvocationInfo(self.hostname, self.req_id, 20) assert a != b assert hash(a) != hash(b) assert a is not b assert a == c
def test_de_json_all(self, client): json_dict = {'hostname': self.hostname, 'req_id': self.req_id, 'exec_duration_millis': self.exec_duration_millis} invocation_info = InvocationInfo.de_json(json_dict, client) assert invocation_info.hostname == self.hostname assert invocation_info.req_id == self.req_id assert invocation_info.exec_duration_millis == self.exec_duration_millis
def de_json(cls, data, client): if not data: return None data = super(Response, cls).de_json(data, client) data['data'] = data.copy() from yandex_music import InvocationInfo data['invocation_info'] = InvocationInfo.de_json( data.get('invocation_info'), client) return cls(client=client, **data)
def de_json(cls, data: dict, client: 'Client') -> Optional['Response']: """Десериализация объекта. Args: data (:obj:`dict`): Поля и значения десериализуемого объекта. client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music. Returns: :obj:`yandex_music.utils.response.Response`: Ответ API. """ if not data: return None data = super(Response, cls).de_json(data, client) data['data'] = data.copy() from yandex_music import InvocationInfo data['invocation_info'] = InvocationInfo.de_json(data.get('invocation_info'), 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.utils.response.Response`: Объект класса :class:`yandex_music.utils.response.Response`. """ if not data: return None data = super(Response, cls).de_json(data, client) data['data'] = data.copy() from yandex_music import InvocationInfo data['invocation_info'] = InvocationInfo.de_json(data.get('invocation_info'), client) return cls(client=client, **data)
def invocation_info(): return InvocationInfo(TestInvocationInfo.hostname, TestInvocationInfo.req_id, TestInvocationInfo.exec_duration_millis)
def test_de_json_required(self, client): json_dict = {'hostname': self.hostname, 'req_id': self.req_id} invocation_info = InvocationInfo.de_json(json_dict, client) assert invocation_info.hostname == self.hostname assert invocation_info.req_id == self.req_id
def test_de_json_none(self, client): assert InvocationInfo.de_json({}, client) is None