Exemplo n.º 1
0
    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
Exemplo n.º 2
0
    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
Exemplo n.º 3
0
    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)
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
    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)
Exemplo n.º 6
0
def invocation_info():
    return InvocationInfo(TestInvocationInfo.hostname, TestInvocationInfo.req_id,
                          TestInvocationInfo.exec_duration_millis)
Exemplo n.º 7
0
    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