Ejemplo n.º 1
0
def test_client_uses_correct_transport(client, mock_protocol, method_name,
                                       method_args, method_kwargs,
                                       async_kwargs, mock_transport):
    req = Mock(RPCRequest)
    req.unique_id = '0'
    req.method = 'test_method'
    req.callback = async_kwargs['callback']
    req.sync = async_kwargs[
        'asynchronize'] if 'asynchronize' in async_kwargs else True
    req.args = method_args
    req.kwargs = method_kwargs
    mock_protocol.create_request = Mock(return_value=req)
    method_kwargs.update(async_kwargs)
    client.call(method_name, method_args, method_kwargs)
    assert mock_transport.send_message.called
Ejemplo n.º 2
0
def test_client_passes_correct_reply(client, mock_protocol, method_name,
                                     method_args, method_kwargs, async_kwargs,
                                     mock_transport):
    req = Mock(RPCRequest)
    req.unique_id = '0'
    req.method = 'test_method'
    req.callback = async_kwargs['callback']
    req.sync = async_kwargs[
        'asynchronize'] if 'asynchronize' in async_kwargs else True
    req.args = method_args
    req.kwargs = method_kwargs
    method_kwargs.update(async_kwargs)
    mock_protocol.create_request = Mock(return_value=req)
    transport_return = '023hoisdfh'
    client.receiver.transport.receive_reply = Mock(
        return_value=transport_return)
    time.sleep(0.1)
    client.call(method_name, method_args, method_kwargs)
    mock_protocol.parse_reply.assert_called_with(transport_return)